Posts

Showing posts from April, 2010

javascript - Promise - is it possible to force cancel a promise -

i use es6 promises manage of network data retrieval , there situations need force cancel them. basically scenario such have type-ahead search on ui request delegated backend has carry out search based on partial input. while network request (#1) may take little bit of time, user continues type triggers backend call (#2) here #2 naturally takes precedence on #1 cancel promise wrapping request #1. have cache of promises in data layer can theoretically retrieve attempting submit promise #2. but how cancel promise #1 once retrieve cache? could suggest approach? no. can't yet. es6 promises not support cancellation yet . it's on way, , design lot of people worked hard on. sound cancellation semantics hard right , work in progress. there interesting debates on "fetch" repo, on esdiscuss , on several other repos on gh i'd patient if you. but, but, but.. cancellation important! it is, reality of matter cancellation really important scenario in...

How to add a logout callback for facebook sdk in android -

i have integrated facebook sdk in android app. described in manual added login callback facebook. have change ui if user logs out facebook. put code. code login /** * login callback facebook login */ callbackmanager = callbackmanager.factory.create(); loginmanager.getinstance().registercallback(callbackmanager, new facebookcallback<loginresult>() { @override public void onsuccess(loginresult loginresult) { //call updateui() setdata("provider","facebook"); logintype = logintypes.fb_login; isloggedin = true; graphrequest request = graphrequest.newmerequest( loginresult.getaccesstoken(), new graphrequest.graphjsonobjectcallback() { @override public void onc...

javascript - How can I get coverage of protractor with cucumber -

my project build on django , angular. use protractor cucumber , chai e2e test. , using "grunt-protractor-coverage" report code coverage. have question here if use jasmine protractor framework, when run "grunt test" it's fine. when use cucumber, error happens. [launcher] process exited error code 1 /users/paizanmay/documents/ichef/superadmin2.0/node_modules/protractor/node_modules/q/q.js:126 throw e; ^ error: spec patterns did not match files. @ runner.run (/users/paizanmay/documents/ichef/superadmin2.0/node_modules/protractor/lib/runner.js:249:11) @ taskrunner.run (/users/paizanmay/documents/ichef/superadmin2.0/node_modules/protractor/lib/taskrunner.js:123:19) @ createnexttaskrunner (/users/paizanmay/documents/ichef/superadmin2.0/node_modules/protractor/lib/launcher.js:220:20) @ /users/paizanmay/documents/ichef/superadmin2.0/node_modules/protractor/lib/launcher.js:243:7 @ _fulfilled (/use...

gulp - browser-sync is blocked by chrome csp -

i have gulp task runs browsersync. var options = { proxy : 'localhost:9000/html' , port : 3000 , files : [ config.root + config.srcpaths.htmlbundle , config.htmlroot + 'main.css' , '!' + config.htmlroot + '**/*.scss' ] , injectchanges : false , logfilechanges : true , logprefix : 'brosersync ->' , notify : true , reloaddelay : 1000 }; browsersync( options ); browsersync detects changes , tries inject them chrome blocks error: refused connect 'ws://localhost:3000/browser-sync/socket.io/?eio=3&transport=websocket&sid=goqqpsac3rbjd2onaaaa' because violates following content security policy directive: "default-src 'self'". note 'connect-src' not explicitly set, 'default-src' used fallback. uncaught securityerror: fa...

error handling - What is the right way to capture panics? -

frequently don't want our program stopping due out of bounds, division 0 or similar panics. however, std::thread::catch_panic marked unstable. write... let result = thread::scoped(move || { make_a_division_for_ever() }).join(); if result.is_ok() { println!("finished ok"); } is right way capture panics (like division 0 or out of bounds)? a complete example... use std::thread::thread; fn main() { println!("make divisions ever"); loop { let result = thread::scoped(move || { make_a_division_for_ever() }).join(); if result.is_ok() { println!("finished ok"); } else { println!("it crashed!!! restarting..."); } } } fn make_a_division_for_ever() { loop { println!("enter divisor..."); let line = std::io::stdin() .read_line() .ok() .expe...

java - How do static methods run? -

how static methods run in java? invoke them using class name, , not create object them, these objects can "run", not methods! in case of static method java loads method when class loaded , shares method objects , that's why object not necessary. it's not necessary have object in order run method. and no, it's not object runs. it's method operation , objects or classes hold them property.

C# Write Json file error -

i want write data object json file. my class person public class person { private string firstname; private string lastname; private int height; private double weight; public person() { } public person(string firstname, string lastname, int height, double weight) { this.firstname = firstname; this.lastname = lastname; this.height = height; this.weight = weight; } } my program class class program { static void main(string[] args) { // serialize json string , write string file person ps1 = new person("tay", "son", 180, 99.99); string json = jsonconvert.serializeobject(ps1,formatting.indented); file.writealltext(@"c:\person.json", json); console.writeline("done"); console.readline(); } } person.json displays: "{}" please helps me fix error. change code to: public string firstname; public st...

ruby - RuntimeError when running script? -

so have found ruby script, looks png images in sub folders , folders , converts png images using tinypng api reason runtime error c:/users/vygantas/desktop/tinypng.rb:14:in `': usage: ./tinypng.rb c:/users/vygantas/desktop/product c:/users/vygantas/desktop/product(runtimeerror) #!/usr/bin/ruby -w # # tinypng.rb — placed public domain daniel reese. # require 'rubygems' require 'json' # set api key. apikey = "xxxxxxxxxxxxxxxx" # verify arguments. argv.length == 2 or fail("usage: ./tinypng.rb c:\users\vygantas\desktop\product c:\users\vygantas\desktop\product*emphasized text*") src = argv[0] dst = argv[1] file.exist?(src) or fail("input folder not exist: " + src) file.exist?(dst) or fail("output folder not exist: " + dst) # optimize each image in source folder. dir.chdir(src) dir.glob('*.png') |png_file| puts "\noptimizing #{png_file}" # optimize , deflate both images. cmd = ...

java - Struts 2 display image -

i looking simpler solution display image inside jsp page, within struts2 application. solution found far (and working) one: struts 2 dynamic image example . however, writing image stream of bytes seems me overkill. there other simpler solution? or absolutely necessary use stream of bytes? simply, writing <img src="#image_location_on_disk"> is not acceptable solution, because want struts responsible bringing image (in business logic decide whether image should displayed or not) if want stream image location not publicly visible browser, standard way it. in case use fileinputstream read image, assign inputsream , use stream result action. in struts2 can perform task of serving image stream result instead of writing directly response. can configure result corresponding content type.

ios - Declaring function usable throughout project -

i new swift , trying figure out how add function usable throughout entire project. simple function like func globalfunction() { println("global function!") } then able call function on swift file within project. declare function? its in programming language - declaring function outside class, like: class { var a:int // can call global function here } class b { var b:int // , here } func flobalfunction() { println("hello, global function!") }

node.js - MongoDB to return assoc array of results -

my collection has object following form {'id':2, 'name':'john', 'avatar':'img.png'}, {'id':3, 'name':'chriss', 'avatar':'img2.png'} after query mongo, want following results {'2': {'id':2, 'name':'john', 'avatar':'img.png'}, '3':{'id':3, 'name':'chriss', 'avatar':'img2.png'}} is possible mongo or have iterate on results form ? you try iterating on results using find() cursor's foreach() method follows : var obj = {}; db.collection.find({}, {"_id": 0}).foreach(function(doc){ obj[doc.id.tostring()] = doc; }); printjson(obj); or using map() method: var mapped = db.collection.find({}, {"_id": 0}).map(function(doc){ var obj = {}; obj[doc.id.tostring()] = doc; return obj; }); printjson(mapped); output in both methods : { "2" : {...

matlab - Image steganography based on DWT integer coefficients -

i trying code dwt based steganography hide image inside image. getting coefficients of subbands float. how can make them integers can use lsb embedding? this known integer wavelet transform. in matlab achieved using lifting schemes . define lifting scheme liftwave , use lwt2 , ilwt2 transformations. lshaar = liftwave('haar','int2int'); [ca ch cv cd] = lwt2(x,lshaar); % x data ilwt2(ca,ch,cv,cd,lshaar);

html - How to solve this error : Bad value original-source for attribute rel -

i trying validation site w3c getting error: bad value original-source attribute rel on element link: string original-source not registered keyword. for: <link rel="original-source" href="http://themarketmogul.com/" /> can 1 suggest me can error. the rel attribute specifies type of link. there limited set of values attribute (the type) accepts. specification defines them in section 4.8.4 link types : alternate - gives alternate representations of current document. author - gives link author of current document or article. bookmark - gives permalink nearest ancestor section. etc. this list includes best known stylesheet type importing css stylesheets. there no "original-source" type. hence, validation error get. in case looking meta tag name "original-source" (see codyogden's answer).

java - Fast conversion of String to byte[] using UTF-16LE encoding -

i need bytes of millions of string using : string str="blablabla...."; // utf-16le encoding string extracted db bytes=str.getbytes("utf-16le") but awfully slow . there custom fast versions of getbytes don't support utf-16le . example 1 of them: // http://stackoverflow.com/questions/12239993/why-is-the-native-string-getbytes-method-slower-than-the-custom-implemented-getb private static byte[] getbytesfast(string str) { final char buffer[] = new char[str.length()]; final int length = str.length(); str.getchars(0, length, buffer, 0); final byte b[] = new byte[length]; (int j = 0; j < length; j++) b[j] = (byte) buffer[j]; return b; } is there similar fast solution convert java string byte array using utf-16le encoding? this version produce utf16le bytes array: private static byte[] getbytesutf16le(string str) { final int length = str.length(); final char buffer[] = new char[length]; str.getchars(...

Is it possible to use an object defined in C# to serve as an input to R function/command using R.NET -

i using r.net library call r functions in c#. want define or construct input in c# , pass r command. tried : engine.evaluate("library(mirt)"); engine.evaluate("x=mirt(science,1)"); s4object obj111 = engine.getsymbol("x").ass4(); engine.evaluate("pl=x@pl"); numericvector pl_c= engine.getsymbol("pl").asnumeric(); int[] resp_c = new int [] {1,1,1,1}; engine.evaluate("ff=fscores(x, response.pattern=resp_c)"); while trying came across error says, "resp_c" not found. is there way pass input r functions c# without writing input explicitly in double quotes nothing r script. thank response in advance. not expert of c#, quick glance @ the doc reveals can achieve want through: int[] resp_c = new int [] {1,1,1,1}; integervector resp_cr = engine.createintegervector(resp_c); engine.setsymbol("resp_c", resp_cr); engine.evaluate("ff=fscores(x, response.pattern=resp_c)"); you need...

asp.net - display data dynamically in gridview -

i have list of image urls have check whether url responding or not. adding url not responding gridview 1 one . problem when first not responding url displaying in gridview , when subsequent invalid url added, replacing first. need display removeurl s in gridview here code: list<removeurl> removeurl = new list<validateurlofhiipsdata.removeurl>(); datatable dtfpid = businessclass.gethotelfpid(); (int = 1; <= 2; i++) { if (session["removeurl"] != null) { removeurl = (list<removeurl>)session["removeurl"]; } removeurl = businessclass.searchimageurl(i)/*checking url valid or not; session["removeurl"] = removeurl; gvremovedurl.datasource = session["removeurl"]; gvremovedurl.databind(); } each time iterate through for loop, setting removeurl list value stored in session["removeurl"] . don't think after. i have made assumptions: all url...

asp.net - Execution time testing for c# method -

i have cs page few methods. when try load page takes long time. there way identify how long each method taking fetch data? instead of debugging there way of capturing time spans? any tool or other suggestions? the visual studio profiling tools let developers measure, evaluate, , target performance-related issues in code. these tools integrated ide provide seamless , approachable user experience. profiling application straightforward. begin creating new performance session. in visual studio team system development edition, can use performance session wizard create new performance session. after performance session ends, data gathered during profiling saved in .vsp file. can view .vsp file inside ide. there several report views available visualize , detect performance issues data gathered. msdn reference

ios - What is the purpose of a DictionaryIndex in Swift? -

per header documentation on dictionary in swift: a hash-based mapping key value instances. collection of key-value pairs no defined ordering. note in particular- no defined ordering . with in mind, i'm having trouble understanding these computed variables (and related methods take these types): // position of first element in non-empty dictionary. var startindex: dictionaryindex<key, value> { } // collection's "past end" position. var endindex: dictionaryindex<key, value> { } the "index" here dictionaryindex . however, documentation on dictionaryindex kinda circular here: used access key-value pairs in instance of dictionary<key, value> . what purpose of dictionaryindex ? we know dictionary composed of keys , values . every key mapped value based on internal calculations. here mechanism used purpose hashing . from wikipedia: a hash table uses hash function compute index array of bu...

javascript - Can we use web SQL local database with PHP? -

i'm creating offline application using web sql local database javascript. when internet not connected on time entries inserted in local database web sql. but when connected internet web sql local database synchronize live database , new entries of local database not available in live database inserted automatically. later on application deployed in phonegap. here code local database (sql transactions) open database: var db = opendatabase('retaurant', '1.0', 'test db', 2 * 1024 * 1024); new table , insert data table: var username = "test"; var password = "test"; db.transaction(function (tx) { tx.executesql('create table if not exists user (id integer not null primary key autoincrement , username,password)'); tx.executesql('insert user (username,password) values ("'+username+'","'+password+'")'); }); delete entry database db.transaction(function (tx) { ...

Using Google App Scrips to produce Input Messages -

i want have set-up our gaming community out. have idea if put value cell on google spreadsheet, give client-side pop-up box saying something. now in current spreadsheet use can see here: " https://docs.google.com/spreadsheets/d/1qbvvqkkmlj3ro2uhamqm2yulmj8tg38p5ke3yie-fwi/edit#gid=1161230471 ". have data validation under course section. essentially, want happen when person selects value drop down list, put pop-up box on screen explaining key information course. is possible? shaun. here how it. add many "else if" functions want. formatted in easy edit function onedit(e) { var cell = e.range; var cellcolumn = cell.getcolumn(); var cellsheet = cell.getsheet().getname(); var cellvalue = e.value; var sheet = "system_info"; //this here ignore system info sheet if (cellsheet !== sheet && cellcolumn === 4) { if (cellvalue === "pt1 - induction training") { browser.msgbox("this training course. (pu...

vba - Removing extra quotes in XML files -

i'm making quick , dirty xml generator. below code works when open it has additional double quotes i.e. <"something"> turn "<""something"">. there way remove them below code? can't use xltextprinter because of cells have more 255 characters. appreciated! sub test() dim desktop string dim filename string desktop = createobject("wscript.shell").specialfolders("desktop") activesheet filename = .range("b1").value .range("h2:k33").copy workbooks.add activeworkbook.sheets(1).range("a1").pastespecial xlpastevalues application.cutcopymode = false end activeworkbook .saveas filename:=desktop & application.pathseparator & filename _ , fileformat:=xltextmsdos, createbackup:=false .close savechanges:=false end end sub because excel add quotes file in situations when exported t...

operating system - What is the Best Linux OS for Samsung 900x? -

i wondering if can recommend me linux os samsung 900x laptop. want familiarize myself linux os , know companies people uses linux. thanks! you should ask kind of questions in linux forums. depending on hardware , knowledge level can choose distro use. example if want use os out of box, can use distributions linux mint , ubuntu. i recommend try live linux disk knoppix has desktop environments installed. can choose desktop (gnome shell, kde, xfce,...) , if ever wanted install linux on hard disk, @ least know want. luck , welcome gnu/linux world!

How to prevent people from accessing OpenShift web apps? -

i uploaded wildfly web application free openshift account team members can check out. it's work in progress don't want people know , access via web. if want use i'll send them url "xxx-xxx.rhcloud.com" is there way prevent people knowing , accessing web application on openshift? you can use basic authentication in order provides login/password before access contents. in openshift there enviroment variable called $openshift_repo_dir, path of working directory i.e. /var/lib/openshift/myuserlongid/app-root/runtime/repo/ i create new enviroment variable called secure wrapping folder path. rhc set-env secure=/var/lib/openshift/myuserlongid/app-root/data --app myappname finally connect app ssh rhc ssh myappname and create .htpasswd file htpasswd -c $secure/.htpasswd <username> note: -c option htpasswd creates new file, overwriting existing htpasswd file. if intention add new user existing htpasswd file, drop -c option. .htaccess...

python - Redirect any urls to 404.html if not found in urls.py in django -

how can redirect kind of url patterns created page "404.html" page if doesn't exist in urls.py rather being shown error django. make view that'll render created 404.html , set handler404 in urls.py. handler404 = 'app.views.404_view' django render debug view if debug enabled. else it'll render 404 page specified in handler404 types of pages if doesn't exist. django documentation on customizing error views . check this answer complete example.

eclipse - How to change default properties in Maven Release Plugin for WSDL builds -

i require default properties of mvn release:prepare , mvn release:perform modified. source code i'm trying build has wsdl files. the jar file generated in non maven format , achieved 2 step build process, using i'm able generate maven based wsdl compiled jar file. mvn exec:exec mvn install:install-file -dgroupid=com.stackoverflow.abc -dartifactid=xyz -dversion=${build_version} -dpackaging=jar -dfile=path-of-jar -dpomfile=path-of-pom.xml this builds jar file mainfest.mf , no pom.properties , pom.xml, i'm trying convert jar generated in non maven format maven format. when try using release:prepare , release:perform, i'm unable override default properties used in mvn install:install-file , there no way generate jar pom properties is there way can override mvn release plugin properties me build jar files? plugin used build wsdl: <plugin> <groupid>org.codehaus.mojo</groupid> <artifactid>exec-maven-plugin</a...

mysql - How to cross join a table and use fields from the select statment in the where clause of the cross join -

unfortunately cannot make procedure in case. i'm setting variables in select statement , using them in cross join. count(*) line item 0... select @p := `purchaseorder`.`po` `po` ,`purchaseorder`.`customer po` ,`customer`.`customer` ,`work_order`.`work order` ,@l := `work_order`.`line order` `line order` ,`line item`.`line item` `work_order` left join `purchaseorder` on `purchaseorder`.`po` = `work_order`.`po` left join `customer` on `customer`.`rn` = `purchaseorder`.`customer` cross join (select count(*) `line item` `work_order` `work_order`.`po` = @p , `work_order`.`line order` <= @l ) `line item` `purchaseorder`.`po` not null order `purchaseorder`.`po`,`work_order`.`line order` what doing wrong? thanks pala_ this works! select @p := `purchaseorder`.`po` `po` ,`purchaseorder`.`customer po` ,`customer`.`customer` ,`work_order`.`work order` ,@l ...

android - How to zoom to a specific country with OSMDroid? -

assume following situation: user chooses country list. after clicking on country, map should zoom selected country. how can achieve zoomtocountry in osmdroid if know country name list? in php api "googlemaps v3" there solution like function findaddress(address) { var geocoder = null; geocoder = new google.maps.geocoder(); if (!address) var address=document.getelementbyid("countryselect").value; if ((address != '') && geocoder) { geocoder.geocode( { 'address': address}, function(results, status) { if (status == google.maps.geocoderstatus.ok) { if (status != google.maps.geocoderstatus.zero_results) { if (results && results[0] && results[0].geometry && results[0].geometry.viewport) map.fitbounds(results[0].geometry.viewport); } else { alert("no results found")...

Can I create a IVR Using Sinch -

i trying app in sinch act automated voice response menu people choose set of options , application forward call accordingly. know twillio has this, wanted use sinch various reasons. the documentation not complete, give ivr type example suggests "might" possible. { "instructions": [{ "name" : "playfiles", "ids" : [ "welcome" ], "locale" : "en-us" }], "action": { "name" : "connectpstn", "number" : "+46555000111", "maxduration" : 600, "locale" : "en-us", "cli" : "+46555000222", "suppresscallbacks" : true } } but there isn't verb (like twillio) can capture response. has out there been able create simple ivr using sinch? edit, support now please @ https://www.sinch.com/docs/voice/rest/#runmenuaction

c - Realloc setting pointer to empty -

void test(){ char *c = malloc(strlen("i coffe") + 1); strcpy(c, "i coffe"); char **s = &c; while(strlen(*s) < 25) my_function(s); } void my_function(char **s){ char *w = *s; char *tmp = realloc(w, len + 2);//error here. *s gets = "" if(tmp != null) w = tmp; for(i= len; i>=p; i--){ w[i+1] = w[i]; } w[p] = c; } this function used insert new character inside char * . also, function inside while loop. works fine 3rd time loop runs, sets *s = "" . thought using char *tmp keep data if wrong thing happen. can't understand why p *s been setted empty string. you've forgotten assign new value *s in function contains realloc() . void test(void) // unaltered; still broken! { char *c = malloc(strlen("i coffe") + 1); strcpy(c, "i coffe"); char **s = &c; while (strlen(*s) < 25) my_function(s); } void my_function(char **s...

java - (Simple placement issue) How do I make my ATM program not withdraw below $0? -

this java 1 final. want kick saying insufficient funds if balance go below $0 (and not create object action -- added arraylist actions). i believe use conditions in 2 places. 1 in getdouble() method in class account, in object action() in class action. perhaps in main method though... don't know conditions put, , in simplest way won't mess program.. i have separate issue... if huge number, 7 or 8 digits, return different value, 200e7jk(example). assume double reaching kind of maximum. how can fix this? main class: public class atm_larrabee { public static void main(string[] args) { scanner in = new scanner(system.in); arraylist<action> actions = new arraylist(); account acc = new account("n/a", "n/a", 0.0); acc.displaywelcome(); acc.createusernamepassword(); boolean options = true; while(options){ acc.disconnect(); system.out.println("\nwhat action take?"); s...

ruby - Dynamically including a Rails Concern -

my objective dynamically load set of methods activerecord model instance based on attribute that's set: class book < activerecord::base after_initialize |cp| self.class.include "#{cp.subject}".constantize end end i have following concerns: module ruby extend activesupport::concern def get_framework 'rails' end end module python extend activesupport::concern def get_framework 'django' end end then, when run these separately, correct framework string: python_book = book.create(:subject => 'python', :id => 1) python_book.get_framework -> 'django' ruby_book = book.create(:subject => 'ruby', :id => 2) ruby_book.get_framework -> 'rails' my problem when have both of books returned in query, concern included last in result set , not picking correct concern methods. books.all.order(:id => 'asc').collect |book| puts book.get_framewo...

javascript - GoJS: use more than one parameter in a conversion function -

i need use 2 properties of node in gojs perform particular operation. here current code: $(go.picture, { //some properties }, new go.binding("source", "item_status", geticon)), //.... function geticon(item_status) { //do } is possible modify above code geticon() function gets second parameter called item_id? e.g can this: new go.binding("source", "item_status","item_id", geticon)), .... function geticon(item_status, item_id) {} thanks answering own question again... to data particular node, can pass "" instead of "item_status" binding function. go.binding("source", "", geticon)), ... geticon(node){ var x = node.item_status; var y = node.key; }

javascript - slick slider will not instantiate when content is loaded via ajax -

what trying load in portfolio item on click of div pertains portfolio item. load portfolio single page , populate view. slick slider not being instantiated , not work when loaded via ajax. this code instantiates slick slider (usually wrapped in $(document).ready. if enter in console after ajax gets loaded works, if add end of .click() function (which load content via ajax) seems not intantiated - , nothing in console tell me why not: $('.slick-slider').slick({ lazyload: 'ondemand', centermode: true, centerpadding: '60px', variablewidth: true, speed: 300, slidestoshow: 1, adaptiveheight: true, responsive: [ { breakpoint: 1024, settings: { slidestoshow: 3, slidestoscroll: 3, infinite: true, dots: true } }, { breakpoint: 600, settings: { slidestoshow: 2, slidestoscroll: 2 } }, ...

php - why the last element of array changed after 2 foreach loop? -

this question has answer here: strange behavior of foreach 2 answers what's magic? last element of $data changed, after 2 each loop. <?php $data = array("1" => "a", "2" => "b"); print_r($data); foreach($data $k=>&$v) {} foreach($data $k=>$v) {} print_r($data); output:[2] => after second foreach array ( [1] => [2] => b ) array ( [1] => [2] => ) it code change this,the array won't change: <?php foreach($data $k=>&$v) {} foreach($data $k=>&$v) {} from foreach manual: warning reference of $value , last array element remain after foreach loop. recommended destroy unset(). so @ end of first foreach , $v reference last element in array. next foreach 's first iteration changes value of $v (to value of first array element) re...

Google Public API access, Allowed Referrers Key for browser applications -

i'm using key browser applications. i'm trying set domain referrers functional on website api stop working. example: api on www.mywebsite.com/v1.html i've tried .mywebsite.com/ on edit allowed referrers page , stop working

ios - unexpectedly found nil while unwrapping an Optional value - Sprite Kit -

hey guys im having huge problem sprite kit game. im new , im trying kind of asteroids game exercise learnt. my problem is, asteroids infinite, don't stop unless player hit. code follows: for meteor: func addmeteor() { let bigmeteor = skspritenode(imagenamed: "meteor1") let bigmeteoraux = bigmeteor let sizex = uint32(cgrectgetmaxx(self.frame)) let randomx = cgfloat(arc4random_uniform(sizex)) var impulse : cgvector! bigmeteoraux.position = cgpoint(x: randomx, y: size.height + 100) impulse = cgvector(dx: 0, dy: -30) bigmeteoraux.physicsbody = skphysicsbody(texture: bigmeteor.texture, size: bigmeteor.size); bigmeteor.physicsbody?.affectedbygravity = false bigmeteor.physicsbody?.allowsrotation = false bigmeteoraux.physicsbody?.friction = 0.0 bigmeteoraux.physicsbody!.categorybitmask = collisioncategoryasteroids bigmeteoraux.name = "asteroid" ...

javascript - .menu() is not a function; jQuery upgrade -

i migrating menu widget jquery 1.6.4 newer version of jquery , 1.11.1 $(document).ready(function () { $('#takemetolink').menu({ content: $('#globalcontent1').html(), flyout: false }); }); markup <a id="takemetolink" href="#" style="color:black"> take me <span style="height:3px;width:15px;position:relative;display:inline-block;overflow:hidden;" class="s4-clust ms-viewselector-arrow"> <img src="/_layouts/15/images/fgimg.png" alt="open menu" style="border-width:0px;position:absolute;left:-0px !important;top:-491px !important;" /></span> </a> when replace .js file new one, throws exception uncaught typeerror: $(...).menu not function is there new function available? .menu() jquery ui "widget", means need include jquery ui. here...

Understanding this custom hasPrototypeProperty function in JavaScript -

how function determine if property exists on prototype ? function hasprototypeproperty(object, name){ return !object.hasownproperty(name) && (name in object); } i confused 2 things: what ! operator doing hasownproperty method? and while && seems saying (name in object) has true well, kind of not sure... i know hasownproperty return true if property exists on instance, read still checks prototype , if so, for? seems strange thing if instance thing matters? thanks in advance! what ! operator doing hasownproperty method? it's boolean not operator . doesn't method, result of call. and while && seems saying (name in object) has true well, kind of not sure... yes, that's does. i know hasownproperty return true if property exists on instance, read still checks prototype, if so, for? not, not check prototype. in operator however. so hasprototypeproperty function return true iff object has no own...

jquery - Why is this DIV duplicating? -

i having trouble getting banner image underneath nab bar fit right , respond screen width. seems div using set banner background image duplicated or here screen shot... duplicate div pic this same image twice. here code: <!doctype html> <html> <head> <title>vector games</title> <meta charset="utf-8"/> <link rel="shortcut icon" href="favicon.png" /> <link rel="stylesheet" type="text/css" href="homecss.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <head> <style> body{ margin: 0; padding: 0; font-family: sans-serif; } header{ background-image: url('cubes.png'); width: 100%; padding: 15px 0; color: #49ac6f; text-align: center; font-size: 20px; } a{ text-decoration: none; color: inherit; } nav ul{ background-co...

vbscript - How to avoid "permission denied" when copying damaged files? -

i write vbscript copy file e drive c drive. there many system files , damaged files in e drive, when copy these files, script stop. method pass or skip these files when script running? the code copy folders e drive c drive const hd = "e:\" const cd = "c:\" dim path sub genpath() path = cd end sub sub genfolder() set objfso = createobject("scripting.filesystemobject") objfso.createfolder path set objfso = nothing end sub set fso=wscript.createobject("scripting.filesystemobject") set fs=fso.getfolder("e:\") set f=fs.subfolders each uu in f set ws = wscript.createobject("scripting.filesystemobject") ws.copyfolder uu,path & "\" for each uu in f set ws = wscript.createobject("scripting.filesystemobject") ws.copyfolder hd & uu,path1 end if next becomes set ws = wscript.createobject("scripting.filesystemobject") ...

ios - Use of custom delegate vs NSNotification vs NSUserDefaults state -

Image
in app i'm using nsuserdefaults give state performing operations based on state. in other places i'm using nsnotification-s fire methods in other classes. feel 1 example better use custom delegate. what benefits , drawbacks using nsnotification vs custom delegate vs i'm doing nsuserdefaults? my question intends address performance or potential issues between using nsuserdefaults give state compared calling methods using either protocols or nsnotificationcenter. it's important remember nsuserdefaults persists data. when read , write nsuserdefaults, you're reading , writing to/from disc. whenever use nsuserdefaults should ask "is needs persisted between app launches? could/should thing without writing disc?" (note performance: any time have go disc something, expect take longer time) nsuserdefaults ideal things app settings. app have multiple color schemes user can choose from? store preferences in user defaults , them later. i put nsus...

php - Concrete5: set File thumbnail to generated image (e.g. for PDFs) -

i'm using concrete5, , i'm trying display thumbnails various uploaded files. while of these might images, majority pdfs. i'm using: <?php $file = file::getbyid($fid); $imagehelper = core::make('helper/image'); try { $imagehelper->outputthumbnail($file, 200, 200); } catch(invalidargumentexception $e) { ?> <img src='https://placehold.it/200x200'> <?php } ?> i'd prefer somehow create smaller thumbnail of pdf files, example using ghostscript in background. in built-in file manager, @ least pdf icon displayed. non-optimal option, still better not displaying signify we're dealing pdf.. how can access built-in thumbnails? and, more importantly, how can overwrite them file-types when uploaded? edit: i came across $file->getthumbnailurl('type'); , created type own purposes. how automatically generate such thumbnail when file uploaded? can figure out how generate file plain php, storing in concrete5 i...

php - Mediawiki Call hook function from another file -

hello need save content database in mediawiki when new page created. added hook in localsettings.php: $wghooks['pagecontentsavecomplete'][] ='assign_responsibility'; but need call function assing_responsibility() extension php file responsibility.php not localsettings. new @ mediawiki system , cant find out how tell mediawiki can find required hook function ? thank you hook values php callables ; can defined in file long file gets loaded before hook gets called (or, if use class method instead of global function, class registered via $wgautoloadclasses ). the convention extension (which assume called responsibility) creates hook file: // responsibilityhooks.php class responsibilityhooks { public static function onpagecontentsavecomplete(/*...*/) { /*...*/ } // ... } and makes sure can autoloaded: // responsibility.php $wghooks['pagecontentsavecomplete'][] = 'responsibilityhooks::onpagecontentsavecomplete'; $wgautoloadc...

Why is my button_to creating blank entries? Ruby on Rails 3 -

updated not using params passing params block it seems parameters not getting passed controller action. i'm trying create entry svc_tickets table using button_to . i'm getting blank entries table . this button_to <td class='create_service_ticket' style="width: 7%"><%= button_to 'create service ticket', {controller: :svc_tickets, action: 'create', priority_level: 3, summary: event[:signature_name].to_s, description: 'description', closed: 0} %> </td> svcticktscont...

sql server - How to get the physical_name of the secondary log shipping databases? -

the following query returns m:\data\db.mdf , l:\data\db.log . however, server doesn't have drive m: , l:. select * sys.database_files how physical names of disk files? need detach database , make copy of database files restore on machine since secondary logshipping database cannot backed up. what's best way make copy of secondary db?

java - Partitioning tests across multiple nodes with Gradle and TestNG -

i have java project lot of tests. build using gradle , tests using testng , invoked gradle. speed testing build running build simultaneously on multiple workers , having each worker run subset of tests. each node provide 2 environment variables total_nodes , node_number , total_nodes number of nodes running build , node_number number assigned particular node. i want way of partitioning tests each node runs ~ 1/total_nodes tests , each test run once. there simple way of doing gradle , testng? i manually divide tests groups labeling each 1 in specific group, there many tests , that's major maintenance hassle, plus doesn't scale if number of nodes change. gradle offers tests filtering, seems it's based on class name matching, , can't accept arbitrary filtering functions. find test files , subdivide them according hashing scheme before plugging them test filter, seems needlessly complex. is there simpler way of doing this? there no simple wa...

c# - BigInteger.Pow(BigInteger, BigInteger)? -

i'm trying calculate large number, requires biginteger.pow() , need exponent biginteger , not int . i.e. biginteger.pow(biginteger) how can achieve this? edit: came answer. user dog helped me achieve this. public biginteger pow(biginteger value, biginteger exponent) { biginteger originalvalue = value; while (exponent-- > 1) value = biginteger.multiply(value, originalvalue); return value; } just aspect of general maths, doesn't make sense. that's why it's not implemented. think of example: biginteger number 2 , need potentiate 1024. means result 1 kb number (2^1024). imagine take int.maxvalue : then, number consume 2 gb of memory already. using biginteger exponent yield number beyond memory capacity! if application requires numbers in scale, number large memory, want solution stores number , exponent separately, that's can speculate since it's not part of question. if your issue exponent variable bigi...

php - Controllers and pages without "actions"? MVC -

as understand "mvc" came before web , used in desktop software example. if understand correctly, controller runs @ time user click button , trigger action. but if talk web pages, scenario little different, assuming user clicks link triggers action. but then, came me doubt, home page part of controller ? what mean is, homepage not performed user action within website home , noticed many php frameworks use controller home , correct? another doubt in "home" have several items, example: banners featured posts recent posts each of these items have different model , can call more 1 model , view controller ? would these correct steps? or of php frameworks not strict? you right , understand confusion. in pure mvc approach , controller listens user actions , updates model accordingly. model notifies view (through observer design pattern) , view updates itself, accessing data needs model. how done before web, in desktop application, mo...

Generating a HTML table from an Excel file using EPPlus? -

i generate html table excel file. epplus package provides .net api manipulating excel file. happy know whether possible generate html table code excel file using epplus? couldn't find on documentation, intuition tells me there should way it thank you! if looking built epplus, havent seen export directly html. best thing bring in excel file epplus , extract data collection or datatable . should pretty straight forward. from there, there plenty of documentation on how html table. quick search turned first hit: datatable html table

java - Spring : XML Configuration Location -

i learner of spring have build test project spring ioc container , have configure beans.xml in project root path , load application , bean it. spring.xml in project root directory beanfactory bean = new xmlbeanfactory(new filesystemresource("spring.xml")); spring.xml in source file beanfactory bean = new xmlbeanfactory(new filesystemresource("src/spring.xml")); this code load beans.xml file applicationcontext context = new genericxmlapplicationcontext("beans.xml"); my question is there standards or conventions creation of xml file name , location of file in real project.because in reading articles found there might multiple xml files large project service.xml , dao.xml. it can useful have bean definitions span multiple xml files. each individual xml configuration file represents logical layer such defining dao beans etc. in architecture should place xml configuration files under src/resources , access them new classpathxmlappli...