Posts

javascript - catching a 500 response when setting the src of an iframe -

i'm doing similar code: $('#myiframe').attr('src', 'dosomethingthatreturnsadocument.aspx'); the page gets called returns document, whether word doc, pdf etc , prompts user open/save , working fine. the problem have if goes wrong @ server side 500 response returned. don't seem have way of catching error. i've tried try catch around line. .error function of iframe doesn't seem catch it. does know of way allow me catch 500 can act accordingly ui? you should first check response , set in iframe. can try this: var loading_url = "/dosomethingthatreturnsadocument.aspx" $.ajax({ url: loading_url, type: 'get', complete: function(e, xhr, settings){ if(e.status === 200){ $('#myiframe').attr('src', 'dosomethingthatreturnsadocument.aspx'); }else if(e.status===500){ // } } });

My java game isn't working -

so i'm still beginner managed code didn't work wanted, main problem every time press 1 resets enemy instead of keeping same one. appreciate if me. far have made writing 1 something. package game; import java.util.random; import java.util.scanner; public class main { public static void main(string[] args) { scanner in = new scanner(system.in); random r = new random(); system.out.println("welcome dragon heart"); system.out.println("1. start"); system.out.println("2. quit"); int input = 0, enemyhealth = 75, enemyattack = 15, playerhealth = 100, playerattack, random; boolean enemydead = true, playerdead = false; input = in.nextint(); if (input == 1) { system.out.println("game started!"); while (0 != 1) { if (enemydead = true) { enemyhealth = r.nextint(50) + 51; enemyattack = r.n...

android - When to use object.recycle() in java? -

i learning android development , have basic knowledge of java. see .recycle() being used in different codes. reading few documents learnt method used recycle bitmaps save memory avoid exceptions outofmemoryerror (however, may alternative on android version 3.0 , higher, saw somewhere). however, reading tutorial custom views , came know method recycle() used typedarray ; left me wondering other possible uses of method. questions are: what other areas recycle should used? should recycle method used objects of user created class if grow complex? i may entirely wrong concepts above, if can please point me right direction proper links articles 'when use recycle() , why?', thanks.

Does double buffering for the purpose of vertex streaming do anything in webgl? -

Image
i trying render many moving objects can webgl , updating objects position glbufferdata/glbuffersubdata each frame.i found recommended use double buffer reduce synchronization issues between gpu , cpu: https://developer.apple.com/library/ios/documentation/3ddrawing/conceptual/opengles_programmingguide/techniquesforworkingwithvertexdata/techniquesforworkingwithvertexdata.html , https://www.opengl.org/wiki/buffer_object_streaming , google's webgl optimizationg slides . so have implemented double buffering , drawing expected. however, there no performance gains. (in fact made slower) curious if double buffer technique described in above 3 documents approriate webgl. here doing (capture webgl inspector): frame x: frame x+1:

python - pandas raises ValueError on DatetimeIndex Conversion -

i converting iso-8601 formatted values unix values. inexplicable reason line a_col = pd.datetimeindex(a_col).astype(np.int64)/10**6 raises error valueerror: unable convert 0 2001-06-29 ... (abbreviated output of column name: datecol, dtype: datetime64[ns] datetime dtype this odd because i've guaranteed each value in datetime.datetime format can see here: if a_col.dtypes (np.dtype('object') or np.dtype('o')): a_col = a_col.apply(lambda x: x if isinstance(x, datetime.datetime) else epoch) a_col = pd.datetimeindex(a_col).astype(np.int64)/10**6 epoch datetime.datetime. when check dtypes of column gives me error it's "object), i'm checking for. there i'm missing? assuming time zone us/eastern (based on dataset) , dataframe named df , please try following: import datetime dt time import mktime import pytz df['job start date'] = \ df['job start date'].apply(lambda x: mktime(pytz....

javascript - Full calendar Timezone Moment js Issue -

i've been wrestling while now, reaching out bit of please. i have realtime multi timezone application uses signal r, datetimes stored , broadcast using utc , want manipulate them client side avoid multiple broadcasts different users if 1 appointment updated. i'm trying fullcalendar display dates in appropriate timezone user, not based on browser local string held when user logs on. is possible? or need store offsets , way (i hoping avoid this). using eventrender manipulate giving me other issues , have raise bug. my code is: $(document).ready(function() { function rendercalendar() { $('#calendar').fullcalendar({ header: { left: 'prev,next today', center: 'title', right: 'month,agendaweek,agendaday' }, editable: true, timezone: "europe/istanbul", eventlimit: true, // allow "more" link when ...

C create array of struct using constructor function -

i have c struct: typedef struct { dataset *datasets; int ndatasets; char *group_name; enum grouptype type; } datasetgroup; it has constructor function this: datasetgroup * new_datasetgroup(char *group_name, enum grouptype type, enum returncode *ret) { datasetgroup *dg; dg = (datasetgroup *) malloc(sizeof(datasetgroup)); if (dg == null) { *ret = ememory_error; } // allocate space few datasets dg->datasets = malloc(sizeof(dataset) * increment); if (dg->datasets == null) { *ret = ememory_error; } dg->group_name= malloc(sizeof(char) * strlen(group_name)); strcpy(dg->group_name, group_name); dg->type = type; groupcount++; return dg; } i want dynamically create array of these structs. whats best way this? so far have like: datasetgroup * make_array(){ datasetgroup *dg_array; // allocate space few groups dg_array = (datasetgroup *) malloc(sizeof(datase...