Posts

Showing posts from September, 2014

objective c - EXC_BAD_ACCESS error when using an NSURLSession NSURLSessionDownloadTask on some hardware in iOS 9 -

update works in ios9 beta 5 original question executing line of code causes exc_bad_access error happen shortly after in library code on non-main thread before completion handler called. [[[nsurlsession sharedsession] downloadtaskwithurl:[nsurl urlwithstring: @"https://www.google.com/images/srpr/logo11w.png"] completionhandler:^(nsurl *location, nsurlresponse *response, nserror *error) { nslog(@"at download completion handler"); }] resume]; it happens on ipad model a1403 on ios 9 beta 3 , 4, not on ios8.1, , works fine on ipad model a1566 on both ios 9 , ios 8.4. i've logged bug apple. is else having issue? see workaround? tests: ios 8.1 - device a1566 - working ios 8.4 - device a1403 - working ios 9 beta 4 - simulator - wo

jquery - Scroll modal on show -

i'm using jquery show bootstrap modal, unable scroll until manually click inside it. i've tried focus(): $('#action-modal-body').focus() i've tried click(): $('#action-modal-body').click() i've added delay account modal animation: settimeout(function (){ $('#action-modal-body').click() }, 1000); now bootstrap 3 events has change can achieved (plus smooth animation top) $('#modalidhere').on('shown.bs.modal', function () { $('#modalidhere').animate({ scrolltop: 100 }, 'slow'); });

php - Adding Pagination to WordPress Page Templates -

i built wordpress theme existing theme (one engine theme). site launched , seems working except pagination. have tried many things failed work. template pages meant paginate @ point no 1 seem work. below looping code blog page template: <?php $newsposts = get_posts(); foreach($newsposts $post) : setup_postdata($post); ?> //the html codes added here <?php endforeach; ?> i want make post per page 4 , add default wordpress pagination function: <?php posts_nav_link(); ?> the page template here blog.php, can see page in action here: www.kayodeolusoji.net/blog appreciated! try this: i add 'paged' atrribute in $args wiht wp_query $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $posts_per_page=4; $args = array( 'paged' => $paged, 'posts_per_page'=>$posts_per_page );

python - How to return django form object in an AJAX request from django template? -

i trying call view django template via ajax call. i want form object in response view such can render form via jquery in div element. is possible ? how? this tried: home.html function get_edit_form(button, id) { $.ajax({ url: "/manage/licenses/{{mls_signup_code}}/{{agent_id}}/" + id + "/", type: "get", data: {id: id}, success: function(response) { console.log(response); $("#formdiv").html({{ response.as_p }}); } }) } views.py elif request.method == "get": owned_license_id = request.get.get('id', '') form = ownedlicenseform(owned_license_id) return form i see trying do, cannot render html form way: $("#formdiv").html({{ response.as_p }}); i think confusing server side rendering (django templates) client side rendering. server side rendering happens when se

gcc - Benchmarking a pure C++ function -

how prevent gcc/clang inlining , optimizing out multiple invocations of pure function? i trying benchmark code of form int __attribute__ ((noinline)) my_loop(int const* array, int len) { // use array compute result. } my benchmark code looks this: int main() { const int number = 2048; // own aligned_malloc implementation. int* input = (int*)aligned_malloc(sizeof(int) * number, 32); // fill array random numbers. make_random(input, number); const int num_runs = 10000000; (int = 0; < num_runs; i++) { const int result = my_loop(input, number); // call pure function. } // since program exits don't free input. } as expected clang seems able turn no-op @ o2 (perhaps @ o1). a few things tried benchmark implementation are: accumulate intermediate results in integer , print results @ end: const int num_runs = 10000000; uint64_t total = 0; (int = 0; < num_runs; i++) { total += my_loop(input, number); // call pure function. } printf(&quo

r - reshape and aggregate datatable -

i asked similar question , because haven't quite gotten handle on tidyr or reshape have ask question. have datatable containing repeat id values (see below): id product ni 1 direct auto 15 2 direct auto 15 3 direct auto 15 4 direct auto 15 5 direct auto 15 6 direct auto 15 6 mortgage 50 9 direct auto 15 10 direct auto 15 11 direct auto 15 12 direct auto 15 13 direct auto 15 14 direct auto 15 15 direct auto 15 16 direct auto 15 1 mortgage 50 5 personal 110 19 direct auto 15 20 direct auto 15 1 direct auto 15 i id aggregated 1 row, product column 'spread' values become variables, variable containing aggregated count of each product id, , ni summed each of product groups id. see example below: id directauto da_ni mortgage mortgage_ni personal p_ni 1 2 30 1 50 na na 2 1 15 na na na na 3 1 15 na na na na 4 1 15 na na na na 5 1 15

three.js - Creating a 3d graph using VivaGraphJS and using a particle system -

i'm trying create force directed graph layout data of nodes , edges have.i want use vivagraphjs this. want integrate particle cloud in threejs. know how them individually, i'm lost when comes using them together. you use ngraph.pixel , combines three.js renderer 3d layout engine ngraph family. see more demos here . both vivagraph , ngraph.pixel sharing same primitive structures.

windows 7 - How do I start ipython's qtconsole cleanly on Win7 -

i have python 3.4 , ipython 2.3.1 installed on windows 7. installed ipython using pip wheel http://www.lfd.uci.edu/~gohlke/pythonlibs/ (thanks, chris!). install procedure not create start menu shortcuts, when run administrator. can run "ipython qtconsole" cmd window, have have command window open , process doesn't fork--it's , window hosting child process. if create shortcut same, opens cmd window opens qtconsole. so, how start qtconsole without having cmd window? in previous versions, invoke python run ipython-console script, seems done away now, in favor of dedicated exe appears same...but waits finish. there way can start qtconsole without waiting? i found here , , tried few things , hence found if typed in run window c:\python27\pythonw -c "import ipython; ipython.start_ipython(['qtconsole'])" i guess should work shortcuts. p.s: using python 2.7.9 ipython 3.0.0 on windows 7

iOS Autolayout - How to have one sticky subview when rotating (like Native Camera App)? -

Image
i creating custom camera , want lock camera controls bottom of phone @ orientations i.e. portrait orientation has control toolbar @ bottom, landscape orientation has control toolbar on left i have been playing around constraints , setting them width/height aspects rotates. suggestions? portrait: landscape: so ended locking view portrait orientation, transforming text (i think how apple it). see answer transforming text: objective c: how can rotate text uibutton , uilabel?

lua - lupa not working on mac OSX 10.9.5 -

python 2.7.6 (v2.7.6:3a1db0d2747e, nov 10 2013, 00:42:54) [gcc 4.2.1 (apple inc. build 5666) (dot 3)] on darwin type "help", "copyright", "credits" or "license" more information. >>> lupa import * >>> lua=luaruntime() dyld: lazy symbol binding failed: symbol not found: _lual_newstate referenced from: /library/frameworks/python.framework/versions/2.7/lib/python2.7/site-packages/lupa/_lupa.so expected in: flat namespace dyld: symbol not found: _lual_newstate referenced from: /library/frameworks/python.framework/versions/2.7/lib/python2.7/site-packages/lupa/_lupa.so expected in: flat namespace [1] 11436 trace trap python first uninstall lupa. install again with: ldflags="-l/usr/local/bin/lua" pip install lupa==1.3 --no-binary :all: note: above path lua binary default 1 on el capitan when installing lua via brew (brew install lua). might have change path lua binary if it's installed somew

php - Add Pagination To Custom Magento catalog -

i have code, , need add pagination code. function __construct() { $category = mage::getmodel('catalog/category'); $products = mage::getresourcemodel('catalog/product_collection') ->addattributetoselect('name') ->addattributetoselect('price') ->addfinalprice() ->addattributetoselect('small_image') ->addattributetoselect('image') ->addattributetoselect('thumbnail') ->addurlrewrite() ->addcategoryfilter($category); mage::getsingleton('catalog/product_visibility')->addvisibleincatalogfiltertocollection($products); $currencycode = mage::app()->getstore()->getbasecurrencycode(); foreach($products $product){ echo $product->getid()."<br>"; echo $product->getname()

javascript - Compare arrays of different sizes and dimensions -

so here's proposed problem. compare 2 arrays , return new array items not found in both of original arrays. here's have far. function diff(arr1, arr2) { (var in arr1) { (var b in arr2) { if (arr1[a] == arr2[b]){ arr2.splice(b,1); } } } return arr2; } diff([1, 2, 3, 5], [1, 2, 3, 4, 5]); this code compares each value of first array second one. if match found removes item using splice function. this works great arrays 1 dimensional how can work multidimensional arrays such as: diff([1, 2, 3, 5], [1, [2, 3], [4, 5]]); what if these arrays not 2 dimensions number of dimensions. should able iterate through every element of every array no matter set up. with lodash can : var = [1, 2, 3, 5, 7], b = [1, [2, 3], [4, 5, [7]]]; var result = _.filter(_.flattendeep(b), function(item){ return a.indexof(item) === -1; }); console.log(result); $("body").append(json.stringif

javascript - Short hand for .parent().parent().parent() -

i have jquery function, needs position of element's parent. it looks like: function show(e) { //debugger; var nexttableselector = $(e).parent().parent().parent().parent().parent().parent().parent().parent(); } is there short hand traversing dom structure? something along lines of: $(e).parent()[5]; any suggestion? note dom structure generated 3rd party js framework, , i'm not able append additional id's or classes structure. i'm stuck having work way through dom way. if can't identify exclusively element want know fifth parent up, can $(e).parents().eq(5) or $(e).parents()[5] suggested.

openjdk - java.lang.UnsupportedClassVersionError: com/crawljax/cli/JarRunner : Unsupported major.minor version 51.0 -

i have downloaded program: wget https://github.com/crawljax/crawljax/releases/download/crawljax-3.6/crawljax-cli-3.6.zip unzip it: unzip crawljax-cli-3.6.zip get in folder , run: java -jar crawljax-cli-3.6.jar this error get: java -jar crawljax-cli-3.6.jar exception in thread "main" java.lang.unsupportedclassversionerror: com/crawljax/cli/jarrunner : unsupported major.minor version 51.0 @ java.lang.classloader.defineclass1(native method) @ java.lang.classloader.defineclass(classloader.java:643) @ java.security.secureclassloader.defineclass(secureclassloader.java:142) @ java.net.urlclassloader.defineclass(urlclassloader.java:277) @ java.net.urlclassloader.access$000(urlclassloader.java:73) @ java.net.urlclassloader$1.run(urlclassloader.java:212) @ java.security.accesscontroller.doprivileged(native method) @ java.net.urlclassloader.findclass(urlclassloader.java:205) @ java.lang.classloader.loadclass(classloader.java:323) @ sun.misc.launcher$appclassloader.load

java - Validate a String Using Xtext Validator -

i baby in using xtext , stuck in finding solution problem. have built xtext grammar of dsl , created web-based editor using ace. inject xtext validator module dependency in rest project , make validating dsl typed user on web interface. after validating it, want display error messages on web if there's any. otherwise, execute corresponding operations. what know need build dsl interpreter , export xtext project jar file. but, don't have idea interface of xtext allows me make use grammar rules validate inbound string? should translate string emf model first , use iconcretesyntaxvalidator.validateobject() function? if yes, give me example of how that? thanks in advance! appreciated! please check iresourcevalidator , validate method. that'll provide correct answer. iconcretesyntaxvalidator narrow usecase create objects in-memory means of constructor calls , setter invocation , want write these objects language syntax. not you're doing there.

c# - WPF Program Could not Find an Image, and then he didn't find all of them -

Image
i making game , have tons of images loaded content. when try , run game image not found. next time run game different image not found. tried going line line , fixing can't. i have custom made user controls have button on them , set background image using c#. public bitmapimage getbitmapofimage() { try { var = new bitmapimage(new uri(string.format("imgfolder/{0}.png", this.tostring()), urikind.relativeorabsolute)); return a; } catch (exception) { messagebox.show("erorr"); throw; } } tostring gives unique name gave file goes object. bitmapimmage used in next stage: var brush = new imagebrush(); brush.imagesource =item.getbitmapofimage(); this.item_button.background = brush; this.item_button.begininit(); this.item_button.endinit(); if can see problem here tell me because might not here, , think on else code m

css - Displaying an indeterminate checkbox with GWT Bootstrap -

i want able set bootstrap checkbox "indeterminate" status in gwt. wrote following code: /** * javascript give id'd element in form focus * * @param checkbox element manipulate * @param indeterminate true if indeterminate, false if not */ public static native void setindeterminate (element checkbox, boolean indeterminate) /*-{ checkbox.indeterminate = indeterminate; }-*/; running in chrome debugger tells me checkbox set indeterminate = true, still displays unselected. when display this page see indeterminate checkbox correctly, it's not browser problem. any suggestions on how fix this? why want jsni code that? you can use following checkbox checkbox = new checkbox("some-label"); checkbox.getelement().setattribute("indeterminate", true /*or false*/); edit just checked docs , blog posts. apparently, gwt doesn't support indeterminate in checkboxes. apparently there work around. whenever want indetermin

Mysql put duplicate rows of a query in 1 row -

i have table select `prodcutos`.`id`, `prodcutos`.`nombre`, `prodcutos`.`sku`, `prodcutos`.`marca`, `prodcutos`.`precio`, `prodcutos`.`imagen`, `prodcutos`.`descripcion`, `prodcutos`.`categoria1`, `prodcutos`.`categoria2`, `prodcutos`.`categoria3` `syscom`.`prodcutos`; with query duplicate sku diferente categoria2, categoria3 '2948', 'licencia', 'xpetbl', 'milestone', '1,999', 'xpetbl.png', 'description', 'cctv', 'nvr grabación', 'licencias' '3425', 'licencia', 'xpetbl', 'milestone', '1,999', 'xpetbl.png', 'description', 'cctv', 'software', 'grabación' can create query me next result '2948', 'licencia', 'xpetbl', 'milestone', '1,999', 'xpetbl.png', 'description', 'cctv', 'nvr grabación', 'licencias', 'cctv', 'software',

salesforce - Apex Triggers - Trailhead -

the code doesn't give errors, anytime run trailhead gives me message: "challenge not yet complete... here's what's wrong: executing trigger did not work expected. " here instructions: for challenge, need create trigger that, before insert or update, checks checkbox. if checkbox field true, sets shipping postal code (whose api name shippingpostalcode ) same billing postal code ( billingpostalcode ). the apex trigger must called accountaddresstrigger . the account object need new custom checkbox should have field label 'match billing address' , field name of match_billing_address . resulting api name should match_billing_address__c . with accountaddresstrigger active, if account has billing postal code , match_billing_address__c true, record should have shipping postal code set match on insert or update. my code: trigger accountaddresstrigger on account (before insert,before update) { for(account : [select id account match

html - Can't figure out how to combine nth-of-type selector with transitions -

i have series of divs have images in them. i'm alternating side of div image floats (1st div floats left, next floats right, , on). i'm trying make when user hovers on div, image smoothly transitions 1 end other. with have far, image switch sides, ignoring 1s transition i'm trying implement. i'm not quite sure i'm using transition affect nth-of-type selectors. see i'm doing wrong? .introcard { -webkit-transition: float 1s; transition: float 1s; } .introcard { color: white; font-size: 140px; margin: auto 80px; vertical-align: middle; line-height: 200px; } .introcard:nth-of-type(odd) .fa { float: left; } .introcard:nth-of-type(even) .fa { float: right; } .introcard:hover:nth-of-type(odd) .fa { float: right; } .introcard:hover:nth-of-type(even) .fa { float: left; } here's relevant html <div class="introcard"> <i class="fa fa-plus-circle"></i> <h1>create</h1> </

bash - linux command line text file manipulation -

let's have text file following contents: test blablabla test1 moreblabla atest blabla3 just*a*test blabla14 test88 lastblabla i want delete only line matches string "test" , line after without deleting lines contain string "test" in case want delete first , second lines not rest. the above file example, contents of file varies string. all examples found sed deal deleting lines contain string. want delete line is string. just add ^ , $ around test regex anchor match. sed -e '/^test$/,+1d' path/to/file or ^ *test *$ line containing 'test' possibly spaces.

javascript - Choose a file sporadic issue -

i using angularjs in nodewebkit application upload file. html has : <input type="file" id="fileinput" class="image-selector" name="image" accept="image/*" /> in desktop application, on clicking "choose file" there sporadic issues occur in windows: 1. not show folders in specific location. 2. if there 2 windows users , b, if user logged in currently, shows desktop/documents foloder of user b instead of a. this happened once every 10-15 times clicked on choose file. not sure sure if issue related nodewebkit or javascript or windows.

java - What is a NullPointerException, and how do I fix it? -

what null pointer exceptions ( java.lang.nullpointerexception ) , causes them? what methods/tools can used determine cause stop exception causing program terminate prematurely? when declare reference variable (i.e. object) creating pointer object. consider following code declare variable of primitive type int : int x; x = 10; in example variable x int , java initialize 0 you. when assign 10 in second line value 10 written memory location pointed x. but, when try declare reference type different happens. take following code: integer num; num = new integer(10); the first line declares variable named num , but, not contain primitive value. instead contains pointer (because type integer reference type). since did not yet point java sets null, meaning "i pointing @ nothing". in second line, new keyword used instantiate (or create) object of type integer , pointer variable num assigned object. can reference object using dereferencing operator . (a dot

r - Write data.frames to separate files -

i have result object includes 11 time series: > dput(res) structure(list(oenb_dependent = structure(c(1.02270390000001, -5.06831440000002, 0.665771299999989, 3.31613740000003, -2.15867040000001, -0.783362300000022, -0.22032089999999, 2.416144, -1.76254059999999, -0.156503700000002, -7.9803936, 9.45947149999999, -4.8104584, 8.48271070000001, -6.18952620000002, 1.42885950000002, 1.4896459, -0.419852200000008, -5.1583964, 5.25022940000001, 1.0567102, -1.09233420000001, -1.58522979999999, 0.606193599999997, -0.375233499999993, 2.50086640000001, -1.39997290000002, 2.28021660000002, -2.1468756, -1.4890328, -0.792543760000001, 3.21804705000001, -0.944078860000019, -0.278023159999989, -0.207530789999993, -1.12610048000001, 2.0883735, -0.742485400000007, 0.442037290000002, -1.48905938, 1.39644423999999, -3.89173769999999, 11.25665848, -9.22884035, 3.26856762, -0.00179540999998551, -2.39664325000003, 4.00455574000001, -5.60891295, 4.6556348, -4.40536951, 6.64234497, -7.347

java - Can I get rid of this switch and enum? -

i under impression piece of code cleaner somehow utilizing polymorphism, can't seem find proper way of doing it. tried using visitor pattern didn't manage far it. the "hero" class has switch: public class hero { private equipment equipment = new equipment(); // other fields public void equiparmor(armor armor) { findcorrespondingarmorslot(armor).equipitem(armor); } private itemslot findcorrespondingarmorslot(armor armor) { switch (armor.getarmortype()) { case shield: return equipment.offhand; case body: return equipment.body; case head: return equipment.head; case gloves: return equipment.hands; case boots: return equipment.feet; case belt: return equipment.waist; case amulet: return equipment.neck; case ring: return equipment.finger; case trinket:

ruby on rails - Encoding differences from active record to view -

the special characters come server not rendered right, ones in static text in html rendered ok. i have record in dev base. it's title 'légende'. [1] pry(main)> record.last.title record load (0.3ms) select "records".* "records" order "records"."id" desc limit 1 => "légende" [2] pry(main)> record.last.title.encoding record load (0.2ms) select "records".* "records" order "records"."id" desc limit 1 => #<encoding:utf-8> when want #show in view, prints le‘gende . it's not usual encoding problem, because doesn't print &eacute; or é . plus, if copy , paste le‘gende web page, becomes légende again. it's weird. records#show def show @record = record.find(params[:id]) end show.html.erb <h1>bibliothèque</h1> <h2><%= @record.title %></h2> config/application.rb config.i18n.default_locale =

javascript - Dynamically created mouse cursor? -

i have javascript/jquery project requires dynamically created labels used mouse pointer. there way change mouse cursor use dynamically created images? var mybase64label = createlabelpngbase64("hello world!", "#ff0000"); $("#pagecontainer").css("cursor","url("+mybase64label+"), auto"); make sure url() indicates mybase64label in fact base64-encoded. should url(data:image/png;base64,ivborw0kggoaasuh...) i'm guessing work: $("#pagecontainer").css("cursor","url(data:image/png;base64,"+mybase64label+"), auto"); check out example here .

Converting Java Object to XML in the order of Schema xml -

i have java object @xmlrootelement public class customer { private string name; private list<phonenumber> phonenumbers = new arraylist<phonenumber>(); private string id; private date startdate; private date enddate; public string getname() { return name; } public void setname(string name) { this.name = name; } @xmlelement(name = "phone-number") public list<phonenumber> getphonenumbers() { return phonenumbers; } public void setphonenumbers(list<phonenumber> phonenumbers) { this.phonenumbers = phonenumbers; } } i want define schema xml (customer.xsd) should used set order of tags while generating xml, object xml generated should below in different order compared object members order. <customer> <startdate></startdate> <enddate></enddate> <name></name> <id></id> <phonenumbers>&l

QT: SIGNAL & SLOT macro -

i'm beginner in qt , when tried use connect method bind signal , slot , refered examples found standard usage of connect(obj1,signal(signal(int)),obj2,slot(slot())) however when use connect(obj1,&obj1::signal,obj2,&obj2::slot) it worked , question occurs me did macro signal , slot ,did signal in class object belongs , return address of it? then why programmers use these macros instead of using &obj1::signal latter appears simpler , don't need edit code when changing parameter of signals . thanks answering. the use of signal , slot macros used way make connections, before qt 5. connection made @ runtime , require signal , slots marked in header. example: - class myclass : public qobject { q_object signals: void signal(); slots: void aslotfunction(); }; to avoid repetition, way in works described in qt 4 documentation . the signal , slot mechanism part of c++ extensions provided qt , make use of meta

javascript - Stop timeout within a function from another function -

function one(){ settimeout(function(){ two(); },3000); } function two(){ settimeout(function(){ one(); },3000); } function stop(){ alert('this should run,and functions above should stop'); } i want stop autorun of first 2 functions,when click on third. now,if click on third,the alert shows up,but loop continue.any way of doing this? var onetimeout, twotimeout; function one(){ onetimeout = settimeout(function(){ two(); },3000); } function two(){ twotimeout = settimeout(function(){ one(); },3000); } function stop(){ cleartimeout(onetimeout); cleartimeout(twotimeout); alert('this should run,and functions above should stop'); }

python - sqlite insert or ignore always inserts on empty field -

i getting multiple inserts when field empty despite using insert or ignore primary key. tried adding unique index, sure. want new inserts when primary key not equal existing row. according sqlite.org/nulls.html nulls distinct in unique column these duplicate inserts should not happen. i'm doing insert: insert or ignore facts ( created, inserted, author, kind, what, field, val ) values (?, ?, ?, ?, ?, ?, ?) with table: create table if not exists facts ( created text, inserted text, author text, kind text, text, field text, val text, primary key(created, author, kind, what, field, val) ) and getting result after doing same inserts multiple times: sqlite> select * facts what='vot1dafjt95326qvs8kn' order inserted; 2014-01-29t09:30:44.000000|2015-07-23t13:23:10.643060|test_user_id|taskfact|vot1dafjt95326qvs8kn|created|2014-01-29t09:30:44.000000 2014-01-29t09:30:44.000000|2015-07-23t13:23:10.643152|test_user_id|taskfact|vo

osx - Set CMake to use dyld options instead GNU ld options under OS X -

i try to port linux software os x (yosemite) uses cmake built. modification made, direct homebrew installed gnu gcc , g++ when executing cmake . if use existing cmakelists.txt, build process stops following error: ld: unknown option: --start-group collect2: error: ld returned 1 exit status make[2]: *** [lib/somelib.dylib] error 1 make[1]: *** [lib/somelib.dir/all] error 2 make: *** [all] error 2 obviously --start-group option gnu ld , not dyld, os x ld derivate. installing gnu ld on os x not possible, answered here . how can set cmake use dyld options instead?

html - How to change order of files in multiple file input? -

the files ordered alphabetically default; there way upload them in order chosen in file picker instead? i want able select primary file , other files in same input without having submit more 1 input/time. the files not ordered alphabetically. lined in order of appearance in file picker (at least how current chrome , firefox work on windows 7). had them sorted name in picker. i don't think you're asking possible. either: instruct user make sure primary file first in list (however, believe there no guarantee of order browsers). create separate input element primary file. (recommended) display file names (and/or content) , allow user select file wishes primary. store information in hidden field javascript.

objective c - Should NSNotificationCenter selector be with or without an NSNotification object -

i'm doing code cleanup , wondering if there official or unofficial standard option below should preferable. the basic issue have view change logic. code should called both in awakefromnib , whenever notification received. prevent writing same code twice option below preferable. // option 1 - (void)receivethemechangenotification:(nsnotification *)note { [self updateinterfacewiththeme]; } - (void)updateinterfacewiththeme { } - (void)awakefromnib { [self updateinterfacewiththeme]; } // option 2 - (void)receivethemechangenotification:(nsnotification *)note { [self updateinterfacewiththeme]; } - (void)awakefromnib { [self receivethemechangenotification:nil]; } // option 3 // registered selector notification directly - (void)updateinterfacewiththeme { } - (void)awakefromnib { [self updateinterfacewiththeme]; } answer pretty simple : if want send data notification ( e.g. id , playerobject , name , anything ) use nsnotificati

symfony - Symfony2 app.request.get('_route') is empty when throw new AccessDeniedException -

i'm working on implementing role based admin application. have custom voter , @ point i'm doing like: if($role && voterinterface::access_granted !== $voteresult) { throw new accessdeniedexception('unauthorized access!'); } and result custom error403.html.twig template rendered. far good. the error403 template extends main template in @ point i'm building menu using app.request.get('_route') generating links. the problem app.request.get('_route') null . xdebug-ing issue i've noticed somehow $request->attributes->parameters array not contain _route or _route_params keys. any thoughts? the problem symfony uses sub-request rendering error pages. doesn't need router , have not exatly same request object in master request. github issue https://github.com/symfony/symfony/issues/5804 same question on so app.request.attributes.get('_route') empty when override 404 error page some theor

Reading property file in java using Spring -

have been trying understand how load property file using spring in java , populate java.util.properties object. use newly created property object constructor arguement bean. appreciate pointers on this. thanks, cabear to load properties file in spring use propertiesfactorybean make easier use there properties tag in util namespace can use. <util:properties id="props" location="location-of.properties" /> then have bean named props can use regular bean. <bean id="otherbean" class="my.app.myclass" > <constructor-arg ref="props" /> </bean> when using property placeholder support use same properties object again instead of loading again, referencing using properties-ref attribute of property-placeholder tag. <context:property-placeholder properties-ref="props" />

javascript - How to test if an element inside a "carousel" (a container with overflow:hidden" having multiple large children) is visually visible? -

i'm looking generic (native) javascript function tell if element visible, can take account elements in "carousel" (aka "slider"); these containers "slides", each element positioned left (or right) of previous 1 - 1 of them visible. example can seen in web page: http://www.technobuffalo.com/2015/07/22/iphone-7-concept-sports-quad-hd-retina-display-wireless-charging/ edit: example carousel 3 slides: <div class="carousel"> <div class="slide" style="left:0"><img src="..." /></div> <div class="slide" style="left:640px"><img src="..." /></div> <div class="slide" style="left:1280px"><img src="..." /></div> </div> <style> .carousel { width: 640px; height: 460px; overflow: hidden; } .slide { position: absolute; width: 100%;

javascript - Undefined upon get Request in Backbone -

i try execute operation "put" using backbone. fetchs records server. neighter where nor get method retrieve solution (result of console.log of code below [] ) can edit (using set ) , can save . solution can simple still don't realize wrong! var model = backbone.model.extend({ idattribute : "id" }); var todoscollection = backbone.collection.extend({ model : model, url : myurl }); var todos = new todoscollection(); todos.fetch(); var todo = todos.where({ id : 2 }); console.log(todo); todo.set('name', 'changedname'); todo.save(); you need parse response , specify models are. for better reference if stumbles on this. like { "location": "uk", "users": [ {id: "etc", name: "etc"}, {id: "etc", name: "etc"}, {id: "etc", name: "etc"} ] "someothermeta": "score",

Formula in Excel to find cell's value, which is a sub-string of a given string -

all. just in case if have seen kind of problem before and/or can think elegant solution… i looking formula cell e3, that’ll fill first matching id of requirement, if it’s listed in “linked items” column of defects table , reqid column of table requirements. image illustrate or sample excel file . p.s.: know 1 solution, it’s not elegant 1 , provided have thousands of records in both tables, makes whole excel file huge , not usable on normal pc (3gb of memory , cpu resources consumed when 178mb file open). possible solution in this file . it's not ideal assumes 1. list of linked items comma-delimited 2. there not more 10 items linked 1 defect…

Take non null value to do the inner join in sql -

i have code here: select c.case_code,coalesce(c.case1, c.case2) case_def,aspm.userid cases c left join aspnet_membership aspm on c.case_def = aspm.userid and well, since there alias in on clause, won't recognize case_def. what need is, need take non null value between case1 , case2 , need left join in query. how do this? in advance. select c.case_code,coalesce(c.case1, c.case2) case_def,aspm.userid cases c left join aspnet_membership aspm on coalesce(c.case1, c.case2) = aspm.userid you can't specify alias used in select clause elsewhere in query. however, dbms' accept that.

c# - The System cannot find the path specified for some crystal reports -

i using crystal reports latest edition in mvc application. 1 report working fine weird error occurring continuously in loading other reports. have used switch statement. report in first case running fine. in other cases there error: an exception of type 'system.runtime.interopservices.comexception' occurred in myapp.dll not handled in user code additional information: the system cannot find path specified. public actionresult seereport(formcollection f) { reportdocument rd = new reportdocument(); string s = f["rptname"]; switch (s) { case ("011501"): { dataset ds = new dataset(); commonprocs_ahpi.commonprocess xrptprocess = new commonprocs_ahpi.commonprocess(); ds.extendedproperties["index"] = 1150101;//13502 013501_3 datatable xdtr = new datatable(); xdtr.tablename = "_rptitle_"; xdtr.columns.add("n100", system.ty

c# - How to bind dynamic text to a viewmodel other than using a hidden HTML control -

how bind dynamic text view model? i have product page. each variation of product has specific sku (stock keeping unit) . example (these examples): green shirt have sku of greenshirt-001 blue shirt have sku of blueshirt-001 when page loads first time load different colours product ( shirt ) , default sku, lets default sku greenshirt-001 . user see greenshirt-001 text on page. when user selects colour, example blue shirt, need go , stuff on server , display information blue shirt. blueshirt-001 displayed text on page. there add cart button on page. when user clicks button want variation of product added shopping cart. retrieve sku being displayed user. what best way of displaying sku user , retrieving when form posted? can't think of way display html control , retrieve value on post other using hidden control? @using (html.beginform("details", "product", formmethod.post, new { role = "form" })) { <div class="produ

java - MongoDB aggregation result as a nested Json -

this piece of mongodb collection : { "_id" : objectid("55b0ba203a20b54e3b1e09e4"), "i" : 0, "x" : 1, "id" : 2, "info" : { "j" : 0 } } { "_id" : objectid("55b0ba203a20b54e3b1e09e5"), "i" : 1, "x" : 2, "id" : 2, "info" : { "j" : 1 } } { "_id" : objectid("55b0ba203a20b54e3b1e09e6"), "i" : 2, "x" : 3, "id" : 2, "info" : { "j" : 2 } } { "_id" : objectid("55b0ba203a20b54e3b1e09e7"), "i" : 3, "x" : 4, "id" : 2, "info" : { "j" : 3 } } { "_id" : objectid("55b0ba203a20b54e3b1e09e8"), "i" : 4, "x" : 5, "id" : 2, "info" : { "j" : 4 } } { "_id" : objectid("55b0ba203a20b54e3b1e09e9"), "i" : 5, "x" : 6, "id

alloy - Is using util/ordering exactly the same as axiomatizing a total order in the usual way? -

the util/ordering module contains comment @ top of file fact bound of module parameter constrained have exactly bound permitted scope said signature. i have read few times ( here instance) optimization allows generate nice symmetry-breaking predicate, can grasp. (btw, respect the said post , right infer exactly keyword in module parameter specification here enforce explictly exact bound (while implicit in pre-4.x alloy versions)?) however, comment contains part not seem refer optimization issue has semantic flavour: * technical comment: * important constraint: elem must contain atoms permitted scope. * let analyzer optimize analysis setting fields of each * instantiation of ord predefined values: e.g. setting 'last' highest * atom of elem , setting 'next' {<t0,t1>,<t1,t2>,...<tn-1,tn>}, n * scope of elem. without constraint, might not true ord.last * subset of elem, , domain , range of ord.next lie inside elem. so, not understa

javascript - How to Store List of selected value from multiselect dropdown list in array in asp.net? -

i used bootstrap multiselect dropdown item, in if select many values select first values, whats wrong in code logic. asp dropdown list <asp:dropdownlist width="320px" id="drplstgetdb" runat="server" multiple="multiple"> </asp:dropdownlist> javascript enable multiple check feature bootstrap. $(function() { $('[id*=drplstgetdb]').multiselect({ includeselectalloption: true }); }); c# code store in array. int[] stopwordarray = new int[drplstgetdb.items.count]; foreach(listitem listitem in drplstgetdb.items) { if (listitem.selected) { int = 0; stopwordarray[i] = convert.toint32(drplstgetdb.items[i].value.tostring()); i++; } } i getting first checked value in array, if don't use if if (listitem.selected) can store values in array. can suggest error,, specially selected logic. or alternative this.. because setting int = 0 inside loop, s

Google protocol buffer compiling error in cygwin -

i installed protobuf on cygwin , did test (make check). tests successful. when try compile example file, error. /tmp/ccffz4qk.o:add_person.cc:(.rdata$.refptr._zn6google8protobuf8internal13empty_string_e[.refptr._zn6google8protobuf8internal13empty_string_e]+0x0): undefined reference `google::protobuf::internal::empty_string_' /tmp/ccjplpok.o:addressbook.pb.cc:(.text+0xee3): undefined reference `google::protobuf::internal::wireformatlite::writestringmaybealiased(int, std::string const&, google::protobuf::io::codedoutputstream*)' /tmp/ccjplpok.o:addressbook.pb.cc:(.text+0xee3): relocation truncated fit: r_x86_64_pc32 against undefined symbol `google::protobuf::internal::wireformatlite::writestringmaybealiased(int, std::string const&, google::protobuf::io::codedoutputstream*)' /tmp/ccjplpok.o:addressbook.pb.cc:(.text+0x1060): undefined reference `google::protobuf::io::codedoutputstream::writestringwithsizetoarray(std::string const&, unsigned char*)' /tmp/c

javascript - CSS transitions for content loading -

Image
i'm implementing animations on html5 project css3 , far good. can do, example: #somedivid { position: absolute; background:rgba(255,0,0,0.75); transition: 0.7s ease-in-out; -moz-transition: 0.7s ease-in-out; -webkit-transition: 0.7s ease-in-out; -o-transition: 0.7s ease-in-out; } #somedivid:hover { background:rgba(255,0,0,1); } and change opacity of red div 0.75 1 . work other properties of div on hover too, color attribute or border-radius . my problem comes attributes changed automatically when manipulate dom javascript , change in height or width happens when src added img or if content added div . for image case, have folowing css: .someimageclass { border-color: white; border-width: 15px; border-style: solid; max-height:370px; max-width:370px; transition: 0.7s ease-in-out; -moz-transition: 0.7s ease-in-out; -webkit-transition: 0.7s ease-in-out; -o-transition: 0.7s ease-in-out; } and im