Posts

Showing posts from May, 2010

java - JMock Allow Other Method Calls -

i'm using jmock test behavior of class using object. want test method a() called. however, b() , c() called on object too. therefore if expectations expect a() , must expect b() , c() make test pass. there way test method, , allow else? expect a() allow methods b() & c() mockery.checking(new expectations() {{ one(mockobject).a(); allowing(mockobject).b(); allowing(mockobject).c(); }}); expect a() allow other methods. mockery.checking(new expectations() {{ one(mockobject).a(); allowing(mockobject); }});

javascript - Access one controller inside another in SAPUI5 -

i have sapui5 master detail page application. in master page controller need access element defined in detail view. how can it? jquery.sap.require("util.formatter"); jquery.sap.require("util.networkaccess"); sap.ui.controller("view.sales.salesorder.somaster", { myfunc: function() { var icontabbar = this.byid('itabbar'); icontabbar.setselecteditem(icontabbar.getitems()[1]); } }) the above code through error because itabbar element not there in master view, it's defined in detail view file. i not sure know trying do, controls have unique id's prefixed view, try var icontabbar = sap.ui.getcore().byid("vwdetails--itabbar")

html - Basic JavaScript validation not working -

i'm trying make simple form javascript validation. has 4 fields: title, email address, rating , comments. far know, code have here should work validate form , should not allowed submit whenever press submit button none of prompts appear , browser submits form. let me know going wrong please? i'd imagine there simple solution or forgetting i'm pretty new apologies if it's obvious. the html , javascript code is: <html> <head> <script type="text/javascript"> function validateform() { var e=document.forms["review"]["title"].value; var s=document.forms["review"]["email"].value; var t=document.forms["review"]["rating"].value; var c=document.forms["review"]["comments"].value; var atsym=s.indexof("@"); var dotsym=s.lastindexof("."); if...

How to connect android app to google cloud storage via JSON API -

i have problem connect android app google cloud storage. want connect via json api, can't use google authorization this. i generated api key. in internet found, should on manifest .xml: <meta-data android:name="??????" android:value="my_api_key" /> but don't know, should put on: android:name="??????" can me? `"meta-data contains name-value pair item of additional, arbitrary data can supplied parent component" a meta-data made of following: android:name: unique name item. ensure name unique, use java-style naming convention — example, "com.example.project.activity.fred". android:resource: reference resource. id of resource value assigned item. id can retrieved meta-data bundle bundle.getint() method. android:value: value assigned item. data types can assigned values , bundle methods components use retrieve values listed in following table: source . you supposed us...

c# - Datasource says not binding to IList...but I am aren't I -

i getting: data source invalid type. must either ilistsource which straight forward. need binding collection such list instead of single item...only think binding list not understanding? my collection object singleton such: public class calendarevents { private static calendarevents _calendareventshandle; internal list<calendarevent> abcd_calendarevents { get; set; } //seal constructor private calendarevents() { this.abcd_calendarevents = new list<calendarevent>(); } internal static calendarevents calendareventshandle { { if(_calendareventshandle == null) { _calendareventshandle = new calendarevents(); } return _calendareventshandle; } } } my handle assignment: calendarevents eventscal = calendarevents.calendareventshandle; populating collection: eventscal.abcd_calendarevents.add(new calendarevent(...)); //40...

sql - Detect when a record is inserted or updated in oracle materialized view -

when updating existing record, deleted materialized view , re-inserted? my problem update existing record , trigger being executed. want trigger fired new records. i'm working oracle materialized view. have trigger like: create or replace trigger my_view_trigger after insert on my_materialized_view each row begin --handle new record end; i have tried changing "after insert" part "after insert or update" , had body in begins block like: if inserting --handle new record elseif updating --handle modification of existing record end if; but every update seen insert. there way detect updates in materialized view? have considered materialized view logs? there seeded functionality around monitoring tables materialized view dependent on using materialized view log files (explicitly designed purpose). for instance, have log file oracle apps table,inv.mtl_system_items_b. next, if want monitor dml chang...

php - Using HTML file type in JavaScript -

this question has answer here: html5 ajax multiple files upload 1 answer how can upload files asynchronously? 25 answers does know how manage <input type="file" id="myfile" /> in javascript can send file php code? i have this: <input type="file" id="myfile" /> <input type="button" value="file" onclick="usefile()" /> then, in javascript want use file user uploaded because want use in php code. how file , send php parameter? function usefile() { var myfile = document.getelementbyid("myfile"); //does work? // how send php? } i hope me. thanks lot. can submit form? if so, it's simple. here's html: <form method="post" action="mys...

xslt function to generate number which is based on attributes of aother element -

i trying convert xml quirky formats html. i have this <spec_span span_start="c2" span_end="c9" span_name="ab12" /> ... <table_entry span_name="ab12">text value</entry> i trying convert <td colspan="8">text value</td> roughly needs done is. look span_spec id ab12 strip 'c' prefix span_start , span_end subtract integer value left in span_start span_end add 1 final value. i think should possible write function of sort it. string manipulation type casting , maths in xslt not sure about. roughly needs done is. look span_spec id ab12 strip 'c' prefix span_start , span_end lookup in xslt best done using key . , stripping out known character easy using translate() function. place @ top of stylesheet, outside of template: <xsl:key name="spec_span" match="spec_span" use="@span_name" /> then apply input ...

Set global Datetime offset for Azure website -

i have azure website have datetime set gmt + 0. of users located in gmt +2. is there simple way how set time offset globaly on application startup datetime values rendered correct offset? it depends on programming language provides. example, in php, can use date_default_timezone_set . however, in .net , many other languages, there no way change default time zone - use local time zone of machine it's running on. it's azure sets it's time zones utc. it's not server application or web site depend on time zone settings of computer it's running on. should rely on features of language write application such in control of time zone functionality. example, in .net, can use timezoneinfo convert times time zone wish.

c++ - Make and Re-Compiling Headers with Sub-Directories -

there few different questions related i'm trying do, such this , this , , this . however, i've looked @ there , link , i'm still not able work. i have following make file (i had here ). builds .os in build directory .cpps in source directory. want adjust if headers updated, re-compiles don't have make clean whole thing (most particularly ones inc_dir1 folder). cc = g++ cflags = -g -wall inc_dir1 = include inc_dir2 = c:/cppfiles/cpp_extra_libraries/armadillo-4.200.0/include inc_dir = $(inc_dir1) $(inc_dir2) includes = $(foreach d, $(inc_dir), -i$d) build_dir = build src_dir = test src = $(wildcard */*.cpp) vpath = $(src_dir) objs = $(addprefix $(build_dir)/, $(notdir $(src:.cpp=.o))) main = armadillo_extra_functions_test .phony: depend clean all: $(build_dir) $(main) @echo compilation complete $(build_dir): mkdir -p $@ $(build_dir)/%.o: %.cpp $(cc) $(cflags) $(includes) -c $< -o $@ $(main): $(objs) $(cc) $(cflags) $(includes) -o ...

jsf - PrimeFace ajax resets all p:inputText -

hello friend iam trying use primeface ajax enable/disable submit button , works fine except resets p:inputtext . here code:- <p:inputtext value="#{loginto.emailaddress}" id="emailadd" tabindex="1" required="true" maxlength="50" requiredmessage="#{apploginparameter['apploginemailrequiredmsg']}" validatormessage="#apploginparameter['apploginemailincorrect']}"> </p:inputtext> <p:selectbooleancheckbox id="esignaturecheckbox" value="#{loginto.userlogindetailto.resetesignflag}" rendered="true" styleclass="acc-lable-name-check1"> <p:ajax event="change" update="submitbutton"></p:ajax> </p:selectbooleancheckbox> please me on iam new in primefaces. you missing opening { in: validatormessage="#apploginparameter['apploginemailincorrect...

php - Redirecting to a page after ajax post. And then accessing values from $_SESSION: session is empty -

i'm posting 3 arrays of data php file(checkout.php) on server via jquery post. $.post("checkout.php", {items_name : json.stringify(items_name), items_price : json.stringify(items_price), items_amount : json.stringify(items_amount)}, function(data){ console.log(data); //those 3 arrays(items_name, items_price & items_amount }); window.location.href = "checkout.php"; then receive data arrays in checkout.php , store them in $_session. $items_name = json_decode($_post['items_name']); $items_price = json_decode($_post['items_price']); $items_amount = json_decode($_post['items_amount']); session_start(); $_session['items_name'] = $items_name; $_session['items_price'] = $items_price; $_session['items_amount'] = $items_amount; when page redirects checkout.php after making jquery post, when try access data session, doesn't show anything. session_start(); print_r($_session); where doing wrong? ...

cypher - neo4j LOAD CSV with Tabs -

i trying load csv , create nodes in neo4j 2.1.0 using following: using periodic commit load csv "file://c:/temp/listings.txt" line fieldterminator '\t' create (p:person { id: line[0] }); the columns separated using 0x9 (tab) characters. created nodes have entire row content in id. any appreciated. try fieldterminator '\\t' that's worked me

Constant arrays in Java -

i have move class, immutable (basically it's 2 ints). the have class moves constants: public class moves { public static final move nw = move.make(-1, -1); public static final move n = move.make(0, -1); public static final move ne = move.make(1, -1); public static final move e = move.make(1, 0); public static final move se = move.make(1, 1); public static final move s = move.make(0, 1); public static final move sw = move.make(-1, 1); public static final move w = move.make(-1, 0); public final static move[] = { nw, n, ne, e, se, s, sw, w }; public final static move[] cardinal = { n, e, s, w }; } i need arrays methods such as: public void walktorandomside(move[] possiblemoves) it works nicely, - - elements of all , cardinal can changed anytime anyone. know elements cannot made final, of course. that bad - want part of library , stable , predictable possible. how work around this? make method crea...

python - Query items in nested dictionaries with wildcards -

i trying retrieve items in nested dictionaries , print them out text game coded python 3 wildcards. here dictionary: dict = { "ninja1": { "no": "there map under blue rock" }, "amy": { "yes": "the peasant's name ato" } } i loop through dictionary , print strings (like: 'there map..) if key 'yes'. for key in dict: if dict[wildcard] == 'yes': print (dict[wildcard]['yes']) i new @ this, i'm sure codes horrible. appreciated! all need test presence of key; use in operator: for key in yourdict: if 'yes' in yourdict[key]: print(yourdict[key]['yes'])

c# - How to query for all EntityA that contain any EntityB within a collection of EntityBs? -

given following 2 example c# entity classes ... class entitya { public int entityaid { get; set; } public virtaul icollection<entityb> bs { get; set; } } class entityb { public int entitybid { get; set; } public string foobar { get; set; } public virtual entitya { get; set; } } how go using entity framework + linq query entitya contain entityb within provided collection of entityb ? to clarify, if have following subset of entityb ... var bs = new list<entityb> { new entityb { foobar = "a" }, new entityb { foobar = "b" }, new entityb { foobar = "c" } }; i want find entitya entitya.bs collection contains of possible entityb within above bs collection. so when asked thought meant had dbset of entityb. see you're trying find entitya entityb defined in given set, can simplify this: var bs = collection of entityb var dbset = dbset of type entitya var entities = dbset.where(m => m.bs.any(b => ...

c++ - Where and why do I have to put the "template" and "typename" keywords? -

in templates, , why have put typename , template on dependent names? dependent names anyway? have following code: template <typename t, typename tail> // tail unionnode too. struct unionnode : public tail { // ... template<typename u> struct inunion { // q: add typename/template here? typedef tail::inunion<u> dummy; }; template< > struct inunion<t> { }; }; template <typename t> // last node tn. struct unionnode<t, void> { // ... template<typename u> struct inunion { char fail[ -2 + (sizeof(u)%2) ]; // cannot instantiated u }; template< > struct inunion<t> { }; }; the problem have in typedef tail::inunion<u> dummy line. i'm inunion dependent name, , vc++ quite right in choking on it. know should able add template somewhere tell compiler inunion template-id. exactly? , should assume inunion class template, i.e. inunion<u> names type , ...

java - Android saving state of checkbox if exit app -

i have 5 checkboxs , when clicked set boolean in abstract class true or false using oncheckedchangelistener. example: checkbox.setoncheckedchangelistener(new oncheckedchangelistener(){ @override public void oncheckedchanged(compoundbutton buttonview,boolean ischecked) { if(ischecked) { checkboxdata.checked = true; } else if(!ischecked) { checkboxdata.checked = false; } } }); however when leave app , return checkboxes not clicked anymore, yet boolean values still true. how can make app remember check boxes clicked.? should check boolean values in main activity oncreate , set checkboxs checked or not or there better/faster way make app remember checkboxs states? just added in main activities oncreate method: if(checkboxdata.checked) { checkbox checkbox = (checkbox) ...

ios - The upgrade procedure failed when testing iAPs...? -

when try test in-app purchase error "please check internet connection , app store account information" pop in app. using test account , have transferred device, still no solution. what recreate glitch: run application on simulator or on device click on iap - purchase works sign in using test account the pop denies me iap, reading "the upgrade procedure failed" followed "please check internet connection , app store account information". i've searched internet hours on end no success, know cause/solution of this?

asp.net mvc - Glimpse seems to be hanging my browsers -

i've update web projects mvc5 , latest glimpse (asp.net 1.9,1.85 core , 1.53 mc5). when run remoted production server, hangs browser. is there known problem here? how can figure out going on? thanks there isn't outstanding known issue. the best thing use browser's f12/networking tools determine size of /glimpse.axd?n=glimpse_request&requestid=... request. if json response large, may causing browser work little hard. can reduce size of payload removing tabs aren't using.

javascript - Authenticating to the Google Analytics Core Reporting API for One Account -

i want display number of times video has been viewed using core reporting api via javascript. however, api designed oauth, building applications , not logging account event count. is there way login account via javascript? thanks, matthew. i think looking service account . knowledge cant use service account javascript due security issues key file. what try , authenticate script once using normal oauth2 save refresh token file , hard code script , send that. wouldn't recommend checks script able access it. have same security issues had using service account. as can see doing trying javascript isn't going work. can see have tried unsuccessfully in past do. recommend try , kind of server sided scripting language, php.

functional programming - How to understand Bird and Hughes foldr -

got lost trying understand charles bird's introduction functional programming john hughes' why functional programming matters . discussion of foldr . length = foldr count 0 count n = n + 1 when applied list, say, [1, 2, 3], should come 3. here's bird (p 66): (#) = foldr oneplus 0 oneplus x n = 1 + n and here's more lambda treatment: length = foldr (λx.λn.(1 + n)) 0 i'm @ loss understand what's going on foldr once start trying apply list [1, 2, 3]. i'm not seeing variables x , n refer to. simple 1 sum: sum = foldr (+) 0 for [1, 2, 3] is (+) 1 ((+) 2 ((+) 3 0)) = 6 using hughes' notation of replacing list's implied cons function/operator , identity list's implied nil, (prefix) adding -- understand. not when dealing these mysterious variables. maybe can walk me through how list , variables interact. the arguments function passed foldr element of list being folded on , accumulator (essentially, thing being ca...

type error in Alloy -

i have alloy specification represent subset of java programming language. below have part of model: abstract sig type {} 1 sig void_ extends type {} abstract sig primitivetype extends type {} 1 sig int_, long_ extends primitivetype {} sig method { id : 1 methodid, param: lone type, acc: lone accessibility, return: 1 type, b: 1 body }{ (return=void_) => ( ( (b=constructormethodinvocation) => (b.cmethodinvoked).return = void_) || ( (b=methodinvocation) => ((b.id_methodinvoked).return = void_) ) ) } abstract sig body {} sig methodinvocation extends body { id_methodinvoked : 1 method, q: lone qualifier } sig constructormethodinvocation extends body { id_class : 1 class, cmethodinvoked: 1 method }{ this.@cmethodinvoked.acc != private_ this.@cmethodinvoked in ((this.@id_class).*extend).methods } in c...

ios - Loading data from api to tableview -

i need load large set of messages backend api tableview ios chat app.each time reload data whole list populated.how more without loading whole list ? load last 20 messages , when user scrolls fetch next 20(last 40 messages) backend. appreciated. thanks i dont know how go this. imagine call api - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath in way call api every time cell on screen. problem approach how ever calling api every time cell goes in , out of screen.

rubygems - ruby sass, unable to resolve dependancies -

i downloaded 2 gem files: sass-3.3.7.gem & compass-0.12.6.gem i ran gem install --local sass-3.3.7.gem installed. followed same command compass , got error: unable resolve dependencies: compass requires sass (~>3.2.19) i'm installing them pre-downloaded have no connection. knows can solution? compass 0.12.6 apparently depends on sass ~>3.2.19, means version of sass should bigger 3.2 , smaller 3.3, compass needs sass 3.2.x. have 2 options. also download sass 3.2.19, install both versions of sass, use latest 1 , make compass happy. just install sass 3.2.19 , use well, works if don't need features introduced in sass 3.3.

ios - Apple Push notifications for distribution -

in app using apple push notifications. followed raywenderlich development tutorial . able send , receive push notifications, development only. want submit app @ app store. need easy tutorial above (apns)distribution. please me. thanks. using ios7 , xcode 5. find following lines in simplepush.php ssl://gateway.sandbox.push.apple.com:2195 and replace following ssl://gateway.push.apple.com:2195 make sure have generated certificate , key production

timer - Stop time automatically in Javascript using clearTimeout() -

i creating pong game using webgl, trying when ball touches wall want stopwatch stop automatically. here code of timer: var h4 = document.getelementsbytagname('h4')[0], seconds = 0, minutes = 0, hours = 0, t; function add() { seconds++; if (seconds >= 60) { seconds = 0; minutes++; if (minutes >= 60) { minutes = 0; hours++; } } h4.textcontent = (hours ? (hours > 9 ? hours : "0" + hours) : "00") + ":" + (minutes ? (minutes > 9 ? minutes : "0" + minutes) : "00") + ":" + (seconds > 9 ? seconds : "0" + seconds); } function timer() { t = settimeout(add, 1000); } and here code when want stop timer, can stop ball how stop timer? if (ball.position.x <= -fieldwidth/2 && ball.position.x >= fieldwidth/2){ ballspeed = 0; ... } just call function cleartimeout(myvar); , myvar in sample t on w3schools.com have example http://www.w3s...

c# - GIF image issues with PictureBoxes -

i newbie here , appreciate help. i creating mdi project in visual c#. there 1 child form, while 1 parent form can hold maximum of 4 child forms same type. in each of child form, there 150 pictureboxes, if run program, have total of 600 pictureboxes. now want load moving image every pictureboxes. question is, why of them animation? control focus problem( because when click on 1 of form child, 150 pictureboxes in form , other form animation), or other problem maybe?

assembly - What is a branch taken stall? -

Image
i'm analyzing simple assembly program winmips64 , in 1 moment program has branch taken stall, don't know why , type of stall is. have been searching on internet , found related "prediction stalls", didn't understand it. in picture can see 1 of moment when branch taken stall produced. thanks in advance :) a branch taken stall stall when branch taken :-) the core reason instruction prefetch , multiple instructions in stream processed in parallel. see pipeline picture in simplest form, while instruction n in stream executing, next (n+1) decoding. machine executes 1 instruction ever clock on average, in reality instruction takes 2 clock (one clock decode, 1 clock execute). netburst architecture (pentium 4/d) notorious having deep pipelines. (and horrible penalties if mispredicted) if branch (go different instruction next), instruction on target address hasn't decoded yet. therefore must decoded first, , execution of instruction takes 2 cl...

javascript - Links inside highlight.js code -

i'm using highlight.js show code on website. make parts of highlighted code links. link not processed , represented code. this how code highlighted: <xml attribute="value">my <a href="test.html">xml content</a> should clickable (link)</xml> but have this, , word content link: <xml attribute="value">my content should clickable (link)</xml> i use highlight.js specified in documentation this: <script src="highlight.pack.js"></script> <script>hljs.inithighlightingonload();</script> <pre><code id="mycode"><xml attribute="value">my <a href="test.html">content</a> should clickable (link)</xml></code></pre> how can use links inside highlighted xml code? information! found out problem occurs because i'm changing content ajax call receive json containing whole code: $.ajax({ ...

php mkdir folder tree from array -

i'm trying create folder tree array, taken string. $folders = str_split(564); 564 can number. goal create folder structure /5/6/4 i've managed create folders in single location, using code inspired thread - for ($i=0;$i<count($folders);$i++) { ($j=0;$j<count($folders[$i]);$j++) { $path .= $folders[$i][$j] . "/"; mkdir("$path"); } unset($path); } but way folders in same containing path. furthermore, how can create these folders in specific location on disk? not familiar advanced php, sorry :( thank you. this pretty simple. do each loop through folder array , create string appends on each loop next sub-folder: <?php $folders = str_split(564); $pathtocreatefolder = ''; foreach($folders $folder) { $pathtocreatefolder .= directory_separator . $folder; mkdir($folder); } you may add base path, folders should created initial $pathtocreatefolder . here you'll find demo: http://c...

python yaml.dump format list in other YAML format -

i want dump python object yaml file this: a: 5 b: 6 c: 7 d: [ 1,2,3,4] but not a: 5 b: 6 c: 7 d - 1 - 2 - 3 - 4 image d massive list, output gets messy humans see. i use: default_flow_style=false uses new line list item format. i use customer dumper stop anchors. is following result meeting expectations? >>> import yaml >>> dct = {"a": 5, "b": 6, "c": 7, "d": range(60)} >>> print yaml.dump(dct) a: 5 b: 6 c: 7 d: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59] note, linebreaks added yaml , not me.

C# VLC COM Player Hide Controls -

Image
i using vlc axvlcplugin2 type play movies inside winforms applications. works easy enough, want able play , stop individual movie files. however, want user not know there's player there. ideally totally chromeless , not react hover or clicks. is there way hide ui stuff player includes?

How to get list of podcast episodes from an album (iTunes Search API) -

i'm trying obtain list of podcasts episodes itunes search api. i'm able make call api , podcast albums based on search term: https://itunes.apple.com/search?media=podcast&term=nerdcast this returns following json (cropped): { "resultcount": 20, "results": [ { "wrappertype": "track", "kind": "podcast", "collectionid": 381816509, "trackid": 381816509, "artistname": "nerdcast", "collectionname": "nerdcast", "trackname": "nerdcast", "collectioncensoredname": "nerdcast", "trackcensoredname": "nerdcast", "collectionviewurl": "https://itunes.apple.com/us/podcast/nerdcast/id381816509?mt=2&uo=4", "feedurl": "http://jovemnerd.com.br/categoria/nerdcast/feed/", ...

parse.com - Parse - afterSave and access inner field? -

i trying send of data in request client push notification. request object should "comment" object has pointer "user" object named "from". i tried both request.object.get("from").objectid and request.object.get("from").get("objectid"); when log them in console looks both undefined edit: also tried use id instead of objectid in both cases. this correct syntax: request.object.get("from").id but works in beforesave . not quite sure why.

java - UriMatcher doesn't match correctly -

first up: have sifted through many of questions on topic on , have still failed come correct answer. here a, (way simplified), version of code: private static urimatcher urimatcher = new urimatcher(urimatcher.no_match); private static final int homework_table_request = 1, class_table_request = 2, settings_table_request = 3, homework_item_request = 4, class_item_request = 5, settings_item_request = 6; static { urimatcher.adduri("org.dvc.homeworkreminder.homeworkprovider", "homework", homework_table_request); urimatcher.adduri("org.dvc.homeworkreminder.homeworkprovider", "homework/#", homework_item_request); urimatcher.adduri("org.dvc.homeworkreminder.homeworkprovider", "class", class_table_request); urimatcher.adduri("org.dvc.homeworkreminder.homeworkprovider", "class/#", class_item_request); urimatcher.adduri("org.dvc...

c# - Completely remove a picturebox from project? -

i have project in dynamically create pictureboxes run 1 side of screen another. user needs click pictureboxes and, when clicked, dissapear. however, if picturebox gets 1 side of screen another, life lost. problem is, lives seem dissapear randomly. suspect because pictureboxes aren't removed project , somehow keep travelling after clicked them. code. thank :). //the movement timer private void timermovement_tick(object sender, eventargs e) { int i; (i = 0; < zombie.count(); i++) { int x = zombie[i].img.location.x; int y = zombie[i].img.location.y; if (zombie[i].loc == 0) { x = x + 10; if (zombie[i].img.location.x > 1200 && zombie[i].img != null) { zombie[i].img.dispose(); this.controls.remove(zombie[i].img); label5.text = convert.tostring(zombies_total - zombies_killed - 1...

dynamic - Declare the size of array at runtime in standard C (not in C99) -

array needs size defined @ compile time. there possibility define size of array @ runtime using malloc or whatever? you can use calloc , malloc or realloc per requirements. explained here . the malloc function allocates n bytes of memory, suitably aligned storage of type. pointer suitable passing free, deallocates it, or realloc, changes size (and may move different location). calloc allocates nmemb*size bytes, if malloc, , sets them bits zero. should noted bits 0 not valid null pointer or floating point 0 calloc cannot relied upon correctly initialise data types. here code samples #include<stdlib.h> /* code */ n = some_calculation() ; // array size generated @ runtime // data_type type of array eg. int or struct //using calloc ,it set allocated values 0 or null per data_type data_type *array = calloc(n,sizeof(data_type)) ; // using malloc , allocate adresses, may contain garbage values data_type *array = (data_type *)malloc(n); // using realloc ...

java - Stuck in "Concurrency In Practise" article no Listing 2.1. A Stateless Servlet -

from book: 2.1.1. example: stateless servlet in chapter 1, listed number of frameworks create threads , call components threads, leaving responsibility of making components thread-safe. often, thread-safety requirements stem not decision use threads directly decision use facility servlets framework. we're going develop simple examplea servlet-based factorization serviceand extend add features while preserving thread safety. listing 2.1 shows our simple factorization servlet. unpacks number factored servlet request, factors it, , packages results servlet response. and code example @threadsafe public class statelessfactorizer implements servlet { public void service(servletrequest req, servletresponse resp) { biginteger = extractfromrequest(req); biginteger[] factors = factor(i); encodeintoresponse(resp, factors); } } with nothing else provided, tried things working first writing simple servlet in eclipse using dynamic-web module ...

objective c - NSTextView sometimes get grayed out and unable to interact with -

i have nsview inside of "menubar". have button click on , add new nsmenuitem menu. when run code inside custom view in init method view grayed out , i'm unable select it. ideas cause of this. problem seems affect created nsmenuitems after problem occur. -(id)initwithframe:(nsrect)framerect andtag:(int)tagz{ textfeild = [[nstextview alloc]initwithframe:cgrectmake(19,1 , 110, 18)]; [textfeild setfont:[nsfont fontwithname:@"helvetica" size:15]]; [textfeild setstring:[nsstring stringwithformat:@"notespace %d",tagz]]; [textfeild selectall:self]; [self addsubview:textfeild]; } i don't think supposed use [self addsubview:] on menu item. instead, supposed create nsview , place custom view inside it. documentation here: https://developer.apple.com/library/mac/documentation/cocoa/conceptual/menulist/articles/viewsinmenuitems.html however, according documentation views inside menu item may not receive keyboard event...

python - Having users reference nodes of a tree structure -

i writing app stores hierarchical data in tree structure of python class instances. root node have list of children , each child have own children in list, , on. users need operate directly on tree structure in easy way. easiest way being enumerated hierarchical list. lizards waterfowls goose so example if user wanted add data goose in command line need work on item 2 sub item 1 or 2.1. what's best way maintain these accessible references these tree node instances? every node has timestamp , uuid. problem everytime program run must serialized , deserialized. sort timestamp bit unsure how come enumeration, if should dynamically done or stored in tree structure. class node: def __init__(self, name): self.name = name self.parent = none self.children = [] def __repr__(self): return self.name def add_node(self, child): child.set_parent(self) self.add_child(child) def get_node(self, po...

php - Stripe.js won't charge with AJAX Submit -

i have been scratching head on this. stripe won't charge. have tried running php on server using station variables , worked; problem seems between server , ajax. here html , javascript code: <!doctype html> <html> <head> <meta charset="utf-8"> <title>untitled document</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, target-densitydpi=medium-dpi, user-scalable=0" /> <meta http-equiv="access-control-allow-origin" content="*"> <script type="text/javascript" src="js/jquery.min.js"></script> <script type="text/javascript" src="https://checkout.stripe.com/checkout.js"></script> <script type="text/javascript"> $(document).ready(function() { $('#sendpledgebtn...

sql - What are alternatives to update/delete records with a key that references multiple tables? -

i reading on threads in so, , found out example party table below incorrect because have foreign key referencing 2 tables cannot do. thought whole idea of foreign keys make sure if update or delete in 1 table, row references foreign key gets updated or deleted. doesn't whole idea of limiting foreign key reference single table kind of kill idea? way update/delete records among tables when delete key referenced in other tables? in mobile app right now, if "party" deleted or renamed, write query check appropriate tables , delete table, condition wherever need to. "normal" way? thought on delete cascade or on update cascade trick, if it's single referenced table, might doing query on each appropriate table. i guess question might be, if have foreign key in multiple tables, sign of bad design? foreign key in multiple tables supposed rare occurrence? create table party ( partyname varchar(30) not null, pcname varchar(30) not null, pr...

java - Auto Increment like with String values in hibernate -

well want know if there appropriate way tackle generating auto id string values, first idea creating auto increment id can call auto_id before saving new entity i'll query latest data inside db id i'll add 1 auto generate value column assign name stringvalue+(id+1) though i'm concerned on how affect performance saving entity needs 2 access in db fetching , saving... question earlier there appropriate way handle scenario? and sorry english guys if want clarify things question kindly ask, thnx in advance.. here's code attributemodel hibernate annotation @component @entity @table(name="attribute_info") public class attributemodel { @id @generatedvalue(strategy=generationtype.auto) @column(name="attr_id", nullable=false, unique=true) private int id; @column(name="attr_name") private string name; @column(name="attr_desc") private string desc; @column(name="attr_active") pri...

php - magento Fedex shipping method -

i using magento community 1.8.1 using fedex shipping carrier, i want set fedex such take individual product in cart shipping , calculate rate instead of taking product in cart in 1 box because not allow more 150 lbs in 1 box , want ship more that. please consider scenario, product weight 15lbs , want ship more 10 product @ time fedex doesn't show shipping method more 10 products , how it? either have setup in fedex account or have change coding. please give right suggestion. there no need change code. can configure max weight in back-office/admin. here screenshot: http://grabilla.com/04514-594a5652-63b9-4ea7-ba56-1b92df3def90.html# hope helps.

html - How do I make text inside the title tag animate using JavaScript? -

how show scrolling (moving) message in title? <title>welcome title</title> translate titlebar dynamic displays additional information using javascript (without css). you can add marque in title bar text through javascript. see in blog post add scrolling marquee effects text title bar . the unmodified contents of page, except formatting: /* can add moving text title bar of browser website or blog. here code this. add code in website or blog in widget (after replacing text desired text). */ <script language=javascript> var rev = "fwd"; function titlebar(val){ var msg = "your text"; var res = " "; var speed = 100; var pos = val; msg = " |-"+msg+"-|"; var le = msg.length; if(rev == "fwd"){ if(pos < le){ pos = pos+1; scroll = msg.substr(0,pos); documen...

python - How to use glob to read limited set of files with numeric names? -

how use glob read limited set of files? i have json files named numbers 50 20000 (e.g. 50.json,51.json,52.json...19999.json,20000.json) within same directory. want read files numbered 15000 18000. to i'm using glob, shown below, generates empty list every time try filter out numbers. i've tried best follow link ( https://docs.python.org/2/library/glob.html ), i'm not sure i'm doing wrong. >>> directory = "/users/chris/dropbox" >>> read_files = glob.glob(directory+"/[15000-18000].*") >>> print read_files [] also, if wanted files number greater 18000? you using glob syntax incorrectly; [..] sequence works per character . following glob match files correctly instead: '1[5-8][0-9][0-9][0-9].*' under covers, glob uses fnmatch translates pattern regular expression. pattern translates to: >>> import fnmatch >>> fnmatch.translate('[15000-18000].*') '[15000-18000]\\...

Using an uuid or guid as id in grails/hibernate -

i need have guid/uuid's id column of rows. this able create entries both online , offline, , of course not having these conflict on pk when merging. know mitigate this, i'd keep simple, , there legacy apps using uuid/guids define relationships). data needs synced both ways later. rewriting existing applications not option. when try use either guid or uuid grails error 500. (using guid on h2 results in error - detaling db not support guids, expected). i error when try save 'withuuid': uri /gtestuuid/withuuid/save class java.lang.illegalargumentexception message argument type mismatch entire error 500: http://imgur.com/m2udbm6.png i've tried mariadb 5.5 , 1.1.7 driver, results in same problem. grails 2.3.8. windows 8.1 (x64). netbeans 7.4 all default. example classes: withuuid.groovy: package gtestuuid class withuuid { string name static constraints = { } static mapping = { id generator: 'uuid' } ...

ruby on rails - can't include devise helper methods in my controller -

i'm working on api , have login via devise. working on controllers, have method in sessionscontroller this def create resource = user.find_for_database_authentication(email: params[:user_email]) return invalid_login_attempt unless resource if resource.valid_password?(params[:user_password]) session[:uid] = resource.authentication_token #sign_in("user", resource) render :json => {success: true, auth_token: resource.authentication_token, email: resource.email} return end invalid_login_attempt end but got error on sign_in saying method doesn't exists. tried include devise::controllers::internalhelpers doesn't worked too... missing?

javascript - Listen for multiple promises to complete -

this works fine the first call, regardless on if "reset" deferred objects, $.when trigger once, unless rebind inside click handler. is there way make global listener several promises, can resetted? i've thought custom events , pub/sub pattern well. work great single events, can't figure out way use them scenario below. var dfd1 = $.deferred(), dfd2 = $.deferred(); $('input').on('click', function(){ dfd1 = $.deferred(); dfd2 = $.deferred(); f1(); f2(); }); $.when.apply($, [dfd1, dfd2]).then(function(schemas) { console.log('done'); }); function f1(){ settimeout(dfd1.resolve, 500); } function f2(){ settimeout(dfd2.resolve, 600); } f1(); f2(); http://jsfiddle.net/c62gh/ tl;dr: have call $.when again every time create new deferreds. the problem code don't "reset" deferred objects (and in fact cannot reset) -- replacing references these objects references other (unresolved) defe...

operating system - OS detection in php not working accurately / bug in script? -

i used script os detecting php described enter link description here the code looks this: function getos() { global $user_agent; $os_platform = "unknown os platform"; $os_array = array( '/windows nt 6.3/i' => 'windows 8.1', '/windows nt 6.2/i' => 'windows 8', '/windows nt 6.1/i' => 'windows 7', '/windows nt 6.0/i' => 'windows vista', '/windows nt 5.2/i' => 'windows server 2003/xp x64', '/windows nt 5.1/i' => 'windows xp', '/windows xp/i' => 'windows xp', '/windows nt 5.0/i' => 'windows 2000', '/windows nt 6.3/i' => 'windows 8.1...

php - Add WHERE to PDO query if checkbox is checked -

i have mysql query pdo: $ac_term = "%".$_get['term']."%"; $query = "select * table name :term"; $query .= $filterquery; $result = $conn->prepare($query); $result->bindvalue(":term",$ac_term); $result->execute(); i'm using autocomplete jquery code "term". $('#input').autocomplete({ minlength: 2, source: function (request, response) { $.ajax({ url: 'suggest_zip.php', type: "post", data: { term: request.term, filter: '1' }, success: function (data) { response(data); } }); } }) if @ first block of code, can see tried $query .= $filerquery. $filterquery defined here: $filter = "%".$_get['filter']."%"; if($filter = '1'){ $filterquery = 'where allowed = 1'; } else{ ...