Posts

Showing posts from August, 2010

Is it possible to pass Facebook Graph API access token through request header? -

i testing facebook graph api v2.3 postman . while possible response putting access token in query string follow: https://graph.facebook.com/v2.3/me?access_token=my_access_token i wondering whether it's possible same thing http request headers, this: get /v2.3/me http/1.1 host: graph.facebook.com authorization: <my_access_token> cache-control: no-cache postman-token: <postman_token> based on similar question (i.e. how should client pass facebook access token server? ) on stackoverflow, seems should possible. any thoughts on this? edit: what raised interest that, when used api graph explorer provided facebook developers, seems there's no query string in sandbox either. how work? facebook api graph explorer use query string access token. @cbroe 's response. yes possible authorization: oauth accesstokenhere e.g. curl --header "authorization: oauth caac...zd" https://graph.facebook.com/me

c++ - Array of objects not working correctly -

i have class creates array of objects class(the array class friend) class vector_xxl { int i=0,n=0; xxl_nr *xxlvector; public: vector_xxl(int y) { n = y; xxlvector = new xxl_nr[y];} n size of array. xxl_nr class creates large numbers represented linked list(each digit has spot on list) i want product of each 2 numbers 2 array objects on same positions. so, example, v[i]*d[i] , = 0,n; this function should doesn't work correctly: void produs_scalar(vector_xxl a) { xxl_nr temp(2),temp1(2),temp2(2),result(2); vector_xxl vector_result(n); temp1 = this->xxlvector[0]; temp2 = a.xxlvector[0]; temp1.addition(temp2); for(i=0;i<n;i++) { temp = this->xxlvector[i].product(a.xxlvector[i]); vector_result.xxlvector[i] = temp; } for(i=0;i<n;i++) result= temp.product(vector_result.xxlvector[i]); result.print(); } i used temp1, , temp2 test if can use product method(defin

Multiplying column values in Google Spreadsheet with ability to add/delete rows -

Image
i have invoice, there 2 columns: rate (column h) , quantity (column i). , there amount (column j). i need formula automatically multiply rate , quantity , show in amount . number of rows changing (added or deleted), formula should still work. the following arrayformula() spans row 5 ("books name") row 14 ("total price"), adding rows or deleting them should not problem: =arrayformula(if((c5:c14="books name")+(c5:c14="total price")=1,"",h5:h14*i5:i14)) however, since formula have reside in column j, following formula more useful: =arrayformula(if(c5:c14="books name","amount",if(c5:c14="total price","",h5:h14*i5:i14)))

cordova - localStorage not being persisted in hybrid app in Android M42 -

in latest release of ·android system webview (m42 42.0.2311.129)· there seems issues localstorage in hybrid apps. i've submitted bug report trying find workaround objects not being persisted in localstorage. this taken bug report: steps reproduce problem: 1. start hybrid app built phonegap 2. in app, call javascript localstorage.setitem("m42bug","test localstorage") 3. through developer tools debugging confirm object has been stored: localstorage.getitem("m42bug") 4. close app (swipe away, force close or restarting device cause same) 5. start app 6. in app, call javascript localstorage.getitem("m42bug") what expected behavior? localstorage.getitem("m42bug") should return value "test localstorage" what went wrong? localstorage.getitem("m42bug") returns null. object.keys(localstorage) indicate there no key m42bug faced exact same problem. workaround store localstorage data on phon

c - count number of ones in a given integer using only << >> + | & ^ ~ ! = -

this question has answer here: how count number of set bits in 32-bit integer? 48 answers how write c program using << >> + | & ^ ~ ! = counts number of ones in given integer? have @ bit twiddling hacks stanford. here choices problem: the naïve approach unsigned int v; // count number of bits set in v unsigned int c; // c accumulates total bits set in v (c = 0; v; v >>= 1) { c += v & 1; } with lookup table static const unsigned char bitssettable256[256] = { # define b2(n) n, n+1, n+1, n+2 # define b4(n) b2(n), b2(n+1), b2(n+1), b2(n+2) # define b6(n) b4(n), b4(n+1), b4(n+1), b4(n+2) b6(0), b6(1), b6(1), b6(2) }; unsigned int v; // count number of bits set in 32-bit value v unsigned int c; // c total bits set in v // option 1: c = bitssettable256[v & 0xff] + bitssettable256[(v >>

pushdown automaton - Approach to finding the context free grammar of more complicated languages -

i'm having problems approaching following problem. give context free grammar following language: {x#y | x,y in {0,1}* , |x| != |y|} what best way approach question? @ moment i'm using intuition solve questions these there useful techniques? i.e. think of pda language , derive grammer that? there method finding grammer g = , b using grammars , b? i'm struggling see how solve appreciated. thanks. using intuition valuable technique. solve more such problems, intuitions sharpen, gets easier. there's no formal technique convert description of language cfg (unless description maps onto cfgs, of course, set of production rules). not, in general, decidable whether language context-free (although cfgs must conform lot of constraints, possible prove language not cfg, semi-mechanically using counting arguments.) , not case intersection of 2 context-free languages context-free, there no procedure can take 2 context-free languages , generate cfg conjunctio

c++11 - c++ typedef/type substitution for enumeration class -

as far aware @ moment not possible typedef of c++11 enum class . know if there other way can reduce length of name of variable enum when referring outside of encapsulating class. here example: // along lines of: class segmentactivitystate; using segmentactivitytype = segmentactivitystate::activitystatetype; // ...however, results in compile time error: // 'segmentactivitystate' not name type. // enumeration class definition class segmentactivitystate { public: enum class activitystatetype : index { preexecution = 0, /**< pre-execution state. */ execution = 1, /**< execution state. */ postexecution = 2 /**< post-execution state. */ }; private: activitystatetype activitystate; /**< unique object identifier tag. */ public: // ... methods work on activitystate } the important issue length of name have refer enum outside of segmentactivitytype . example, in order type comparison need write segmentactivity.

EJB Java: Better to use Session beans or message driven beans -

i design web based application. required functionality includes sending messages system remote system. in addition, ejb system respond messages remote system. which type of enterprise beans should use? should use stateless session beans, message driven bean, or both? as might know mdb asynchronous , per concerns chat application must asynchronous why client should wait response. , if application gets millions of request message stateless session not in performance better use mdb. revert me in case of concern.

python - Django with mongoengine backend and elasticsearch via haystack -

i use mongoengine backend. try integrate haystack elasticsearch engine index mongo documents. follow documentation http://django-haystack.readthedocs.org/ . when run ./manage.py rebuild_index removing documents index because said so. documents removed. /home/t/py/django/boxers/venv/local/lib/python2.7/site-packages/haystack/utils/loading.py:165: userwarning: installed app kombu.transport.django.kombuappconfig not importable python module , ignored warnings.warn('installed app %s not importable python module , ignored' % app) my django haystack 2.3.1

unity3d - Invalid LVL key! how to get LVL android key from unity? -

this code sample code in unity "google play license verification" asset. i build project, , play form android phone. but, show me "invalid lvl key!" i think, have change follow string varibale. private string m_publickey_base64 = "< set base64 encoding rsa public key >"; private string m_publickey_modulus_base64 = "<set output simpleparseasn1>"; private string m_publickey_exponent_base64 = "< .. , here >"; but, know value m_publickey_base64 , google play market. hmm...... know i'm doing wrong?? can do? please me. this part of cehcklblbutton sample source public class checklvlbutton : monobehaviour { /* * java service binder classes.jar */ public textasset servicebinder; /* * use public lvl key android market publishing section here. */ private string m_publickey_base64 = "< set base64 encoding rsa public key >"; /* * consider storing public key rsaparameters.

Analysis of sorting Algorithm with probably wrong comparator? -

it interesting question interview, failed it. an array has n different elements [a1 .. a2 .... an](random order). we have comparator c, but has probability p return correct results. now use c implement sorting algorithm (any kind, bubble, quick etc..) after sorting have [ai1, ai2, ..., ain] (it wrong) 。 now given number m (m < n), question follows: what expectation of size s of intersection between {a1, a2, ..., am} , {ai1, ai2, ..., aim}, in other words, what e[s] ? any relationship among m, n , p ? if use different sorting algorithm, how e[s] change ? my idea follows: when m=n, e[s] = n, surely when m=n-1, e[s] = n-1+p(an in ain) i dont know how complete answer thought solved through induction.. any simulation methods fine think. hm, if a1,a2,...,an in random order (as stated in question), sorting , probability of correctness of comparator c not matter. question reduced expectation of length of intersection of 2 random subsets, each of si

javascript - touchstart event listener returning undefined -

code: document.addeventlistener('touchstart', function(e) { var ypos = e.screeny; console.log(ypos); }); ypos returns undefined in console. have chekced previous answers cannot find solution. why ypos returning udefined , not y-coordinates of mouse? any appreciated. for single finger touch, need retrieve touch object e.touches[0] . e.touches (or e.changedtouches , e.targettouches ) array, because spec supports multiple finger touch well. once object, use either screenx/y , pagex/y , or clientx/y , defined in spec . however, browser implementations may still vary.

java - Filtering using Google Guava API -

is there way check if objects in list have same attribute google guava api? moreover, there way send more parameters predicate? let's said want filter objects string getting user, , want predicate use parameter when applying filter. you can create own predicate follows: class mypredicate implements predicate<myobject> { private final string parameter; public mypredicate(string parameter) {this.parameter = parameter;} boolean apply(myobject input) { // apply predicate using parameter. } } you can filter doing: iterables.filter(myiterable, new mypredicate(myparameter)); you should wary though performs lazy filter.

eclipse - How can I push project in specific folder in my GitHub repository? -

i have created new repository in github named "epamcourses2015". next created folder within named "homeworks". there 1 uri "https://github.com/username/epamcourses2015.git" , in egit plugin in eclipse added "homeworks" myself, "https://github.com/username/epamcourses2015.git/homeworks" gives me error when add in ref mappings: transport error: cannot remote repository refs. https://github.com/username/epamcourses2015.git/homeworks : https://github.com/username/epamcourses2015.git/homeworks/info/refs?service=git-upload-pack not found any 1 can tell me please, how can push projects separate folder in github repository? github isn't designed used really, can clone , push parent repository github , subrepositories not supported. you should clone epamcourses2015 repository, add homeworks folder that, commit , push github if wish inside eclipse, clone epamcourses2015 repository , create homeworks project in

java - Servlet with Ajax - POST works, but GET does not -

i making application able count numbers written in formulas. in html have put this: <input type="text" size="20" id="number2" onblur="validate2()" onfocus = "document.getelementbyid('msg2').innerhtml = ' '"> <br> <div id = "message1">&nbsp</div> i have created javascript firstly validating datas , later inserts them 'answer-formula': function validate2() { var idfield2 = document.getelementbyid("number2"); var data2 = "number2=" + encodeuricomponent(idfield2.value); if (typeof xmlhttprequest != "undefined") { req = new xmlhttprequest(); } else if (window.activexobject) { req = new activexobject("microsoft.xmlhttp"); } var url = "validator" req.open("get", url, true); req.onreadystatechange = inserter2 req.setrequestheader("content-type", "application/x-www-form-urlencod

spring - Dandelion datatables exporting to Excel - missing export links -

i've asked question on dandelion forum did not recieve answer trying here. afaik creator of dandelion answers here maybe lucky time. my stack spring 4, thymeleaf , dandelion datatables 0.10.1. trying achieve simple exporting. i've started filter based exports tables populated ajax call did not work. so i've switched controller based export - i've added code spring app problem still remains. there no export link generated in view layer! thymeleaf code looks this. <table id="appconfig" class="table-striped table-bordered datatable" dt:export="xlsx,pdf,csv,xls" dt:table="true" dt:url="url_where_dataatbles_controller_works" dt:pageable="true" dt:paginationtype="full_numbers" dt:serverside="true" dt:processing="false" dt:dom="frtlpi"> <thead> <tr> <th dt:property="key"><span>parameter key</span></

watchkit - Apple Watch display sleep pauses NSTimer, but WKInterfaceTimer keeps counting down -

as per apple documentation, 1 use both wkinterfacetimer (local watch, counts down not trigger event when ends) , nstimer (to trigger methods when timer ends). so, have both nstimer , wkinterfacetimer in app interface controller. on simulator, on schemes when watchapp runs, nstimer & wkinterfacetimer keep counting down (as should) when watch either in awake or sleep mode (using simulator lock/unlock, instructed in apple's manual). however, on real physical watch, 2 timers behave differently upon watch display sleep (blackout) , awake states. sleep mode pauses nstimer of interface controller, wkinterfacetimer keeps counting down (as should). so, 2 timers run out of synch upon first physical apple watch sleep (nstimer pauses, wkinterfacetimer keeps counting down). seeking others experiences , whether implemented way keep both nstimer , wkinterfacetime in synch regardless of watch mode (sleep or awake). it seems store end time of countdown (for example, in nsuserde

Deserialise JSON with Newtonsoft Json.NET in C# -

i want parse piece of json newtonsoft json.net json : [{ "type": "switchstatus", "data" :[ { "id" : "1", "value" : "2.5" }, { "id" : "2", "value" : "4.2" } ], "datetime": "2014-12-01", "customerid": "50" }] classes: public class account { [jsonproperty("type")] public string type { get; set; } public list<data> data { get; set; } [jsonproperty("datetime")] public string datetime { get; set; } [jsonproperty("customerid")] public string customerid { get; set; } }//account public class data { [jsonproperty("id")] public string id { get; set; } [jsonproperty("value")] public string value { get; set; } } parsing: account account = jsonconve

Use MATLAB to prompt user to select a image file -

i trying implement function starting prompting user select image , image operation. here code: [filename, path] = uigetfile ('*.bmp; *.png; *.jpg','select secret image'); secretimg = filename; r = secretimg(:,:,1); g = secretimg(:,:,2); b = secretimg(:,:,3); however, prompt me error: index exceeds matrix dimensions. error in main (line 16) g = secretimg(:,:,2); it works traditional method specify filename inside code this: %secretimg = imread('images/lena.bmp'); try this: secretimg = imread(strcat(path,filename)); full code: [filename, path] = uigetfile ('*.bmp; *.png; *.jpg','select secret image'); secretimg = imread(strcat(path,filename)); %// 1 alternative use `fullfile` rayryeng suggested, %// secretimg = imread(fullfile(path,filename)); r = secretimg(:,:,1); g = secretimg(:,:,2); b = secretimg(:,:,3);

android - Custom Drawable for ProgressDialog -

<?xml version="1.0" encoding="utf-8"?> <rotate xmlns:android="http://schemas.android.com/apk/res/android" android:pivotx="50%" android:pivoty="50%" android:fromdegrees="0" android:todegrees="360"> <shape android:shape="ring" android:innerradiusratio="3" android:thicknessratio="8" android:uselevel="false"> <size android:width="48dip" android:height="48dip" /> <gradient android:type="sweep" android:uselevel="false" android:startcolor="#4c737373" android:centercolor="#4c737373" android:centery="0.50" android:endcolor="#ffffd300" /> </shape> </rotate> this code creates circle indicator , rotate show 1 color want instead display multi-colors.

java - Simple Basketball using Graphics -

i'm thinking on how draw circle ball, because whenever used paint frame turn blank white space. there way can combine graphics or paint jlabels? i've searched internet cannot find answer hope can me. import javax.swing.*; import java.awt.*; import java.awt.event.*; public class basketball extends jframe implements actionlistener { jbutton shootbutton = new jbutton("shoot"); jbutton drbblbutton = new jbutton("dribble"); jbutton holdbutton = new jbutton("hold"); jbutton exitbutton = new jbutton("exit"); jlabel court = new jlabel(new imageicon("bcourt.jpg")); public basketball() { container c =getcontentpane(); setlayout(null); c.add(shootbutton); c.add(drbblbutton); c.add(holdbutton); c.add(exitbutton); c.add(court); shootbutton.setbounds(0,0,120,125); drbblbutton.setbounds(0,125,120,125); holdbutton.setbounds(0,250,120,125); exitbutton.setbounds(0,375,120,86); court.setbounds(120,0,380,500); settitle("basketball"

arrays - javascript: variable defined vs function undefined -

i have 2 arrays: array1 = ["one", "two"]; array2 = ["two", "four"]; if write: var inetersection = array1.filter(function(n){ return array2.indexof(n) != -1 }); i right answer: "two". but if write function: function intersection (array1, array2){ array1.filter(function(n){ return array2.indexof(n) != -1 }); } then console.log(intersection(array1, array2)); returns undefined what wrong second syntax? your function doesn't return anything. how fix it: function intersection (array1, array2){ return array1.filter(function(n){ return array2.indexof(n) != -1 }); } why? so variables have value, let's start this: var hello_world = "hello world!"; that doing it's setting value of hello_world "hello world!" . that's simple enough. explanation! now let's try function. function addnumbers (number_1, number_2) { number_1 + number_2;

php - laravel 5 boilerplate app not working -

Image
i new laravel framework, first ever application framework tried create minimal application want know how can view default auth, login, register pages found under routes.php? route::get('/', 'welcomecontroller@index'); route::get('home', 'homecontroller@index'); route::controllers([ 'auth' => 'auth\authcontroller', 'password' => 'auth\passwordcontroller', ]); i can see welcome page below, project hosted directory e:\xampp\htdocs\directory\app\ when went go path, http://localhost/directory/public/auth/login see login page without styles, plain ui this. and there when click on login button url redirecting somewhere else. its going here -> http://localhost/auth/login and displaying object not found! error. what did miss in configuration? update: seems app.blade.php not loading , why pages in plain text mode without html styles. you should set document root point directory

osx - On Mac, Drag file to my NSTableVIew? -

i able drag (any) file view-based nstableview, in delegate have setup: class myviewcontroller: nsviewcontroller, nstableviewdelegate, nstableviewdatasource, nsdraggingdestination { @iboutlet var tableview: nstableview! // connected in storyboard. override func viewdidload() { super.viewdidload() tableview.registerfordraggedtypes([nsfilenamespboardtype]) // … } func draggingentered(sender: nsdragginginfo) -> nsdragoperation { println("drag entered.") return .copy } func preparefordragoperation(sender: nsdragginginfo) -> bool { return true } func draggingupdated(sender: nsdragginginfo) -> nsdragoperation { return .copy } // ... } but program refuses react drag-n-drop. when drag file finder , release, file icon flies finder. missing in code? update: added this func performdragoperation(sender: nsdragginginfo) -> bool { return true }

javascript - AJAX not working when pressing submit button -

i practicing basics of ajax. when click submit nothing happens. here’s code. <!doctype html> <html> <head> <meta charset="utf-8"> <title>first ajax!</title> <script> function alertme(){ var field1 = document.getelementbyid("field1").value; var parser = "parse.php"; var values = "name="+filed1; var xml = new xmlhttprequest(); xml.open("post", parser, true); xml.setrequestheader("content-type", "application/x-www-form-urlencoded"); xml.onreadystatechange = function(){ if(xml.readystate == 4 && xml.status == 200){ document.getelementbyid('output').innerhtml = xml.responsetext; } } xml.send(values); document.getelementbyid('output').innerhtml = " loading ... "; } </script> </head> <body> <input type="text" name="field1" id

postgresql - haskell-postgres --> connect parameter is not a Query -

my program: import database.postgresql.simple main :: io () main = conn <- connect defaultconnectinfo { connectuser = "postgres" , connectpassword = "password" , connectdatabase = "postgres" } execute conn "create table users (id int, fname varchar(80), lname varchar(80))" () close conn error: couldn't match expected type ‘query’ actual type ‘[char]’ in second argument of ‘execute’, namely ‘"create table users (id int, fname varchar(80), lname varchar(80))"’ does user need make above psql string query typed object , send parameter connect function? tutorial not written way error meaning otherwise. from the docs : to construct query, enable ghc's overloadedstrings language extension , write query normal literal string. overloadedstrings let write appears string , have ghc auto-coerce appropriate type ( bytestring , text , query ). it's useful extension k

python - Fastest way of comparing two numpy arrays -

i have 2 arrays: >>> import numpy np >>> a=np.array([2, 1, 3, 3, 3]) >>> b=np.array([1, 2, 3, 3, 3]) what fastest way of comparing these 2 arrays equality of elements, regardless of order? edit measured execution times of following functions: def compare1(): #works arrays without redundant elements a=np.array([1,2,3,5,4]) b=np.array([2,1,3,4,5]) temp=0 in a: temp+=len(np.where(b==i)[0]) if temp==5: val=true else: val=false return 0 def compare2(): a=np.array([1,2,3,3,3]) b=np.array([2,1,3,3,3]) val=np.all(np.sort(a)==np.sort(b)) return 0 def compare3(): #thx odiogosilva a=np.array([1,2,3,3,3]) b=np.array([2,1,3,3,3]) val=set(a)==set(b) return 0 import numpy.lib.arraysetops aso def compare4(): #thx tom10 a=np.array([1,2,3,3,3]) b=np.array([2,1,3,3,3]) val=len(aso.setdiff1d(a,b))==0 retu

java - cannot start Hadoop daemons: Insufficient memory -

at first able start daemons , run jobs properly, out of nowhere, cant start daemons (start-dfs, start-yarn). after running .sh terminal waits forever (as in picture http://imgur.com/sr5i5aw ). way stop ctrl+c. logs hs_error_pidxxxx.log says insufficient memory ( http://imgur.com/3e3volg ). i tried advises found in sites, such adding swap memory, rebooting. still cant start daemons. here're in conclusion (in case might confused due bad communication skill): my vm has 4gb of memory 3.5 free @ first. i able run daemons on same vm. thank in advance every help. ps. i'm using hadoop 2.5.1 hbase 0.98.11 on ubuntu 14.04 i've solved problem removing "export hadoop_classpath= /path-to-hbase/hbase classpath " hadoop-env. if knows did wrong, appreciated know that. thanks.

python - Bogus oauth2client.tools.run() deprecation warning from GAE appcfg.py (linux, SDK 1.9.19)? -

i'm fumbling manual gae uploads since pycharm can't handle yet uploads of multi-module apps. @ point i've seen message: #################################################### oauth2 recommended authentication method. use --oauth2 flag enable. #################################################### right, read this, started using --oauth2 flag. surprise see deprecation warning @ every appcfg.py invocation: /usr/local/google_appengine/appcfg.py --oauth2 update_indexes a_module_dir -a my_app_name ... 2015-04-25 19:52:17,169 warning old_run.py:88 function, oauth2client.tools.run(), , use of gflags library deprecated , removed in future version of library. ... and update ok, no issue. i noticed warning in logs other q&as well, on windows, discussions focus on other stuff, not on warning in particular. seen in pycharm gae upload logs single module app. is warning should start worrying about? or oversight in sdk version? thanks in advance. you can i

typeclass - Coq: typeclasses vs dependent records -

i can't understand difference between typeclasses , dependent records in coq. reference manual gives syntax of typeclasses, says nothing , how should use them. bit of thinking , searching reveals typeclasses are dependent records bit of syntactic sugar allows coq automatically infer implicit instances , parameters. seems algorithm typeclasses works better when there more or less 1 possible instance of in given context, that's not big issue since can move fields of typeclass parameters, removing ambiguity. instance declaration automatically added hints database can ease proofs break them, if instances general , caused proof search loops or explosions. there other issues should aware of? heuristic choosing between two? e.g. lose if use records , set instances implicit parameters whenever possible? you right: type classes in coq records special plumbing , inference (there's special case of single-method type classes, doesn't affect answer in way). therefore,

sockets - wsgi nginx error: permission denied while connecting to upstream -

there seem many questions on stackoverflow unfortunately nothing has worked me. i'm getting 502 bad gateway on nginx, , following on logs: connect() ...myproject.sock failed (13: permission denied) while connecting upstream i'm running wsgi , nginx on ubuntu , , i've been following this guide digital ocean . apparently configured wsgi correctly since uwsgi -s myproject.sock --http 0.0.0.0:8000 --module app --callable app worked, keep getting nginx permission denied error , have no idea why: after coming across this question , this other one , changed .ini file , added chown-socket , chmod-socket , uid , gid parameters (also tried setting first two, either or, , couple of different permission settings --and permissive didn't work). this 1 seemed promising , don't believe selinux installed on ubuntu (running sudo apt-get remove selinux gives "package 'selinux' not installed, not removed" , find / -name "selinux" does

sublimetext2 - change line height in sublime text default theme after changing the font-size -

i found link on stackoverflow: sublime text 2 how change font size of file sidebar? i followed directions , changed font size, font big small of line height, looks stacked on top of each other , cut off, without room breathe. is there json label can use change line height/padding? thanks. go preferences>settings-user , add 2 line: { "line_padding_bottom": 3, "line_padding_top": 3, }

html - Why Are My Media Query's Instructions not Honored 100% On Some Devices -

in effort become mobile friendly have implemented media query kindly suggested @cchacholiades. hides "aside" (sidebar) effectively, fails expand "article" (main) resulting empty space in browsers , on devices. doing wrong? css followed html below: @media screen , (max-width: 750px) { aside { display: none; } article { width: 100%; } } #main { width: 58%; float: left; margin-left: 2%; } #sidebar { float: left; width: 34%; margin-left: 4%; } <article id="main"> <h2>the advanced on-site advantage</h2> <p>as service maintaining shades, shutters, blinds, , drapes through occasional cleaning , repair, can confident we're supremely qualified. </p> <p>correct identification of many fabrics , coatings used in draperies, shades , top treatments critical safe, yet effective, cleaning of these items. advanced on-site certified that. it's why we're able <a href="

python - Efficiently multiply a dense matrix by a sparse vector -

i looking efficient way multiply dense matrix sparse vector, av , of size (m x n) , v (n x 1). vector v scipy.sparse.csc_matrix. i have 2 methods use @ moment: in method 1, pick off non-zero values in v, vi, , element-wise multiply vi corresponding column of a, sum these columns. if y = av , y = a[:, 0]*v0 + ... + a[:, n]*vn , non-zero i. def dense_dot_sparse(dense_matrix, sparse_column): prod = np.zeros((dense_matrix.shape[0])) r, c = sparse_column.nonzero() indices = zip(r, c) ind in indices: prod = prod + dense_matrix[:, ind[1]] * sparse_column[ind] return prod in method 2, perform multiplication making sparse vector .todense() , use np.dot() . def dense_dot_sparse2(dense_matrix, sparse_column): return np.dot(dense_matrix, sparse_column.todense()) the typical size of (512 x 2048) , sparsity of v varies between 1 200 non-zero entries. choose method employ based on sparsity of v. if sparsity of v ~ 200 non-zeros, method 1 takes ~45m

javascript - CSS won't apply to HTML code in to-be-placed-variable with innerHTML -

i've got html code placed button .innerhtml css behaves weird. when try apply css id #herpderp won't nor affect selector descendants @ all. when @ site chrome developer tools elements nested. if #herpderp can't changed way why global selectors img , p change? , better way apply css since dont want use inline styling nor global selectors img, p , section? any critism welcome. html <div id="navigation"> <a onclick="changecontent(0)" href="#herpderp">test area</a> </div> <div id='background'> <div id=maincontent> <div id="content"> </div> </div> </div> javascript function changecontent(link) { switch (link) { case 0: document.getelementbyid("content").innerhtml = herpderp; break; } } var herpderp = '<section id=\"herpderp\">' + "<h1>blahblah</h1> &

WIndows Batch Script to remove multiple special characters from a text file -

i have text file has lot of special characters. test file, remove 3 special characters(~ Å“ <). can please provide me script address need? tried scripts doesn't seem working character ~. you can use sed execute this, download here - sed "s/[^a-za-z0-9]//g" file.txt if have latest, windows 7 or higher version, can in powershell get-content file.txt | foreach { $_ -replace '[^\w\d]' } | out-file -encoding utf8 file.new.txt or, download ruby windows c:\>ruby -ne 'print $_.gsub(/[~)Å“\[\]<]/,"")' file thanks!

java - Spring boot whitelabel 404 -

hello guys keep getting error though have followed spring tutorial website. have been trying figure out why i'm getting error. able connect facebook when trying retrieve feeds tutorial provided spring, keep getting whitelabel error. says: this application has no explicit mapping /error, seeing fallback. there unexpected error (type=not found, status=404). no message available everything seems okay dont know why keep getting error. if can assist appreciate it. my controller placed in src/main/java/home: @controller @requestmapping(value="/") public class homecontroller { private facebook facebook; @inject public homecontroller(facebook facebook) { this.facebook = facebook; } @requestmapping( method =requestmethod.get) public string getphotos(model model){ if(!facebook.isauthorized()) { return "redirect:/connect/facebook"; } model.addattribute(facebook.useroperations().getuserprofile()); pagedlist<post> hom

java - Grabbing tagged instagram photos in real time -

i'm trying download photos posted specific tag in real time. found real time api pretty useless i'm using long polling strategy. below pseudocode comments of sublte bugs in it newmediacount = getmediacount(); delta = newmediacount - mediacount; if (delta > 0) { // if mediacount changed now, realdelta > delta, realdelta - delta photos won't grabbed , on next poll if mediacount didn't change again realdelta - delta duplicated else ... // if photo posted private account last photo duplicated counter changes nothing added recent recentmedia = getrecentmedia(delta); // persist recentmedia mediacount = newmediacount; } second issue can addressed set of sort gueess. first bothers me. i've moved 2 calls instagram api close possible enough? edit as amir suggested i've rewritten code use of min/max_tag_id s. still skips photos. couldn't find better way test save images on disk time , compare result instagram.com/explore/tags/ .

c# - Using printf to print string value -

in c# can enumerate through array of strings, i'm have difficulty understanding why code below doesn't work in c++ int main( int argc, char ** argv ) { string hi[] = { "hi", "cool", "what" }; (string s : hi) { printf("%s \n", s); } return 0; } i'm sure answer simple. help? also, tried using instead, doesn't work either: printf(s); oddly enough, array on integers work using %d . , yes have #include <string> error info provided @chris (generated clang compiler): main.cpp:12:25: error: cannot pass non-trivial object of type 'string' (aka 'basic_string<char, char_traits<char>, allocator<char> >' ) variadic function; expected type format string 'char *' [-wnon-pod-varargs] printf("%s \n", s); ~~ ^ main.cpp:12:25: note: did mean call c_str() method? printf("%s \n", s); ^

model view controller - JSF get current values from bean -

hi helping. need current values bean jsf. jsf (example) <!-- inputtext username --> <h:outputtext style="font-size:12px;font-weight:bold;" value="username"></h:outputtext> <h:inputtext a:placeholder="enter user.." id="username" value="#{regbean.username}" required="true"></h:inputtext> <h:outputtext value="&lt;br/&gt;" escape="false" /> <!-- commandbutton send --> <p:commandbutton update=":dialogconf" style="font-size:10px;width:68px;height:32px;margin-left:70px;" type="submit" value="sign up" icon="ui-icon-arrowreturnthick-1-e" styleclass="botonesr" onerror="pf('errordlg').show();" oncomplete="pf('confirmation').show();pf('registration').hide();" action="#{regbean.doactionreg}" ajax=&q

node.js - node-hid building for mac os x 10.9.5 -

having problem building / usage node-hid on mac os x 10.9.5. build went fine node-gyp. had hidapi warnings: gyp info spawn args [ 'buildtype=release', '-c', 'build' ] cc(target) release/obj.target/hidapi/hidapi/mac/hid.o ../hidapi/mac/hid.c:255:20: warning: comparison of integers of different signs: 'cfindex' (aka 'long') , 'size_t' (aka 'unsigned long') [-wsign-compare] if (chars_copied == len) ~~~~~~~~~~~~ ^ ~~~ ../hidapi/mac/hid.c:295:20: warning: comparison of integers of different signs: 'cfindex' (aka 'long') , 'size_t' (aka 'unsigned long') [-wsign-compare] if (used_buf_len == len) ~~~~~~~~~~~~ ^ ~~~ 2 warnings generated. but test example gives dyld error: sh# node src/show-devices.js dyld: lazy symbol binding failed: symbol not found: _iohidmanagercreate referenced from: /users/me/documents/node-hid-master/build/

assembly - Nasm floating point reading and printing error -

this code wrote reading 2 floating point numbers , stored in memory. load memory , print it. however, i'm getting wrong value first number when printing it. i'm getting correct value second number. dont know going wrong in code. please help. section .data message1: db "enter first number: ", 0 message2: db "enter second number: ", 0 formatin: db "%lf", 0 formatout: db "%lf", 10, 0 ; newline, nul terminator section .bss f1: resd 1 f2: resd 1 section .text global main extern scanf extern printf main: push message1 call printf add esp, 4 push f1 push formatin call scanf add esp, 8 push message2 call printf add esp, 4 push f2 push formatin call scanf add esp, 8 fld qword[f1] sub esp, 4 fst qword[esp] push formatout call printf add esp, 8 fld qword[f2] sub esp, 4 fst qword[esp] push formatout call printf add esp, 8 mov eax,1 mov ebx,0 int 80h try use resq instead of resd f1: resq 1 f2: resq 1

performance - Multiple image sprites vs one -

i have 2 image sprites on website - 1 "general" sprite , navigation bar images. of images used in way or on front page (some shown when screen shrinks, using media queries). perhaps apart organisational concerns there reason not combine 2 single file , eliminate request along overhead? thanks.

function - Python: Scrapy start_urls list able to handle .format()? -

i want parse list of stocks trying format end of start_urls list can add symbol instead of entire url. spider class start_urls inside stock_list method: class myspider(basespider): symbols = ["scmp"] name = "dozen" allowed_domains = ["yahoo.com"] def stock_list(stock): start_urls = [] symb in symbols: start_urls.append("http://finance.yahoo.com/q/is?s={}&annual".format(symb)) return start_urls def parse(self, response): hxs = htmlxpathselector(response) revenue = hxs.select('//td[@align="right"]') items = [] rev in revenue: item = dozenitem() item["revenue"] = rev.xpath("./strong/text()").extract() items.append(item) return items[0:3] it runs correctly if rid of stock_list , simple start_urls normal, not export more empty file. also, should possibly try sys.arv setup type stock symbol argument @ command l

python - IMDbPY get_top250_movies() returns empty list -

when try top 250 movies imdbpy returns empty list: >>> imdb import imdb >>> imdb_instance=imdb() >>> top250=imdb_instance.get_top250_movies() >>> top250 [] any idea? above code should return list of top 250 movies rated imdb found here . problem code returns empty array, , not list of 250 movies. i found problem. i did: >>>import imdb >>>dir(imdb) . dir() useful python function returns classes , functions under object. from there, found reason, way written, class imdbbase contains get_top250_movies() , not imdb . change from imdb import imdb from imdb import imdbbase , instance that. edit: point, @user3577702 pointed out abstract base class (oops). the mysterious empty list seems have been problem while. found question on google groups. according answer, the version in svn repository should work. however, no longer case. current commit doesn't work. i have started new question , maintaine

arrays - Remove a Timer from List<Timer> in runtime C# -

i'm trying remove timer component list - foreach (timer timer in timers) { if (timer.tag.tostring()=="mytag") { timer.enabled = false; timer.tick -= ontimertick; timers.remove(timer); } } but gives error- collection modified; enumeration operation may not execute. any help? for unknown size should use list instead of array. try list<timer> timers = new list<timer>(); [edit] changed whole question new 1 after answer. can't remove item inside foreach loop. use duplicate list or iterate backwards: for (int = timers.count - 1; >= 0; i--) { if (timers[i].tag.tostring()=="mytag") { timers[i].enabled = false; timers[i].tick -= ontimertick; timers.removeat(i); } }

algorithm - pseudo-code for visiting a state machine -

i want write pseudo-code visiting state machine using dfs. state machine can considered directed graph. following algorithm cormen book uses dfs algorithm visit graph. dfs-visit(g, u) //g= graph, u=root vertex u.color = gray each v g.adjacents(u) //edge (u, v) if v.color == white dfs-visit(g, v) state machine can have multiple edges between 2 vertices. , above algorithm stores edges in adjacency list. have implemented algorithm in java following classes, class node{ string name; .... arraylist<transition> transitions; void addtransition(transition tr); } class transition { string src; string dest; } with above given information, have built state machine node , transition objects. want modify above algorithm don't have graph object g. have access root object. can modify above algorithm below? dfs-visit(root) //root node root.color = gray each t root.gettransitions() //t=tr

ruby on rails - Join the associated object into the belongs_to object -

i have event model has many dateentry because event can have multiple datetimes . i have view see events date entries specific day. i've made class method in models/event.rb : def self.by_date(date) includes(:date_entries) .where(date_entries: { begins_at: date.beginning_of_day..date.end_of_day }) end and works fine. now on view loop on events grabbed query: @events.each |event| # whatever i looking way use date selected dateentry in loop. think have use activerecords joins method, have tried in many ways , when not getting error output still same. for clarifying, want in loop event.selected_date_entry_by_the_by_date_method.begins_at or that. first, in example date events same. set @date in controller , use in views. second, seems should doing things other way around. instead of finding events should finding dateentries , iterating on those.

android - Why phonegap application always shows own default page after override index.html -

Image
hi have made hello world type of application in phonegap. have index.html in www directory displaying default home page of phonegap. please see attached screenshot displaying always. index.html <html> <head> <meta charset="utf-8" /> <meta name="format-detection" content="telephone=no" /> <meta name="msapplication-tap-highlight" content="no" /> <!-- warning: ios 7, remove width=device-width , height=device-height attributes. see https://issues.apache.org/jira/browse/cb-4323 --> <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" /> <link rel="stylesheet" type="text/css" href="css/index.css" /> <title>hello world</title> </head> &l

android - (Solved) java.lang.NullPointerException: Attempt to invoke virtual method ... on a null object reference -

i have class called resultactivity display list of place'info. activity request server , receive json object. activity doesn't work , found error java.lang.runtimeexception: unable start activity componentinfo{com.example.shameal/com.example.shameal.resultactivity}: java.lang.nullpointerexception: attempt invoke virtual method 'com.android.volley.toolbox.imageloader com.example.shameal.controller.appcontroller.getimageloader()' on null object reference resultactivity public class resultactivity extends listactivity{ private listview listview; private feedlistadapter listadapter; private list<feeditem> feeditems; @override protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); ... listview = (listview) findviewbyid(r.id.list); feeditems = new arraylist<feeditem>(); listadapter = new feedlistadapter(this, feeditems); listview.setadapter(listadapter);