Posts

Showing posts from May, 2014

javascript - How to disable extra space checking for google closure linter? -

google closure linter give warning every line in following code, since there space after key name. there way disable space checking? can't find document configure .gjslintrc file. i can't find right flag use in " gjslint --help" result. var ngtemplatesoptions = { prefix : '/', module : 'lc.directive.tpls', standalone: false, htmlmin : { collapsebooleanattributes : true, collapsewhitespace : true, removeattributequotes : true, removecomments : true, // if don't use comment directives! removeemptyattributes : true, removeredundantattributes : true, removescripttypeattributes : true, removestylelinktypeattributes: true } }; you can disable specific errors using disable flag. in case, want following: gjslint --strict --disable 0001,0002 yourfile.js where, error code 0001 signifies space , erro

http - max-age, no-Cache,must-revalidate on Cache-Control Header, Which takes predence here? -

cache-control : max-age=86400, no-store, must-revalidate, no-cache this response header set server js file. does mean response cached 86400 seconds before revalidating?. which of above 1 takes precedence , resiult?. looks no-cache give precedence on all. http1.1 specification says " if no-cache directive not specify field-name, cache must not use response satisfy subsequent request without successful revalidation origin server. " refer http://www.w3.org/protocols/rfc2616/rfc2616-sec14.html#sec14.9.1 it says " the max-age directive on response implies response cacheable (i.e., "public") unless other, more restrictive cache directive present. " refer http://www.w3.org/protocols/rfc2616/rfc2616-sec14.html#sec14.9.3 all above http/1.1 .

Which will be the best way to update users ReadOnly database using Core Data (iOS) -

i'm building ios app based on our goverment's open data, i use coredata store data, there 8 entities in xcdatamodel, some entity cotains 20000+ row of data's, , database read-only, i won't , user won't modify database, such delete/update/create, read-only database. the open data goverment keep update, isn't scheduled (and not often), , need let user update database if open data updated. i considering 1 best way update users database? 1) fetch json server, delete contents database, , insert again. disadvantages: a) risk high, user/system may terminate app while updating. b) lots of cost of network traffic 2) clear database, fetch entities data server on ios simulator, insert data, after that, copy database documents folder, put on server, let user download whole sqlite database, , cover old database. i think second 1 better, don't know take risk? or there disadvantages of method? thank you! if database heavy , , read-only,

android - File to inputStream for FTP upload returns NullPointerExeption -

i'm trying upload file ftp have trouble inputstream. returns java.lang.nullpointerexception. how load file inputsteam? also no progress reports. onprogressupdate never executed, why? my code private class asyncftp extends asynctask<string, string, string>{ @override protected string doinbackground(string... params) { publishprogress("entro"); //creo ftpclient ftpclient ftp = new ftpclient(); //defino datos del servidor string ftp_host = "not real ip"; string ftp_user = "not real user"; string ftp_pass = "not real pass"; //cargo el archivo file file = new file("/data/data/com.lstupenengo.mysql/files/xx.xx"); fileinputstream fis = null; try { fis = new fileinputstream(file); } catch (filenotfoundexception e) { e.printstacktr

Save and close a word document by giving a name in R -

i trying use 2 libraries ( descstool , r2wd ) in order descriptive analysis of dataset saved in folder exploration later. these steps trying library(desctools) library(r2wd) data(iris) <- ls() wrd <- getnewwrd(header=true) wdget() desc(get(i), plotit=true, wrd=wrd) wdsave(name="temp.doc", wdapp=.r2wd) wdquit() although word capturing output supposed be, cannot save word file giving name (e.g.: temp.doc). can shed light here? try library(desctools) wrd <- getnewwrd() desc(iris, wrd=wrd) wrd[["activedocument"]]$saveas2(filename="describe iris.docx") wrd$quit()

python - MongoAlchemy ObjectIdField resolution -

if have model contains objectidfield model, (django) use property create getter , reference transparent in usage. so: class image(db.document): name_full = db.stringfield(required=true) name_thumb = db.stringfield(required=false) source = db.stringfield(required=false) class product(db.document): name = db.stringfield() description = db.stringfield(required=false) image_id = db.objectidfield(required=false) def _get_image(self): try: return db.query(image).filter(mongo_id=self.image_id)[0] except indexerror: return none image = property(_get_image) though, in practice error when trying access template: <img src="{{ url_for('static', filename='images/products/'+product.image.name_thumb) }}"> undefinederror: 'app.models.product object' has no attribute 'image' am going right way? answering own question here. seems mistake in funct

Write comma separated unicode in android textview -

hello friends have 1 hexadecimal code string ss=54,44,24 i want wrote in android below text.settext("\u54\u44\u24"); but show me error "invalid unicode" idea how can write it? please try this: mport org.apache.commons.codec.binary.hex; ... string hexstring = hex.encodehexstring(mystring.getbytes(/* charset */));

code snippets - Modx - Getting the current context -

i have 2 contexts , use snippet current context. snippet working properly, when use in getresources call, not passing snippet value. [[getresources? &parents=`0` &limit=`10` &depth=`0` &tvfilters=`cb_show_in_top_bar_menu==1` &includetvs=`1` &includetvlist=`cb_show_in_top_bar_menu,cb_hash_link_menu` &tpl=`chk-top-menu-item` &sortdir=`asc` &sortby=`menuindex` &context=`[[!context]]` ]] the context snippet return $modx->context->key; can tell me how can done. what have right, getresources. ~ try calling uncached. if not, try setting context key context setting can call [[++context_key]] or in context snippet set placeholder: [[!context]] [[!getresources? &parents=`0` ... &sortby=`menuindex` &context=`[[+context_key]]` ]] !context

rust - Why are these ASCII methods inconsistent? -

when @ rust ascii operations feels there consistency issue between is_lowercase/is_uppercase: pub fn is_uppercase(&self) -> bool { (self.chr - b'a') < 26 } is_alphabetic: pub fn is_alphabetic(&self) -> bool { (self.chr >= 0x41 && self.chr <= 0x5a) || (self.chr >= 0x61 && self.chr <= 0x7a) } is there reason? 2 methods totally equivalent or missing something? these functions marked stable i'm confused. edit: to make clearer, expect decide on best (in terms of performance/readability/common practice) implementation lower/upper have pub fn is_alphabetic(&self) -> bool { self.is_lowercase() || self.is_uppercase() } since question changed performance, i'll add second answer. to start, created clone of ascii module ( playpen ): pub struct alpha(u8); impl alpha { #[inline(never)] pub fn is_uppercase_sub(&self) -> bool { (self.0 - b'a') < 26 }

ruby - Strong Params Unpermitted parameters -

i know there alot of questions on this, after looking @ dozen or none of them appear same problem. have "action" model trying edit , update. (fyi, isn't nested form, i'm not using devise, , isn't activeadmin problem...like virtually other questions topic are). i'm getting error: unpermitted parameters: utf8, _method, authenticity_token when this. action params in actions_controller: def action_params params.permit(:id, :call_answered, :is_customer, :category_id, :actiontype_id, :why, :reviewer_id, :reviewed, :spam, :lead) end if change to: params.require(:action).permit(:id, :call_answered, :is_customer, :category_id, :actiontype_id, :why, :reviewer_id, :reviewed, :spam, :lead) end than below error (and can't find solution this): undefined method `permit' "update":string actions controller: def edit @action = action.find(params[:id]) @actiontypes = actiontype.all @categories = category.all @

c++ - tcsetattr() blocking time with TCSADRAIN flag is weird -

i coding serial port in linux. and requirement of communication 5ms inter-byte time . and requires me change parity mode(even , odd) each byte before write() call, according byte's value is. so code below(i describe code simply) void setwakeupmode(int fd, bool mode) { struct termios tio; bzero(&tio, sizeof(tio)); tcgetattr(fd, &tio); if (mode == false) { tio.c_cflag &= ~parodd; } else if (mode == true) { tio.c_cflag |= parodd; } if(tcsetattr(fd, tcsadrain, &tio) < 0){ perror("tcsetattr error"); } } int main(){ unsigned char a[2] = {0x01, 0x0f}; write(fd, a, 1); setwakeupmode(fd, true); write(fd, a+1, 1); } but code doesn't satisfy inter-byte time resulting in 20ms. so tried print exact time between each system call below. int main(){ unsigned char a[2] = {0x01, 0x0f}; printf("write1 start : %s", /*time*/); write(f

python - scrapy debug Request object -

how debug scrapy request object? requestobj= formrequest.from_response(response, formxpath =form_xpath,callback=self.parse1) i need check formdata of requestobj .but didn't find documentation debugging request object use traffic monitoring software , use fiddler. check requests sent python browsers

objective c - iOS EXC_BAD_ACCESS KERN_INVALID_ADDRESS -

i error: thread : crashed: com.apple.root.default-priority 0 libobjc.a.dylib 0x000000019079a984 objc_object::release() + 8 1 app 0x000000010015a128 -[decontext callservice:service:] (denavajocontext.m:116) 2 app 0x000000010015fcc4 +[decontext(dxcontext) genericservicerequest:service:error:expectedmessage:] (decontext+dxcontext.m:31) 3 app 0x0000000100111a64 __28+[dxlogo logo:callback:]_block_invoke (dxlogo.m:81) 4 libdispatch.dylib 0x0000000190d58014 _dispatch_call_block_and_release + 24 5 libdispatch.dylib 0x0000000190d57fd4 _dispatch_client_callout + 16 6 libdispatch.dylib 0x0000000190d5f2b8 _dispatch_root_queue_drain + 556 7 libdispatch.dylib 0x0000000190d5f4fc _dispatch_worker_thread2 + 76 8 libsystem_pthread.dylib 0x0000000190eed6bc _pthread_wqthread + 356 i've searched , found couple things: i have dangl

amazon web services - When using Cognito credentials with AWS in a browser (javascript), keep getting "missing credentials" error -

Image
i'm attempting upload file s3 bucket of mine web browser using aws' javascript sdk. code looks this: aws.config.credentials = new aws.cognitoidentitycredentials({ accountid: 'dfhgdh', identitypoolid: 'fdagsd', rolearn: 'fdafds' }); var bucket = new aws.s3({params: {bucket: 'test-bucket'}}); var pdfupload = document.getelementbyid('pdf-uploads').files[0]; var params = {key: pdfupload.name, contenttype: pdfupload.type, body: pdfupload}; bucket.putobject(params, function (error, data) { if (error) { console.log(error); } else { console.log(data); } }); however, whenever reaches putobject command, keep getting error aws: "error: missing credentials in config {message: "missing credentials in config", code: "credentialserror"..." i'm sure i'm missing simple , stupid here, can't figure out life of me. (i different error when try hardcode bogus secret

java - OptimisticLocking is not working in eclipse link -

i working on project , due issue changing pessimistic locking optimistic locking. while doing getting error while updating entity in code tried standalone application there no chance 2 threads updating simultaneously. checked value of version in different part of code. showing 0. while calling flush or commit giving excepion updated 1. note: added @version int version_id field in entity optimisticlocking. the code below: workitem tmp_workitem=entitymanager.find(workitem.class , workitem.getentitykey()); logger.info("before merge"+ tmp_workitem.getversion()); entitymanager.merge(workitem); tmp_workitem=entitymanager.find(workitem.class , workitem.getentitykey()); logger.info("after merge"+tmp_workitem.getversion()+" "+workitem.getversion()); //logger.info(entitymanager.getlockmode(workitem.class).tostring()); entitymanager.flush(); logger.info("after flush"+tmp_workite

bash - How to use grep to find string that contain "\n" char? -

Image
i want use powerful grep find strings contain following sentence in matlab source files in directory. fprintf('error: invalid indexes!\n'); i've tried following command, shows errors. grep -rl "fprintf(\'error: invalid indexes!\\n\');" ./ i've tried solutions presented in here , seems not work. could please give advice? in addition, after find matched strings, want replace them following sentence: if(length(invalid_idx)>0) fprintf('error: invalid indexes!\n'); end i know use following command: grep -rl "need_to_replaced_strings" ./ | xargs sed -i 's/need_to_replaced_strings/replaced_strings/g' i'm not sure if replaced_strings in command above should have special considerations. the errors follows: try this: $ grep -erl 'fprintf\('\''error: invalid indexes!\\n'\''\);' ./ fprintf('error: invalid indexes!\n'); use -e option

mysql - Show primary key column in table -

Image
i have following query use recipesexample; select recipes.recipetitle recipes the create table is: create table recipes ( recipeid int not null default 0 , recipetitle nvarchar (255) null , recipeclassid smallint null default 0 , preparation text null , notes text null ); alter table recipes add constraint recipes_pk primary key ( recipeid ); which outputs: how edit query can view primary key? , foreign key recipeclassid. simply add required columns in query comma separated, select recipes.recipeid,recipes.recipeclassid,recipes.recipetitle recipes

javascript - How to use Backbone to parse JSON? -

i'm learning backbone, little example. have json url, result looks : { help: "help", success: true, result: { count: 13, results: [ { name: "name 1", description: "desc 1", resources: [ { img: "url.jpg" } ] }, { name: "name 2", description: "desc 2", resources: [ { img: "url2.jpg" } ] } ] } } now want results html div, used this: $(function() { var dataset = backbone.model.extend(); var profilelist = backbone.collection.extend({ model: dataset, url: 'profiles.json' }); var profileview = backbone.view.extend({