Posts

Showing posts from July, 2011

ios - NSSortDescriptor NSDate ascending. How to sort objects with the same date? -

i using nsfetchedresultscontroller display objects event in list. event -object has property of startdate , eventtype property enum of types checkin , concert , meeting , flight , checkout . nsfetchedresultscontroller has sortdescriptor orders events startdate : eventsrequest.sortdescriptors = [nssortdescriptor(key: "startdate", ascending: true)] this works fine, however, in cases startdate checkin event , meeting event same. confuses sortdescriptor , places meeting before checkin . is possible make custom nssortdescriptor checks if startdate same, checks eventtype property , returns checkin before meeting ? sortdescriptors array, add additional nssortdescriptor second property wish, that: eventsrequest.sortdescriptors = [nssortdescriptor(key: "startdate", ascending: true), nssortdescriptor(key: "eventtype", ascending: true)] this firstly use nssortdescriptor startdate , if same check value of eventtype

magento - framework for portal develeopment -

i evaluating frameworks use base custom portal development. looking framework covers basic functions, such login, account management etc. different user groups. upon base develop custom functionality special prupose online marketplace. far thought of 2 directions. either going shop system such magento , start tweaking there (however seems quite inflexible) or using cms such drupal base , develop furhter functionality addon. crossed mind use erp system such odoo base since businss processees covered, but, there again, might pretty hard work build marketplace around odoo. i'd curious if missing important directions or if there other frameworks out there, can used portal base. got experience building portals based on "standard" framework? thanks peter in odoo there several number portal module available in odoo 8.0 which related sale,sale stock,crm project,gamification etc.. the following modules helpful use portal implementation odoo 8.0 1.portal 2...

c - Why is this code able to access a null pointer without causing a crash? -

i have come across following piece of code, finds offset of member within structure. not able make out why not crash, though tries derefer null pointer struct a_ { int a; int b; }; int main() { int offset = &(((struct a_ *) 0x0)->b); printf ("offset of b = %x\n", offset); } output = 4 however not able make out why not crash, though tries derefer null pointer. you forming invalid address undefined behavior there no dereference of null pointer because of & operator cancels dereference.

css - Styling pseudo-elements when a link has wrapped? -

i've created 'underline' animation uses ::after pseudo-element underneath link. here code link , pseudo-element: link a { position: relative; } ::after a:after { content: ''; display: inline; position: absolute; height: 2px; width: 0%; background-color: #ce3f4f; left: 0%; bottom: 0px; transition: 0.2s ease; } a:hover::after { width: 100%; } this works fine when link on single line, if link flows onto next line fills across bottom of first line, seen here: http://i.stack.imgur.com/7sx7o.jpg if inspect element appears issue not solvable, browser (in case, firefox) isn't selecting entirety of wrapped element: http://i.stack.imgur.com/342gh.jpg is there way of solving purely css, or problem way browser renders objects? have played around lot of white-space , display , position configurations no avail. here's example of behaviour: https://jsfiddle.net/57lmkyf4/ this cannot done css....

java - What is the purpose of passing parameter to synchronized block? -

i know that when synchronize block of code, specify object's lock want use lock, could, example, use third-party object lock piece of code. gives ability have more 1 lock code synchronization within single object. however, don't understand need of passing argument block. because doesn't matter whether pass string's instance, random class's instance synchronized block synchronized block works irrespective of parameter being passed block. so question if anyways synchronized block stops 2 threads entering critical section simultaneously. why there need of passing argument. (i mean acquire lock on random object default). i hope framed question correctly. i have tried following example random parameters being synchronized block. public class launcher { public static void main(string[] args) { accountoperations accops=new accountoperations(); thread lucy=new thread(accops,"lucy"); thread sam=new thread(ac...

excel - VBA querytables loop placing retrieved data in not correct cells -

i'm creating little macro retrieve data website has table in rows of 30. the problem when loop, every iteration of loop places data column @ right instead of below. mean, query retrieves data columns q until row 30. when next iteration want gets columns q row 31 61. thing places columns r to... xx until row 30. guess issue might on destination:=range... sub extract_data_table() ' ' extract_data_table macro ' = 1 41 x = 1 41 z = (x * 30) - 29 worksheets("nhl_results_rs").select worksheets("nhl_results_rs").activate mystr = "url;http://www.nhl.com/stats/game?fetchkey=20062allsatall&viewname=summary&sort=gamedate&gp=1&pg=" & x activesheet.querytables.add(connection:= _ **mystr, destination:=range("$a$1"))** '.commandtype = 0 .name = _ "game?fetchkey=20062allsatall&viewname=summary&sort=gamedate&gp=1&pg=1_2" .fieldnames = true .rownumbers = false ...

Google map Api google.maps.LatLng(). Can i change the "google.maps.LatLng() method" to location or address -

hi guys using following code load map of location var map; function initialize() { var mapoptions = { zoom: 8, center: new google.maps.latlng(-34.397, 150.644) }; map = new google.maps.map(document.getelementbyid('map-canvas'), mapoptions); } i want use location string draw map this google.maps.location(-34.397, 150.644) if possible. i guess want use latitude , longitude name of location, have use reverse geocoding service google map api . function need : function codelatlng() { var input = document.getelementbyid('latlng').value; var latlngstr = input.split(',', 2); var lat = parsefloat(latlngstr[0]); var lng = parsefloat(latlngstr[1]); var latlng = new google.maps.latlng(lat, lng); geocoder.geocode({'latlng': latlng}, function(results, status) { if (status == google.maps.geocoderstatus.ok) { if (results[1]) { map.setcenter(latlng); map.setzoom(11); if(marker){ marker...

objective c - Deserialization of JSON-Value -

Image
i have problems deserialization of json-value. here code: nsdictionary *responsedict = [nsjsonserialization jsonobjectwithdata: data options:0 error: &errorjson]; nsstring *innerjson = responsedict[@"d"]; nsmutabledictionary *innerobject = [innerjson jsonvalue]; as can see in fallowing printscreen (which taken right after executing last line of code above), items in dictionary innerobject contains special characters, not there in innerjson. can me, why occurs? edit - added descriptions of variables console innerjson: {"ret" : "1", "msg" : "", "list" : ["granatapfel¤200g¤1", "brombeeren¤300g¤1", "papaya (100 g)¤3¤0", "epf müesli 1 messlöffel¤2¤1", "grüner spargel (190 g)¤2¤1", "chicorée (130 g)¤1¤0", "mageres kalbfleisch (190 g)¤3¤0", "zander (160 g)¤6¤0", "bachsaibling (190 g)¤2¤0", "seeteufel (160 g)¤1¤0...

asp.net mvc - Deleting row in table with Jquery in mvc project -

i generate following html code <table> @for (int = 0; < model.listusers.count; i++) { <tr> <td> @html.displayfor(m => m.listusers[i].name)</td> <td> @html.displayfor(m => m.listusers[i].phone) </td> <td> <button type="button" id="delete" data-id="@model.listusers[i].id">delete</button> </td> </tr> } </table> i want delete row, <script> $(document).ready(function () { $("#delete").on("click", function () { var tr = $(this).closest('tr'); tr.remove(); }); }); </script> executing this, row deleted works first time, i.e., once. how can delete row? ids in html must unique , use class instead can use class selector (".class...

smartcard - Secure Box in JCOP card -

jcop v2.4.2 revision 3 security target: page 11-12 a secure box concept implemented within jcop 2.4.2 r3. secure box construct allows run non certified third party native code , ensures code cannot harm, influence or manipulate jcop 2.4.2 r3 operating system or of applets executed operating system.the separation of native code in secure box other code and/or data residing on hardware ensured hardware mmu has been certified in hardware evaluation i have of described card , want have experience in working secure box also! searching in java card v3.0.1 specifications , global platform v2.2.1 card specification , jcop v2.4.2 r3 administrator manual didn't helped. there nothing in mentioned documents secure box. so : does have idea/experience how can use secure box in jcop cards? kind of program/code can upload in secure box? programs written in java card language , in form of cap files also? or written in c++ or assembly example? how upload , ins...

android - Can't receive Intent.extras() from Camera after making a photo -

i found it's common problem capturing photo , receiving full size photo instead of thumbnail (according to: http://developer.android.com/training/camera/photobasics.html ). taking photo , receiving thumbnail easy, rest of tutorial seems uncomplete , not working. resolved in easy way? public class takephoto extends activity{ static final int request_image_capture = 1; static final int request_take_photo = 1; private string mcurrentphotopath; private imageview mimageview; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.take_photo); mimageview = (imageview) findviewbyid(r.id.imageview); dispatchtakepictureintent(); } @override protected void onactivityresult(int requestcode, int resultcode, intent data) { if (requestcode == request_take_photo && resultcode == result_ok) { bundle extras = data.getextras(); bitmap imagebitmap = (bitmap) extras.get("dat...

java - Log4j2 on Tomcat on Windows produces warning "unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream" -

i have web app deployed on tomcat 8. dev env eclipse (luna) on windows 7 x64. finished integrating log4j2 in code. when start tomcat, see following warning: warn unable instantiate org.fusesource.jansi.windowsansioutputstream i did extensive googling not see question related problem. did see class supposed add coloring log file. not interested in feature. the log4j config follows <?xml version="1.0" encoding="utf-8"?> <configuration status="info"> <appenders> <console name="console" target="system_out"> <patternlayout pattern="%d{hh:mm:ss.sss} [%t] %-5level %logger{36} - %msg%n"/> </console> </appenders> <loggers> <root level="trace"> <appenderref ref="console"/> </root> </loggers> </configuration> ok, after diggind log4j2 code, found hidden runtime parameter needs specifie...

jquery - How to sort values from json array follow ul,li -

i have json string. how sort attribute values json follow ul,li html? [{"id":1}, {"id":2,"children":[{"id":3}, {"id":4}, {"id":5,"children":[{"id":6}, {"id":7}, {"id":8} ] }, {"id":9}, {"id":10,"children":[{"id":11,"children":[{"id":12}]}]}]} ] try below <!doctype html> <html> <title>stack jquery</title> <link rel="stylesheet" href="../repo/css/bootstrap.css" type="text/css" /> <script src="https://code.jquery.com/jquery-2.1.3.js"></script> <script src="../repo/js/bootstrap.js"></script> <script src="../repo/js/jquery.validate.js"></script...

What is the best way to work with static variables in java/c++/c/actionscript-3 applications? -

i'm working on application using static variables (eg: pixel width of tile, or how many tiles want in array). i have them declared in class defines object, example tilewidth in tileclass. using width in multiple other classes, , bugged fact have import whole tile class access field. there performance loss this? is better practice hold static variables (they constants) in separate class , import whenever need variable? is there other better way using static variables? thanks is better practice hold static variables (they constants) in separate class , import whenever need variable? just put constants in interface , reference them using interface. there no performance impact such put design rather creating class constants , making them public static (as variables defines in interface implicitly public default , static ).

c# - Displaying search results -

i've been looking around hours today on how display list of strings i've created action result called "results". wondering if knew how display on .aspx page? public class testimonials { public string addtestimonials { get; set; } public string searchtestimonials { get; set; } public list<string> results = new list<string>(); public void getsearchresults(string keyword) { string query = "select content testimonial content '%@p1%';"; //insert statement sqlconnection db = new sqlconnection(@""); sqlcommand command = new sqlcommand(query, db); command.parameters.addwithvalue("@p1", keyword); // seting @p1 content db.open(); sqldatareader reader = command.executereader(); datatable results = new datatable(); results.load(reader); //loads remaining surgeon credentials data table. foreach (datarow row in results.rows) ...

javascript - Isolate scopes angularjs, ditching dependency injection, reusable components -

i haven't been fiddling angularjs's directive while , not still have grasp on it. before dive it, thinking react, on how components. so have search on how create reusable components using directives, , found article: http://michalostruszka.pl/blog/2015/01/18/angular-directives-di/ but implementation on final solution quite blurry, cannot figure out on how use correctly. let's create title directive: <epw-title store="epweventstore">{{vm.title}}</epw-title> and directive uses same service epweventstore can update state <epw-event-list store="epweventstore"></epw-event-list> where epw-event-list renders list , when clicked should change value of vm.title of epw-title . how possible? update q: nested? a: no, siblings. don't put services inside views just avoid misunderstanding, if epweventstore angularjs service (such provider , factory , service ), not meant put attribute value inside ...

Use volume keys when phone is locked in android devices -

before everything, search in site , google still have problem , need please. i want know how can use volume keys while phone locked? i'm using code , while phone not locked it's work not when it's locked. public boolean onkeydown(int keycode, keyevent event) { if ((keycode == keyevent.keycode_volume_up)) { // // return true because want handle key return true; } if ((keycode == keyevent.keycode_volume_down)) { // // return true because want handle key return true; } i know have use broadcastreceiver matter. but, want know how? if guys give me live example or kind of tutorial can use. i added manifest file <receiver android:name=".countreciever" android:process=":remote" > <intent-filter> <action android:name="addedcounting" /> </intent-filter> </receiver> and created activity impor...

css - How to apply SVG clipPath to HTML element that is not in the top left corner of document in webkit browsers -

i have defined svg clippath , applying few divs on page. works/displays expected in ff, in chrome , safari (all latest versions), seems clippath affect html element if html element positioned in top-left corner of page. svg object <svg height="0" width="0"> <defs> <clippath id="clip"> <path fill="#000000" d="m0,0.01c3.472,1.088,6.688,3.663,7.878,9.208c1.604,7.482,4.305,11.862,7.102,11.79v0.003 c0.007,0.001,0.014-0.001,0.02-0.001c0.007,0,0.014,0.002,0.021,0.001v-0.003c2.797,0.072,5.499-4.308,7.103-11.79 c23.312,3.672,26.527,1.098,30,0.01h0z"/> </clippath> </defs> </svg> css element clipped .clipme { background: red; width: 30px; height: 21px; clip-path: url(#clip); -webkit-clip-path: url(#clip); } jsfiddle i believe this article begins address use of coordinate systems, got lost/confused several times. sounds...

c++ - Recursively find the largest number in an integer array -

i required find largest number in integer array recursively. function crashed cannot find bug. here's c++ code: void numbers::compare(int size) { if(size == 0) cout << "you must enter number!" << endl; if(size ==1) cout << "the max number " << numarray[0] << endl; if(size >1) { if(numarray[size-1] > numarray[size-2]) { int temp = 0; numarray[size-1] = temp; temp = numarray[size-2]; numarray[size-2]= numarray[size-1]; size --; } size = size -1 ; compare(size); } } here problem: int temp = 0; numarray[size-1] = temp; // set numarray[size-1]=0 temp = numarray[size-2]; numarray[size-2]= numarray[size-1];// set numarray[size-2]= 0 size --; you set entire array 0. what meant do: int temp = numarray[size-2]; numarray[size-2] = numarray[size-1]; numarray[size-1]= temp size --; note change array in proce...

cypher - Create on NOT MATCH command for Neo4j's CQL? -

i have non-unique node (:neighborhood) uniquely appears [:in] (:city) node. create new neighborhood node , establish relationship if neighborhood node not exist in city. there can multiple neighborhoods have same name, each neighborhood must appear uniquely appear in property city. following advice gil's answer here: return node if relationship not present , how can like: match not (a:neighborhood {name : line.neighborhood})-[r:in]->(c:city {name : line.city}) on match set (a)-[r]-(c) so create new neighborhood node if doesn't exist in city. **update:**i upgraded , profiled , still can't take advantage of optimizations... profile load csv headers "file://thefile" line line limit 0 match (c:city { name : line.city}) merge (n:neighborhood {name : toint(line.neighborhood)})-[:in]->(c) ; +--------------+------+--------+---------------------------+------------------------------+ | operator | rows | dbhits | identifiers | ...

javascript - AngularJS ng-repeat rows/ul -

i have json array various objects , want show these objects in html using ng-repeat, follows: <ul> <li>object 1</li> <li>object 2</li> <li>object 3</li> <li>object 4</li> </ul> <ul> <li>object 5</li> <li>object 6</li> <li>object 7</li> <li>object 8</li> </ul> basically want show 4 items per row (ul) how can that? thanks! you can use filter limitto ng-repeat="item in items | limitto:4" update:this should work <ul ng-repeat="item in arr" ng-if="$index%4==0"> <li ng-repeat="item in arr|limitto:4:$index" > {{item}} </li> </ul> plnkr

node.js - Cannot open site with https server using Express -

var fs = require('fs'), https = require('https'), express = require('express'), app = express(); https.createserver({ key: fs.readfilesync('./ssl/key.pem'), cert: fs.readfilesync('./ssl/cert.pem') }, app).listen(55555); app.get('/', function (req, res) { res.header('content-type', 'text/html'); return res.end('<h1>hello, secure world!</h1>'); }); i tried many times using https server based on express, while still cannot open site, example using chrome: it says "no data received" , "err_empty_response". so listening, response cannot sent client, why? thank you!

c# - Implementing negative number validation for a windows form -

this question has answer here: how implement validation negative values 1 answer i have little code snippet i've been working on. provides validation numbers more 2 decimal places. private void calculatebutton_click(object sender, eventargs e) { int amount; if (int.tryparse(amounttextbox.text, out amount)) { wantedtextbox.text = currency_exchange.exchangecurrency((currencies)currencycombobox.selectedindex, (currencies)wantedcurrencycombobox.selectedindex, amount).tostring("0.00"); wantedcurrencylable.text = ((currencies)wantedcurrencycombobox.selectedindex).tostring(); groupbox.visible = true; } else { messagebox.show("invalid amount"); } now i've realized late should've implemented validation negative numbers as...

r - getting non linear multivariate regression parameter estimates -

i'm looking @ getting parameter estimates data has 3 dimensions. i've plotted out using manipulate function in mathematica. however, when use constants mathematica think fit, end single gradient error. so, there graphical method can use in r plot estimates against 3d plot of data, or have suggestions how rectify error? distance<-c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,15 ,15 ,15 ,15 ,15 ,15 ,15 ,15 ,15 ,15 ,15 ,15, 15 ,15, 15 ,15 ,15 ,15,15 ,15 ,20, 20 ,20, 20 ,20, 20 ,20, 20 ,20 ,20 ,20 ,20 ,20 ,20, 20 ,20, 20 ,20, 20 ,20, 20) height<-c(400 ,300 , 200, 0 ,-200 , -400 ,-600 , -800 ,-1000 ,-1000 ,-1200, -1220 ,-1300 ,-1400,-1400 ,-1500, -1600, -1700 ,-1700 ,-1800 ,-1900 , 400 , 200 , 0 ,-200, -400 ,-600 , -800,-1000 ,-1200, -1200 ,-1400 ,-1600 ,-1600 ,-1800 ,-2000 ,-2000 ,-2200 ,-2200 ,-2400 ,-2600 ,-2800,-3000 , 400 , 200...

ios - How to switch views in the handler of an NSURLSession Request -

i have login view controller, , other view controller. i'd is: when user hits login, sends credentials remote server. remote server returns response indicating whether credentials or not, , if good, app redirects other view controller. the code below crashes @ call .performseguewithidentifier. the crash gives error code of exc_bad_access(code=1, address=0xbbadbeef) question: swifty way of doing this? var request = nsmutableurlrequest(url: nsurl(string: "http://url.to/my/login/handler")!) var session = nsurlsession.sharedsession() request.httpmethod = "post" //user initialized earlier bodydata = "email=\(user.username)&password=\(user.password)" request.httpbody = bodydata.datausingencoding(nsutf8stringencoding); var task = session.datataskwithrequest(request, completionhandler: {data, response, error -> void in // check log in successful looking in 'response' arg // if login successful self.performseguewithiden...

c# - Why SendKeys.SendWait() crashes my application -

in console application, sendkeys.sendwait("^c") called copy selected text clipboard. it works fine, if console application has focus when called, then, instead of throwing exception, closes application. , after things start acting up, mouse wheel affecting zoom instead of scrolling , down. why dose happen. ctrl+c is signal console window close. and reason mouse wheel affecting zoom after closes because application never got chance release ctrl key. this can fixed changing consolemode or changeing console.treatcontrolcasinput property. thanks help

Rails 4.2 doesn't update datetime fields -

i think found bug not 100% sure if 1 or doing wrong. setting timezone this: inside application.rb ... config.i18n.default_locale = :en config.time_zone = 'melbourne' config.active_record.default_timezone = 'melbourne' ... when updating model timestamp columns ( created_at , updated_at ) doesn't update them. problem caused line config.active_record.default_timezone = 'melbourne' (when remove it, works fine). query seems fine when reload model timestamps nil. think problem appears in datetime columns , doesn't matter database using (i managed reproduce in postgres , in sqlite). is expect because forgot configure or bug? config.active_record.default_timezone accepts 2 values: :local :utc what can set: config.time_zone = 'melbourne' and config.active_record.default_timezone = :local will trick.

Emacs mode/method for logic symbol placement in text? -

i put actual logic symbols emacs buffers, e.g., logic symbol "∀" or "∃" or "⇒", directly (fundamental) text or .org or whatever buffer. found xmsi-math-symbols-input.el @ ergoemacs , i'm wondering if "best practice." maybe best practice right tex/latex copy, if i'm doing org-mode? you can use corresponding unicode characters in emacs. bind want keys want. example: (global-set-key [f2] "∀") (global-set-key [f3] "∃") (global-set-key [f4] "⇒") to string char, can use c-x 8 ret , type name or code point of unicode char. in other words, c-x 8 ret lets insert unicode character. for example, unicode code point ∀ 2200. c-x 8 ret 2200 ret inserts ∀ character. and unicode name of ∀ for all . c-x 8 ret ret inserts ∀ character. the reason might want bind particular character key convenience - c-x 8 ret general, , slow.

java - Maven/junit project organization -

i have 3 packages: foo provides api foomysql (depends on foo) implements foo api using mysql foopostgresql (depends on foo) implements foo api using postgresql i have bunch of junit tests, should run twice: once again foomysql, , once again foopostgresql. same tests, because api should behave identically both implementations, setup , teardown different. question: should define tests? logical place appears in foo. however, in foo, not executable because foo doesn't know of implementation. can put them foomysql, appears have have full copy on foopostgresql, "test" code defined in foo cannot referred via maven dependency mechanism foomysql etc. (is correct, or perhaps i'm missing trick?) alternatively create separate footests project, foomysql , foopostgresql tests depend on. somehow sounds wrong, too. there better idea? the first thing should know should unit-test implementations. always. think you're leaning wasn't sure since mentioned ...

trie - Bus error 10 in Radix Tree C program -

i'm writing program operations on radix trie , i'm stuck @ add() function, getting bus error 10. void addrec(struct tnode *p, char *w) { int matches = prefixmatch(p->word,w); bool insert = true; if ((p == root) || ((matches > 0) && (matches < strlen(w)) && (matches == strlen(p->word)))) { char *updatedword = &w[matches]; printf("%s\n", updatedword); struct tnode *tmp = p->child; while (tmp != null) { if (tmp->word[0] == updatedword[0]) { insert = false; addrec(tmp, updatedword); } tmp = tmp->brother; } if (insert) { addchild(p,updatedword); } } else if ((matches > 0) && (matches == strlen(w)) && (matches == strlen(p->word))) { if (p->count < 0) p->count = ++globalcount; else printf("ignored"); } else if ((matches > 0) && (matches < strlen(w)) && (matches ...

python - How to append function to a list then print it -

i creating basic recipe viewer in python, stumbled across problem of when try print saved recipe displays [none] , seen recipe firstly function, appended onto list try print when loading it. the code below can explain more. how stop [none, none] appearing? code below sample made adapt resolving issue in recipe rather posting entire code on here. b = [] #this meant resemble list def function(): # meant resemble recipe print("hi") function() = input('write 1 = ') # meant resemble user saving recipe if == '1': b.append(function()) # meant resemble me saving recipe onto list print(b) # meant resemble me loading recipe when run code , sorry don't have enough reputation points post image comes in python shell hi write '1' = 1 #user input hi [none] you not returning function. printing , that's not same thing. use return return value: def function(): return "hi" print() writes terminal, call...

javascript - Removing a color in image - CSS, HTML, JS? -

i'm wondering how remove color in image on webpage. want kind of result explained here... an image 3 segments: blue, purple, , red. want filter out blue ends segments: black, red, , red. blue purple red -> black red red i know done in css or javascript in way not know how it. i've been messing css filter s , putting div on top of color, nothing rid of blue. does know how / possible? you try using css filters however, don't think there filter specific colour , browser compatibility limited. https://developer.mozilla.org/en/docs/web/css/filter alternatively use svg image allows modify parts of image using css think svg files can pretty big large images... think can use adobe illustrator save files svg. http://www.w3schools.com/svg/tryit.asp?filename=trysvg_myfirst

javascript - External JS sometimes doesnt loads in time? -

<!doctype html> <html> <head> <script type="text/javascript" src="a.js"></script> </head> <body> <script> functionfromajs(); </script> </body> </html> this works ok of time, on production server, not 100%. says functionfromajs() doesnt exists, ok, if .js not gets loaded in time. do? edit: using window.onload function should not difference long script you're embedding loaded before function call. a.js file loaded before <script>functionfromajs();</script> anyway , should able execute function if exists. try using: <script> window.onload = function() { functionfromajs(); }; </script> so function not called before document loaded. or if you're using jquery can use: <script> $(document).ready(function() { functionfromajs(); }); </script>

android - Return/Pass ImageView file -

i generate imageview in androidlauncher , need use in 1 of screen classes, created interface. how can pass image , use in screen class? need make bitmap first? what got right is: uri selectedimage = data.getdata(); selectedimagepath = getpath(selectedimage); imageview.setimageuri(selectedimage); and interface: public interface purchinterface{ public void getselectedimage(); } and in androidlauncher: @override public void getselectedimage() { imageview.getdrawable(); } im in deep water here. note need able draw image in screen class. you need return image encoded in format getselectedimage method. otherwise implementation retrieving drawable , dropping immediately. you should refer converting android bitmap libgdx's texture so interface be public interface purchinterface { public byte[] getselectedimage(); } and implementation be @override public byte[] getselectedimage() { // convert image bitmap, encode in...

symlink - Header image on paypal payment page returning 404 intermittently -

i have added header image customize paypal payment page site eatingatkins.ie/products. when go payment page (by clicking link in cart) header image there , it's not - i'm seeing broken in safari in windows often. can see 404 error in console. if inspect url being used in web developer tools correct. url image https://eatingatkins.ie/wp-content/uploads/site_images/ea_head.gif opening works. i set ssl site , hosting company set symlink https://eatingatkins.ie/anything show resource in http directory. cause issue header image? need in https folder directly , not through using symlink. i asked hosting company remove symlink , put image file in directory in https folder , loads image on payment page every time.

rust - Give caller ownership of local variables that depend on each other -

here's minimal reproduction of problem: fn str_to_u8(s: &str) -> &[u8] { let vector = s.chars().map(|c| c u8).collect::<vec<u8>>(); let slice = vector.as_slice(); slice } the compiler says vector doesn't live long enough, makes sense. there way force vector "move" slice when caller takes ownership of slice takes ownership of vector ? (copied my answer related still different question .) you're trying return borrow created in , owned function. impossible . no, there no way around it; can't somehow extend lifetime of vector , returning vector borrow won't work. really. 1 of things rust designed absolutely forbid. if want transfer out of function, 1 of 2 things must true: it being stored somewhere outside function outlive current call (as in, given borrow argument; returning doesn't count). to expand on this, change function fn str_to_u8<'a, 'b>(s: &'a str, vector: ...

Android Wear: Cannot Resolve Image Reference -

probably stupid question here started programming in android bear me. https://gist.github.com/gabrielemariotti/ca2d0a9f79b902b19a65 i'm following project implement gridviewpager on android wear application. works fine, background images i'm trying use not displaying. displays black screen. the issue getbackground() method, imagereference in particular. public imagereference getbackground(int row, int col) { simplepage page = ((simplerow)mpages.get(row)).getpages(col); return imagereference.fordrawable(page.mbackgroundid); } the tutorial shows image reference should returned getting build errors saying imagereference cannot resolved. have create class or interface imagereference? or set attribute on images themselves? can shed light on this? cheers in advance. as of version 1.1 of wearable support library (which fragmentgridpageradapter part of), methods have changed quite bit: no longer use sort of imagereference class -...

c++ - fast way to get integers 0, 1, and 2 when given a random one from the set -

so basically int num = rand(2); //random number 0-2 int othernum, otherothernum; othernum = implement otherothernum = implement for example, if num 2, othernum , otherothernum must set 0 , 1 (or 1 , 0). how implement this? assume can't use branching or tables. yes i'd bit manipulation solution. yes i'd solution faster solution uses modulus operator (as essentialy division). i think lookup might fastest not sure, dont solution though. you can xor , bit masking. #include <stdio.h> void f(unsigned val, unsigned ary[3]) { ary[0] = val; ary[1] = (ary[0] ^ 1) & 1; ary[2] = (ary[0] ^ 2) & 2; } int main() { unsigned ary[3] = {0}; f(0, ary); printf("f(0) = %d %d %d\n", ary[0], ary[1], ary[2]); f(1, ary); printf("f(1) = %d %d %d\n", ary[0], ary[1], ary[2]); f(2, ary); printf("f(2) = %d %d %d\n", ary[0], ary[1], ary[2]); return 0; } this print: f(0) = 0 1 2 f(1) = 1...

Modern Fortran: Output format without label -

i looking way specify output format without using label. to understand mean, label: write(*,1001) icount, x, y 1001 format (i5,f5.2,e12.3) without label should put format (i5,f5.2,e12.3) somewhere in write statement, write(*,format(i5,f5.2,e12.3)) icount, x, y i think saw somewhere unfortunately cannot find again. if exists feature of newer fortran version. maybe fortran 90? maybe fortran 2008? try write(*,'(i5,f5.2,e12.3)') icount, x, y

javascript - Extending <object> in Dart -

the dart <object> element not support getter access <object>.contentdocument , thought extending object add functionality. i took @ implementation of objectelement , need add these lines: @domname('htmlobjectelement.contentdocument') @docseditable() document contentdocument => _blink.blinkhtmlobjectelement.instance.contentdocument_getter_(this); however, have no idea how this. solution using @ time proxy redirects calls underlying jsobject honest, not dirty, impossible maintain. /* updated explain root of evil */ when starting project working on, wanted display svgs, uploaded user, on website , let user manipulate these svgs inserting additional svgelements or removing others. when downloading svgs string , displaying them by container.append(new svgelement(svgcode)) i got strange display bugs such embeded images in svgs displaced or removed , other bugs masks. the problem solved using <object> tag , set setting data attribute ...

jquery - how to change margin when the image width changes? -

i have fixed header , when resize browser window logo on header resizes , want change margin of logo when image resized how do that? this jquery use resize image $(window).on('load resize', function() { var maxsize = 2560; var screenwidth = $(this).width(); var factor = 0.27*screenwidth-(maxsize-screenwidth)*0.05; if (factor > 2560) factor = 2560; $('#logo').css('width', factor) }); }); css: #logo{ margin-top:5px; margin-left:10px; float:left; cursor: pointer; display:block; min-width:220px; height: auto; width: auto\9; /* ie8 */ }

java - Custom ActionBar NullPointerException -

sorry english. have tabactivity , want create custom action bar, have error: 04-25 20:11:17.777: e/androidruntime(8083): java.lang.runtimeexception: unable start activity componentinfo{com.example.bonsitelazyl/com.example.bonsitelazyl.mainactivity}: java.lang.runtimeexception: unable start activity componentinfo{com.example.bonsitelazyl/com.example.bonsitelazyl.news}: java.lang.nullpointerexception mainactivity: public class mainactivity extends tabactivity { tabhost tabhost; progressdialog pdialog; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); tabhost = gettabhost(); settabs(); } private void settabs() { addtab("", r.drawable.tab_news, news.class); addtab("", r.drawable.tab_servises, news.class); addtab("", r.drawable.tab_profile, news.class); ...

c# - Comparing two byte arrays guarding against timing attacks -

i want write method compare 2 byte arrays, not want use these solutions because want method resistant timing attacks. method looks like: static bool areequal(byte[] a1, byte[] a2) { bool result = true; (int = 0; < a1.length; ++i) { if (a1[i] != a2[i]) result = false; } return result; } (with assumption a1 , a2 have same length). my concern sufficiently smart just-in-time compiler might optimize returning if result ever set false. i have checked jitted assembly code produced .net 4.0.30319, , not: ; `bool result = true;' 00e000d1 bb01000000 mov ebx,1 ; `int = 0;' 00e000d6 33f6 xor esi,esi ; store `a1.length' in eax , @ dword ptr [ebp-10h] 00e000d8 8b4104 mov eax,dword ptr [ecx+4] 00e000db 8945f0 mov dword ptr [ebp-10h],eax ; if `a1.length' 0, jump `return resu...

php - Twitter post and update user profile image -

i'm attempting update user profile using twitter api via j7mbo's wrapper i'm receiving following response... {"request":"/1.1/account/update_profile_image.json","error":"not recognized."} code being used is... require_once('twitterapiexchange.php'); /** set access tokens here - see: https://dev.twitter.com/apps/ **/ $settings = array( 'oauth_access_token' => "***", 'oauth_access_token_secret' => "***", 'consumer_key' => "***", 'consumer_secret' => "***" ); $url = 'https://api.twitter.com/1.1/account/update_profile_image.json'; $requestmethod = 'post'; $postfields = array( 'image' => 'data:image/jpg;base64,ivborw0kggoaaaansuheugaaadaaaaawcaiaaadyyg7qaaaaa3ncsvqicajb4u/gaaamheleqvryhbvzavruv7b+zr23juahgaqwcomai+adfeut0ma00syhdlh6dexn8vrponef062my1wj2tpz3rqj3bqwd...