Posts

Showing posts from June, 2010

c - How to get next certificate in chain -

i want parent certificate (or certificates in chain matter) windows certificate store (assuming know location of end certificate). need each 1 in order build own custom x509_store (using openssl ). i think proper course of action be: obtain first certificate using certfindcertificateinstore (done) get certificate chain using certgetcertificatechain (done) extract certificates chain (?) for each certificate in chain, convert using d2i_x509 (done) or obtain first certificate using certfindcertificateinstore (done) get parent certificate (if exists) (?) convert using d2i_x509 , go 2. (done) then create store. the question answer - how parent certificate or certificates in chain using windows certificate store? i'm missing more or less occult function here. as certfindcertificateinstore outputs chain context, 1 can access it's members using beautiful construction: chaincontext->rgpchain[0]->rgpelement[icertindex]->pcertcontext->

amazon web services - Roles / Permissions to create EMR Cluster using aws cli -

i trying create cluster using aws emr command. call out dont have admin role of stuff. aws emr create-cluster --release-label emr-4.2.0 --instance-groups instancegrouptype=master,instancecount=1,instancetype=m3.xlarge instancegrouptype=core,instancecount=2,instancetype=m3.xlarge --service-role my_role--ec2-attributes keyname=my_key_pair,subnetid=subnet-xxxxxxxx,instanceprofile=my_role i trying run command on ec2 instance. success message cluster id displayed. machine terminates invalid role error message. if try see cluster state in aws console see many permission error messages. are there set of permissions required role / policies ensure creation of cluster out error ? i cant use --use-default-role don't have permission create role. i can give emr_defaultrole i'm using create emr with: { "version": "2012-10-17", "statement": [{ "effect": "allow", "resource": "*&

Javascript events/functions triggering not only from button, but from whole page, incremental game -

i'm trying make own little incremental game , have few buttons currently. buttons following: "ka-ching" - money clicking 3 buttons buying "autoclickers". my problem autoclickers 2 , 3 bought when enough money when click anywhere on site, "ka-ching" button. stopped happening ka-ching when using kaching(ev) {ev.stoppropagation();}; doesn't work others. my full code: https://jsfiddle.net/veix/sdh94o6m/19/ (interval doesn't work in jsfiddle reason, doesn't matter, isn't bug i'm having. jsfiddle doesn't have stoppropagation(); in question. also part of problematic parts (i think): //function buying hotdog function buyhd() { if (buyclicker(hotdog.cost, this)) { hotdog.clicks += 0.10; hotdog.cost *=hotdog.costincrease; hotdog.level++; var e = document.getelementbyid("hotdog-level"); e.innerhtml = "lvl " + hotdog.level; var e2 = document.getelem

javascript - Is it possible to call a function ONLY on the first run? -

i developing app using telerik's nativescript. know whether it's possible call function first time app ran, not each consecutive run. my first thoughts ship 1 line text file content false . on first run check file , value. if false i'd run function , update text file content true , otherwise i'd let app continue normal. i think there must better, more efficient way this. ideas folks? i've no idea why you're getting these browser technology answers you're using nativescript want take @ application settings module. a value set application settings persist long app installed on device. if user re-installing app it'll (of course) reset. it's easy as: var appsettings = require("application-settings"); if(!appsettings.getboolean("hasrunned", false)) { // stuff want on first run // , set true appsettings.setboolean("hasrunned", true); }

How to get various types used in a C# project with Roslyn -

i analyzing converting existing c# library java. start need know types / built-in keywords used in existing c# library. mean, example public class csharpclass { int i; float j; console.writeline(string.concat("a","b")); } in class types/keywords used are, public int float console string my questions are, is there way this. hope can roslyn. can “localdeclarationstatementsyntax” variables. how parse “console” , “concat”. “sytax walker” parses tokens in class option? also how classes project file roslyn? you need semantics -- syntax text see , that's get, nothing more, nothing less. compilation project, can call getsemanticmodel give tree, , there can call gettypeinfo or getsymbolinfo (as appropriate, search online difference between these two) type information. as far getting compilation , if you're writing command line tool want use msbuildworkspace load project. if you're analyzing projects open in visual studio, us

orm - How to implement one-to-many relationship with join table using sequelize-npm in node.js -

Image
i writing rest apis in node.js sequelize mysql orm. know, how achieve n:m relationship between 2 tables using sequelize association. defined here in official documentation of sequelize. i want achieve one-to-many relationship using join table. my approach achieve : parent.model.js module.exports = function(sequelize, datatypes){ var parent = sequelize.define('parent', { parent_id:{ type:datatypes.integer, field:'parent_id', primarykey: true, autoincrement: true, unique:true }, parent_name:{ type: datatypes.string, field: 'parent_name' }, }, { classmethods:{ associate:function(models){ parent.belongstomany(models.child, { through:'parent_child_mapping'

What kind of Open Source License is Appcelerator Titnaium using? -

we had interesting lecture open source projects today @ work. went titanium github repository check kind of license titanium using, not find definite answer. the closest see there is: commercial support, licensing we give our software away free! in order that, have programs companies require additional level of assistance through training or commercial support, need special licensing or want additional levels of capabilities. please visit appcelerator website more information appcelerator or email info@appcelerator.com. but that's vague. commercial applications? payed applications? developer has open-source application in order meet oss requirements titanium? oss titanium uses? appcelerator titanium mobile copyright 2008-2013 appcelerator, inc. licensed under apache license, version 2.0 (the "license"); may not use file except in compliance license. may obtain copy of license at http://www.apache.org/licenses/license-2.0 unless

javascript - How to find partial occurrence of a word in a string and replace the whole word -

i want find partial occurrence of word in string , attach <span> around it. more in detail, want find occurrences of words starting percentage sign "%" (for example %mystring) , replace them <span>%mystring<span> . i found similar solutions in php, i'm not sure how go in javascript. try this: str = 'go %link not %link'; replacedstr = str.replace(/\s\%(.*?)(\s|$)/g, ' <span>%$1</span>$2');

manual - What's the difference between Gray box and Black box testing? -

i m trying understand 1 in terms of how compares other. is grey box testing can see code , black box testing don't @ code? black box testing when know nothing system. know input , check output without knowing process in between input , output. grey box testing same know things internals of system. example have knowledge architecture or have implementation documents. mix of white (see further) , black box testing (it's in between). white box testing when know system. source code, architecture. test program completely, check if doing expected, check exceptions or errors. have understand how code works. so answer question, both black box , grey box testing don't check code. in grey box testing it's more internal structure , architecture have knowledge, in algorithms used. you can find info on wikipedia or this url explains white, grey , black box testing.

extjs - EXTJS5 - how to add the legend color of pie chart dynamically? -

i have issue while using custom legend color in extjs 5 chart. can apply custom color chart legend cannot apply legend item. can hard-code colors using "colors" property within series handle issue statically .like series: { type: 'bar', colors: ['orange', 'yellow'], ... } but,i need pass color dynamically. need fetch legend colors store.so cannot hard-code it my code. ext.define('gmis.view.charts.pie.basicpielegend', { extend: 'ext.panel', config:{ storevalue: null, //'bankerdatastorechr' widthvalue: null, heightvalue: null, identifier: null, titlevalue : null, stylevalue : null, stylevalue1 : null, chartvalue : null, selbanker : null }, storevalue: null, constructor: function(cfg){ this.initconfig(cfg); this.callparent(); this.addcls(this.getstylevalue()); this.addcls(this.getsty

ionic framework - Cloudinary - Upload preset must be in whitelist for unsigned uploads -

i want upload image, cloudinary, taken directly camera in ionic using cordova camera plugin. getting error of code 1, having message "upload preset must in whitelist unsigned uploads." how solve error.please help. my edited js code is: $scope.cameraopen = function(){ var options = { quality : 100, destinationtype : camera.destinationtype.file_uri,//file_uri sourcetype : camera.picturesourcetype.camera, allowedit : false, encodingtype: camera.encodingtype.jpeg, popoveroptions: camerapopoveroptions, targetwidth: 500, targetheight: 500, savetophotoalbum: true }; $cordovacamera.getpicture(options).then(function(imagedata) { var uploadoptions = { upload_preset: cloudinary.config().upload_preset, tags: 'mytag', context: 'photo=photo', file: imagedata }; var onuploadsuccess = function(data){

java - How to Timestamp signature create? -

i want use timestamp signature xml, pdf. have read document timestamp, don't understand how create or add timestamp signature on client. (i don't talk how create timestamp on server). i want know how create timestamp signature on client: client receives timestamp tsa server, client attaches timestamp data. client signs data+timestamp create timestamp signature or client signs data => creates signature receive timestamp , attach timestamp signature => create timestamp signature. what's correct way create timestamp signature in 2 ways? can me answer , what's way product using? can give me document issuer? both orders of making time stamp , signature can make sense signature content time stamp : first time stamp document, add time stamp attributes sign, , sign document , attributes. using construct can prove that the document existed in given form @ time of time stamp and the signature has not been created before time of time stamp. s

Codeigniter Url without index.php -

i want create app url ' http://example.com '. entering url, shows 'http error 403.14 - forbidden'. when have inserted 'index.php' @ last of url ' http://example.com/index.php ' landing page rendering in browser have changed $config['base_url'] = 'http://example.com'; $config['index_page'] = ''; and $config['uri_protocol'] = 'request_uri'; in config.php file. have placed .htaccess file in codeigniter root folder along application , system folder. in .htaccess file have coded <ifmodule mod_rewrite.c> rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ index.php/$1 [l] </ifmodule> i want remove 'index.php' url. using iis 8.5 web server. in ci can set session data when login successful: $this->session->set_userdata('username' $this->input->post('username')) you can unset @ lo

hibernate - JPQL: why 'group by' does not work properly -

executing jpql using hibernate 4.2.5: select c chargeback cc join cc.customer c group c order max(cc.created) usecase: show customers latest chargbacks. produces org.hibernate.exception.sqlgrammarexception: not extract resultset when using select c.id chargeback cc join cc.customer c group c order max(cc.created) work. when using select c chargeback cc join cc.customer c group c.id, c......all columns order max(cc.created) is bug? why jpql not include *? (from usecase necessary) no need - native sql of course solve it. assume jpql mature. there feature request this: hhh-1615 . however, keep in mind grouping columns may not best option performance-wise.

XSLT (1.0): comparing substring-after to attribute value fails -

maybe have overlooked obvious, @ moment i'm @ loss. trying node comparing attribute @id result of call substring-before . while fails, manually entering string gives right result , puzzled problem is. there no whitespaces interfering , result of substring-before() want. i have following snippet in file mets.xml : <mets:file id="edoc_ed000227_fg_kuttenberger_religionsfriede" mimetype="text/xml"> <mets:flocat loctype="url" xlink:href="quellentexte/kuttenberger_religionsfriede.xml"/> </mets:file> the file apply transformation has basic outline: <tei xmlns="http://www.tei-c.org/ns/1.0" xml:id="edoc_ed000227_fg_kuttenberger_religionsfriede_dt"> [...] <p xml:id="p001">[...]</p> </tei> i apply following transformation: <xsl:template match="tei:p[@xml:id]"> <xsl:variable name="test" select="substring-before(

android - Hyperlink in string resource in AlertDialog -

Image
i have large string , need add 2 hyperlinks. did it, it`s not clickable. string: <string name="freeasa"><![cdata[<b><font color=#cc0022>text<font color=#2266bb> text </font></b> <br> text <a href=\'http://google.com\'>navigate google.com</a><br><b><font color=#2266bb> text</font><font color=#cc0022> text </font></b><br> text <a href=\'http://yahoo.com\'> yahoo link<\a> ]]></string> alertdialog: final alertdialog.builder builder = new alertdialog.builder(getcontext()); builder.settitle(getresources().getstring(r.string.add_info)); builder.setmessage(html.fromhtml(getresources().getstring(r.string.freeasa))) .setpositivebutton("ok", new dialoginterface.onclicklistener() { @override public void onclick(dialoginterface dialoginterface, int

How to requesting javascript file of an HTTP server from HTTPS server -

well, have application runs on https , there requests load javascript files server runs on http (there no https option these javascript files), and, obviously, i'm getting error: mixed content: page @ ' https://myapplication.url.com/ loaded on https, requested insecure script ' http://another.application/file.js '. request has been blocked; content must served on https. a solution found @ was: instead of request http://another.application/file.js , suggest removing http:, leaving //another.application/file.js . doesn't work. tries request https , there no https option file.js. i've read related topics here: request json resource http page https server downloading files http server in python http request originated http server but, unfortunately, none of them gave me clue. has got error , how 1 solve that? i don't know if matters, i'm using tomcat6, java7 , problem occurs when try include file in index.html: that's cod

wpf - PropertyGrid with custom Itemsource and Dependency Injection -

i'm using ninject in mvvm application contains xceed propertygrid. propertygrid should use custom itemsource 1 particular property defined attribute: [itemsource(gettype(someobjectitemsource)] the someobjectitemsource.getvalues , need's access object created ninject public function getvalues() itemcollection implements iitemssource.getvalues fetch rootobject ninject kernel extract list of someobject rootobject , return end function as propertygrid not created ninject , ninject internally uses activator.createinstance without optional constructor parameters approach fails cannot pass reference ninject kernel or rootobject. note: source of propertygrid looks this. activate.createinstance able use constructor, isn't implemented way. private system.collections.ienumerable createitemssource() { var instance = activator.createinstance( _attribute.type ); return ( instance iitemssource ).getvalues(); } alternatively possible use custom type edito

Yii2 - How We can Change the element that Will be update via Pjax response -

how can change element(tag) update via server response . this form <div id="test" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mysmallmodallabel"> <div class="modal-dialog modal-sm"> <div class="modal-content"> <div class="modal-header">ورود به سایت</div> <?php \yii\widgets\pjax::begin(['enablepushstate'=>false]); $loginmodel=new \common\models\loginform(); $form=\yii\bootstrap\activeform::begin([ 'id'=>'form-login', 'options'=>['data-pjax'=>''], 'method'=>'post', 'action'=>['site/login'], ]); ec

java - HTML code in Dynamic jasper -

i tried add html styled text dynamic jasper report jrdesignband band = new jrdesignband(); band.setheight(20); // set band height jasperdesign jasperdesign = new jasperdesign(); jrdesigntextfield textfield = new jrdesigntextfield(); textfield.setx(0); // x position of text field. textfield.sety(0); // y position of text field. textfield.setwidth(860); // set width of text field. textfield.setheight(20); // set height of text field. jrdesignexpression jrexpression = new jrdesignexpression(); // new instanse of expression. need create new instance when need set expression. jrexpression.settext("<p>text &nbsp; &nbsp; &nbsp; space</p>"); // added string before field in expression. textfield.setexpression(jrexpression); textfield.setmarkup("html"); band.addelement(textfield); ((jrdesignsection) jasperdesign.getdetailsection(

php - how to increment session id variable after adding item into cart -

i working a cart item user can add multiple item cart , delete item cart using session after adding 1 item increment id 1 one on each add new item cart code working fine problem in deleting when trying delete item item tray delete 1 item here code <?php session_start(); if(!empty($_get["action"])) { switch($_get["action"]) { case "add": if(!isset($_session['cart'])) { $item_id_session = 1; $_session['cart'] = array(); } else { $count = count($_session['cart']); $item_id_session = $count++; } $item = array(); $item['item_id_session']= $item_id_session ; $item['title']=$_request['title']; $item['length_m'] =$_request['length_m']; $item['length_md']=$_request['length_md']; $item['length_cm'] =$_request['l

java - WebService Jax WS compile but unaccessable -

i recover project. project deployed on tomcat can't test web service or can't reach it. when wrote url got error 404. the web service looks : @webservice(servicename = "officialdate", portname = "officialdateport", endpointinterface = "com.????.web.officialdates_v1.officialdate", targetnamespace = "http://????/web/officialdates-v1", wsdllocation = "web-inf/wsdl/officialdatewebservice/officialdates.wsdl") how can debug webservice ? in webservice can error ? (sorry can't paste code -because private-) thanks you need add additional libraries (jar files) , web.xml configuration in order host jax-ws web services in tomcat. it's far easier use complete java ee implementation such wildfly, tomee, glassfish, etc. web service work when deployed in of these.

.net - C# boolean logic with dynamic LINQ? -

i've struggle following task: assuming have list names , values (like dictionary). need provide user of web interface field can write query, checking existence of specific names , values on list. for example, i've got following list: a = 2, b = 4, d = 0 users want query list (don't mind syntax, it's pseudocode) a == 2 && d => returns true , a exists , it's value 2 , d exists. (a && b) || c => returns true , both a , b exists on list. a && !b => returns false , a exists on list b (but b shouldn't) i've been looking on dynamic linq , seems can evaluate 1 object @ time (can't check if object exists on list , ask if 1 doesn't). knows materials or links useful? thanks not sure whether have understood requirement... is asking for? dictionary<string, int> namevaluepairs = new dictionary<string, int>(); namevaluepairs.add("a", 2); namevaluepairs

localnotification - Alarm Local Notification at IOS 7 Locked screen Objective-C -

i'm practicing develop alarm app alarm on ios 7. alarm time on ios7 however, stuck @ local notification @ locked screen, this. my notification code did: in appdelegate.m my code [[uiapplication sharedapplication] registerusernotificationsettings:mysettings]; // handle launching notification uilocalnotification *locationnotification = [launchoptions objectforkey:uiapplicationlaunchoptionslocalnotificationkey]; .... ..in viewcontroller.m.. [self schedulelocalnotificationwithdate:correctdate]; .... (void)schedulelocalnotificationwithdate:(nsdate *)firedate { uilocalnotification *localnotification = [[uilocalnotification alloc] init]; localnotification.firedate = firedate; localnotification.alertbody = [nsstring stringwithformat:@"alert fired @ %@", firedate]; localnotification.soundname = uilocalnotificationdefaultsoundname; localnotification.applicationiconbadgenumber = numberreminder; [[uiapplication sharedapplication] sche

php - how do i call the previous page's random value to another page? -

guys main page <?php $random = rand(4, 5); $random2 = rand(1, 12); $random3 = rand(1, 60); $random4 = rand(1, 60); $random5 = rand(1, 60); if ($random2 % 4 != 0) { $random2 += 4 - ($random2 % 4); $call = $random; } else { $random2 += 4 - ($random2 % 4); $call = $random2; } $answer = $random * $random2; ?> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> <link rel="stylesheet" href="css/main.css" type="text/css"/> <link rel="stylesheet" href="css/easy2.css" type="text/css"/> <title> easy game 2 </title> <center> <h1> easy game 2 </h1> <h2> multiple choice! </h2> <div class="border_solid"> <div id="timer"></div> </div> <hr&

Android Studio NDK OpenCV: c++ code can't work with Mat -

this question has answer here: passing cv:mat android jni 1 answer i included opencv native code in app in android studio. , wrote test function: jniexport jint jnicall java_com_atapy_wisetrend3_mainactivity_search(jnienv *env, jclass type, cv::mat image,cv::mat croppedimage) { croppedimage = image; return 1; } but when call function search, execution of calling function in java stops without errors. in logcat have message: "fatal signal 11 (sigsegv) @ 0x11c00041 (code=1), thread 16754 (tapy.wisetrend3)". if erase line "croppedimage = image" function succeeds , returns 1. happens operations mat. what mean? i'm not sure trying do. cv::mat wrapper of actual mat.data . usually, 1 doesn't want direct assignment image=croppedimage , specially when passed argument. if want copy image data, croppedimage.copyt

loops - How can i do calculations on Textview setText Android -

how can add value of n 2 ?, ie., n+2 textview output should 4 . int n=2; private void tvm() { if (n<=maxcount) { n++; textview.settext("counter:"+ n+2); } int n=2; private void tvm() { if (n<=maxcount) { textview.settext("counter:"+ string.valueof( n+2)); n++; }

node.js - Check versions in package json against actual node_modules -

imagine situation: we have project node_modules gitignored. while fixing task developer1 updated package.json newer version of module, e.g. "dependencies": { "async": "^1.5.2", // 1.5.1 ... then runned npm install locally updated module, performed tests, finished task , pushed changes on server. developer2 pulled changes server , app broken because still having previous version of async locally (1.5.1). , developer2 can waste huge amount of time finding what's goes wrong. until npm i . can suggest npm package or ready-to-use hook can check versions in package.json against actual versions of node_modules ? it helpful! ps: i'm aware of https://www.npmjs.com/package/npm-check not need. at current day job had problem. fixed creating easy script pulled new source , after directly executes npm update.

c# - How to open Excel in windows 10 at the background without "Save as" -

this code opens excel @ background no issue on windows 7 , 8, on windows 10 pops out "save as" prompt. have idea how can rid of "save as" prompt? object misvalue = system.reflection.missing.value; xlapp = new excel.application(); //xlapp.visible = false; // not rid of save //xlapp.displayalerts = false; // not rid of save //xlapp.screenupdating = false; // not rid of save xlworkbook = xlapp.workbooks.open(excelfileurl, 0, true, 5, "", "", true, microsoft.office.interop.excel.xlplatform.xlwindows, "\t", false, false, 0, true, 1, 0); xlworksheet = xlworkbook.worksheets.get_item(1); try this: excelworkbook.saveas(excelfileurl, accessmode: excel.xlsaveasaccessmode.xlexclusive);

How to make google chart API responsive? -

i creating 2 charts line chart , donut chart on same html page using google js api. these charts not responsive. how can make charts responsive? the google charts api not designed responsiveness in mind, specifically. default size of chart fill element it's being rendered into, can use css , media queries make responsive design. the real problem once chart drawn, doesn't change it's size in desktop window resize-type scenario. in angular google chart listen window's resize event , redraw chart. i've seen of resize strategy paired bit of javascript keep chart same aspect ratio no matter how wide is. anything more specific need more detailed question. intentionally not including code answer, because whatever write wrong situation.

cakephp - how show css in header with response? -

i have cms on cakephp have css of site text in component how attach on page css file? cose : ob_start("ob_gzhandler"); $this->controller->response->sharable(true, 86400); $this->controller->response->expires('+1 days'); $this->controller->response->type('text/css'); $this->controller->response->body($css); echo $css but show on page html cod , css on page all css code in variable, want use normall css file : . variable in component. in fact, have component component read style files , keep them until combine

certificate - Docusign code changes after certified inegrator key -

i have completed docu-sign certification process , integrator key in certified.i have change url https://demo.docusign.net https://docusign.net , using account authentication. still redircted demo.docusign.net signing process, other changes need done after certification process , before go production. kindly guide me same. the post certification guide can found here your production url should https://{server}.docusign.net/

visual studio 2015 - Windows IOT: Failed to start package BlinkyHeadless -

Image
i have been working on windows iot , raspberry pi 2 bit now, work through visual studio 2015. things going fine until wanted run app without visual studio (standalone mode), thats when things started make me go crazy. the app runs fine in debug, moment go iot web interface run standalone, "failed start package blinkyheadlessvb...". im running exact copy of samples microsoft blinkyheadless. i have tried building in release mode , deploy, same result (fine through vs failed start itself). raspberry pi running in headless mode. tried checking box "do not launch, debug code when starts", same thing, cannot run web interface. tried building appx file , install through web interface, same thing. im going crazy, error says failed without explanations anywhere (at least none find). i feel im missing simple (and stupid). anybody have ideas? googled hours , couldn't find working solution. your appreciated.. environment details: host machine: window

networking - Attempting to understand Tor and it's relation to SSL -

i'm mathematics student trying understand tor. have little knowledge of networks , how function. up i understand basic functionality of tor. route generated first consensus list, , packet (the message) sent through route. packet encrypted multiple times using public keys obtained consensus list, , each relay strips away layer of encryption before sending on next relay (side question: how work bridge relays? message sent bridge relay first , public tor network, or move exclusively through bridge relays?). means destination ip , ip of sender never in same header of packet , gives tor relative anonymity. very notice ssl brought when discussions regarding tor made. understand ssl encrypts data sent between client , server. if case don't see how ssl related tor, since seemingly function on different layer. edit: more specifically, i'm reading how iranian , chinese authorities did "deep package inspection" (i'm assuming means looked @ contents of each pack

Django model inheritance: share table with parent model -

we use django.contrib.flatpages in our project. @ point, decision made extend django.contrib.flatpages.flatpage model monkey patching 2 fields, which, @ time, didn't seem bad solution. want rewrite subclassing model make bit more readable. however, stick existing table django flatpages this: class meta: db_table = 'django_flatpage' without creating additional tables, has data (including 2 said fields), , don't want touch database much. now, question itself. there clean way it? also, should able register model in django admin, if changes anything.

javascript - How to download a file to memory casperjs -

i'm beginner programmer in casperjs , i'm trying download files webpage , save on memory. i'm able save temp folder, wondering if theres better way. function downloadfile(newurl){ var fileext = newurl.replace(/^.*[\\\/]/, ''); var path = 'c:/windows/temp/' + fileext; casper.download(newurl, path); }

python - Reading all sections in a config file -

my idea fetch component versions installed in different labs across world. code works when give details explicitly. my code follows def uk_pdl_he(): uk_pdl_list = {} sorted_list = {} slist = {} he_string = "uk_pdl_he" global config config = configparser.rawconfigparser() print config.sections() config.read('config.cfg') env.user = config.get('uk_pdl','db.user_name' ) env.password = config.get('uk_pdl','db.password' ) host = config.get('uk_pdl','db.ip' ) settings(hide('warnings', 'running', 'stdout', 'stderr'), warn_only=true, host_string=host): paramiko.util.log_to_file('uk_pdl.log') files = run('ls -ltr /opt/nds') open("uk_pdl.txt", "w") fo: fo.write(files) components = [] open("uk_pdl.txt", 'rb') fo: strings = ("/installed/")

ios - Localization of Launch Screen XIB not working properly -

in app use launch screen xibs splash screens 6 different local languages. localization works fine. app takes proper launch xib proper language @ time of install, changed language after install , launched app again, launch xib remains same old language.

ruby on rails - Dynamic url_for with varying amount of nesting -

i'm building helper method allows me pass array options available management of object (like edit, delete, etc.). simplified version of method looks this: def management_links(instance, actions, *parent) actions.each |action| if (can? action, instance) has_options = true case action when :destroy options = {content: glyphicon('trash') + " delete #{instance.class.to_s}", class: "delete #{instance.class.to_s.downcase}", method: :delete} url = url_for [parent, instance] end end end end as can see works objects nested once (passing 1 parent model) structure: parent_model/parent_id/model/id/action but have model nested twice, won't cut anymore. tried passing array [@grandparent, @parent], doesn't work since url_for has array. is there way allow me passing 'unlimited' parent objects work url_for? *parent part of array (if present), why not

mysql - ER diagram - avoiding one-to-one relationship -

Image
i've been working on er diagram university project. transport company. company particular jobs other companies , each job, there 3 types of documents needed, , documents have unique identifiers among other documents of same kind. did made these types of documents separate entities. when want join them(call them doc1, doc2, doc3) 1 entity(call job), made 1 job , no other. also, job has 1 of each of these documents, therefore looks relationships between documents , job one-to-one. however, when professor teaching er models, told should avoid drawing one-to-one relationships(that there should way make these documents kind of attributes of job). want know - correct draw identifiers of these documents attributes of job, , make them foreign keys referencing corresponding fields in documents' table(in relations model)? or there other, more elegant way connect them somehow avoiding these one-to-one relationships? also, if way, guess should make 3 columns representing documents'

indexing - Getting Error While Creating Text Index in MongoDB -

db.inventory.createindex( {'category.name': 'text', 'brand.name': 'text', 'name': 'text', 'store.name': 'text', 'collection_1' : 'text', 'sku' : 'text', 'parent_sku' : 'text' }) while using commands getting error "exception: namespace name generated index name" i'm using because m creating full text index in application.. have required many fields search index.. should have do...???? you error when auto generated index name long. index name generated concatenating different column names, however, length limited 125 characters according documentation . can resolve error manually specifying shorter index name when creating index: db.inventory.createindex({ 'category.name': 'text', 'brand.name': 'text', 'name': 'text', 'store.name': 'text&#

c++ - How to understand foo(char (&p)[10])? -

#include <iostream> void foo(char (&p)[10]) { printf("%d\n", sizeof(p)); } char p[10] = "aaa"; int main() { foo(p); } that code output 10 , can't understand. what meaning of char (&p)[10] here? the argument function foo reference ( & ) char array of 10 elements ( char ... [10] ). name of argument p . reference means specify argument as-is (no pointer or address needed), calling foo(p) in main correct way given how p declared. function foo prints 10 because argument 10 bytes in size.

css - How to show full field for Bootstrap input date fields? -

Image
when use boostrap create date input field has limited width <input type="date" id="my_date" name="my_date" class="form-control" style="width:80px"> the value (or placeholder) covered control icons when field focused; fine. when field not focused, place control icons placed if focused takes white space. is there workaround field shows full content if not focused? try code. when hover buttons displayed. if text still hidden, try make smaller font, or less padding. css #my_date::-webkit-inner-spin-button { -webkit-appearance: none; display: none; } #my_date:hover::-webkit-inner-spin-button { display: block; }

c# - How the "using" keyword Improves Performance (memory or speed wise) -

i working on image processing scripts in .net , came across following article outlining how crop, resize, compress, etc. in first comment , states methods used in article imaging notorious memory leaks: a quick warning thinking using system.drawing (or gdi+) in asp.net environment. it's not supported microsoft , msdn (as of recently) states may experience memory leaks. then, in second comment, article author says "i've handled problem": just make clear code above isn't thrown together. evolved time because suggested easy mistakenly create performance issues when using gdi+. just see how many times i've written 'using' above! i wondering how (or if) use of using handles (or improves) memory leak problems referenced in first comment. the using statements don't anything performance wise. calling dispose method on objects using declared on. calling dispose allow unmanaged resources, gdi+ creates imag

Google Create Contact Api v3 - in batch request all contacts got contactID but only few got inserted -

i tried insert 4000 contacts using google create contact api client library using batch request. google returned 4000 google contact ids. when try fetch contacts using contact ids, observed around 1000 contacts inserted , remaining empty contacts. cross checked in google contacts ui , via api also. reasons problem. samplecode: batchutils.setbatchid(newentry, "create"); batchutils.setbatchoperationtype(newentry, batchoperationtype.insert); requestfeed.getentries().add(newentry); //requestfeed contactfeed , newentry contactentry posturl=new url("https://www.google.com/m8/feeds/contacts/default/full/batch?xoauth_requestor_id=" + loginuser); contactfeed responsefeed =conservice.batch(posturl,requestfeed);

tsql - Computed Column - as Primary key -

i have following computed column within create table function: create table test ( code1 nchar(10), code2 nchar (10), type nchar(10), final case when len(code1)>0 code1 when len(code2)>0 code2 else type end ); alter table test add constraint pk_test1 primary key (final) but getting following error "cannot define primary key constraint on nullable column in table". this because code 1, code 2 , type can null, 3 never null. 1 of them have value. is there anyway can define computed column primary key above in mind? many - jt your computed column needs persisted , not null used primary key; create table test ( code1 nchar(10), code2 nchar (10), type nchar(10), final case when len(code1)>0 code1 when len(code2)>0 code2 else type end persisted not null ); an sqlfiddle test with .

python - How to generate lists from a specification of element combinations -

i want generate bunch of lists using combinations of elements specified in form following: [[10, 20], [30, 40], [50, 60]] this means values available first element 10 , 20, values available second element 30 , 40 , on (i've used 2 element options each element brevity; there more that). want use specification generate lists using combinations of these elements (including possibility of not having any), generating following: [10] [20] [10, 30] [10, 40] [20, 30] [20, 40] [10, 30, 50] [10, 30, 60] [10, 40, 50] [10, 40, 60] [20, 30, 50] [20, 30, 60] [20, 40, 50] [20, 40, 60] i feel though itertools used this, i'm not sure how implement algorithm generate lists this. good, general way (i.e. not limited 3 elements 3 hardcoded nested loops, instance) generate lists specification i've shown above? as attempt, i've got following: import itertools element_specifications = [[10, 20], [30, 40], [50, 60]] lists = [list(list_configuration) list_configuration in list

apache - Php url rewrite and redirect in htacess -

i want redirect site friendly. have website pull data database , adress /post?id=1 , want change /post/1 wrote code rewrite cant make sense google research how redirect /post/1. my code options +followsymlinks rewriteengine on rewriterule ^post/([^/.]+)/?$ post.php?id=$1 [l] use: options +followsymlinks rewriteengine on # external redirect actual url pretty 1 rewritecond %{the_request} \s/+post\.php\?id=([^\s&]+) [nc] rewriterule ^ /post/%1? [r=301,l,ne] # internal forward pretty url actual 1 rewriterule ^post/([^/.]+)/?$ post.php?id=$1 [l,qsa,nc]

swift - Ios popToRootViewControllerAnimated causing Memory Issues -

i making spritekit game. when player dies, goal have game transition start screen. accomplished code below. however, notice memory increases each time new game begins. xcode instruments not showing memory leak. when memory reaches 150mb games frame rate drops , game become unplayable. in gamescene call function when player dies func gameover(){ if let block = gameoverblock { worldnode.removeallchildren() worldnode.removeallactions() worldnode.removefromparent() self.removeallchildren() block() } } back in gameviewcontroller following functions called scene!.gameoverblock = { [weak self] in self!.goback() } } func goback(){ scene!.removefromparent() navigationcontroller!.poptorootviewcontrolleranimated(false) return } if has ideas how can accomplish without memory leak, appreciated. after commenting out tons of code, have found problem. methods have posted above not causing leak

SOLID and unit testing. Using language provided methods/classes -

so i've read thing called solid (mixed with) writing testable code . , d part. how 1 follow these guidelines when using primitive types or methods/classes provided language library. does 1 need use dependency injection arrays (java ( new int[64] ) or class members of say, filewriter?. these need injected using di or can class still instantiate them? how far should go following above guidelines? i not looking language-specific answer (if possible). imho answer should apply to, ex, php, python java, heck, c you don't inject primitives or dto / pojo -like objects. reason are: simple value holders without business/domain logic associated easily stubbed without tools (creating array of fake data test not problematic) filewriter different it's in exact opposition points above. can't stub in test , make work without few strong assumptions - like, assume every future developer running code have file on machine. no-go unit tests , 1 of reasons why

I want to add my own style pop-up dialogue box in my android app as shown in image -

Image
this question has answer here: android custom popupwindow/dialog 2 answers as shown in image above part layout , want add pop-up part below in image.so how can create , how can handle dialogue box button event.?? public class popupforeditactivity extends activity { @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.alphabetslist); callalertdialoguecustom(); } public void callalertdialoguecustom(){ final dialog dialog = new dialog(popupforeditactivity.this); dialog.setcontentview(r.layout.popup); // custom layout dialog.settitle("this custom dialog box"); dialog.setcancelable(true); //there lot of settings, dialog, check them out! //set text textview text = (textview) dialog.findviewbyid(r.id.txt1); text.settext("lots