Posts

Showing posts from March, 2014

profiler - how to check for memory leaks in android app developed in kony platform -

i have got hybrid android app developed using kony platform. need identify memory usage of app. please me tools used identify memory usage , memory leaks ? you can use android tools mentioned in below link, https://developer.android.com/tools/debugging/debugging-memory.html also, kony provides profiling option, in turn relies on native tools provided android. hope answers.

c# - Extracting same properites to style in WPF XAML -

i'm stuck extracting properties element's style in xaml file. have many repeated blocks like: <controls:roundabletoggleradiobutton style="{staticresource roundabletoggleradiobuttonstyle}"> <stackpanel> <image width="32" margin="2" source="images/inbox_upload.png" /> <textblock margin="2" foreground="white" text="extract" textalignment="center" /> </stackpanel> so want extract same properties every button style , able change image , text. this: <setter property="contenttemplate"> <setter.value> <datatemplate> <stackpanel> <image width="32" margin="2" /> <textblock margin="2" foreground="white" textalignme...

c# - EF6 Lambda Query Error: Unable to create a constant of type ... Only primitive types of enumeration types are supported in this context -

i keep getting following error when execute query below. i'm not sure how else put in condition. haven't been able find same issue other questions have posed same error output. unable create constant value of type 'project.models.bill'. primitive types or enumeration types supported in context. the code: var billresults = db.database.sqlquery<bill>("exec [dbo].[sp_getbills]").asqueryable(); var results = db.bills.select( => new { a.id, a.col1, a.col2, errorcount = (int) (billresults.where(x => x.billresultsid == a.id).count()) }).where(a => a.col1 == "test123"); i'd appreciate - been stuck past few hours on this. thanks! the error says cannot use a.id in expression, constant values. a.id depends on clause of db.bills query. y...

Google Sign IN in android application -

how can google sign in android application without using google plus . need sign in of google in app sign in facebook screen appeared ask fill username , password , click on sign in button. i had sign directly using google play library , want prompt comes , ask username , password . i got problem using google plus if body had google account not activated google plus account can in case? i want google sign in way there way please give me solutions possible . hi can use following approach: first of all, ask user enter email id in edittext , value on click of button, , proceed below: //check whether account configured or not if(isaccountalreadyconfigured(emailid)){ //if email id entered user configured in device getgoogleapiclientinstance(emailid); connecttogoogleapiclient(); }else{ //if email id account not configured in device ...

ruby on rails - Figaro Gem Config Issues -

i'm trying setup figaro in rails 4, after setting correctly yaml such application.yml aws_access_key_id:'#' aws_secret_access_key:'#' fog_directory:'#' carrierwave.rb carrierwave.configure |config| config.fog_credentials = { provider: "aws", # required aws_access_key_id: env["aws_access_key_id"], # required aws_secret_access_key: env["aws_secret_access_key"], # required } config.fog_directory = env["fog_directory"] # required end i keep getting error `global_configuration': undefined method `reject' #<string:0x007f9c7a0d9a80> (nomethoderror) i've looked similar problems haven't found right answer, yaml worked on http://www.yamllint.com/ the yaml file super sensitive , though passed on http://www.yamllint.com/ ...

java - Android Manifest Permissions issues -

i followed tutorial online how create simple app can switch on , off phone's cam-light. <manifest....> <uses-permission android:name = "android.permission.camera"/> <uses-feature android:name = "android.hardware.camera"/> </manifest> this in android manifest. problem: crashes when press on button (made me, in application) stack trace: 07-17 22:27:13.990: e/androidruntime(1775): fatal exception: main 07-17 22:27:13.990: e/androidruntime(1775): java.lang.nullpointerexception 07-17 22:27:13.990: e/androidruntime(1775): @ com.example.salpa.mainactivity$1.onclick(mainactivity.java:33) 07-17 22:27:13.990: e/androidruntime(1775): @ android.view.view.performclick(view.java:4204) 07-17 22:27:13.990: e/androidruntime(1775): @ android.view.view$performclick.run(view.java:17355) 07-17 22:27:13.990: e/androidruntime(1775): @ android.os.handler.handlecallback(handler.java:725) another strange thing: when install app, there no de...

prototype - JavaScript unable to access same object method after object.create(baseObject) -

i new javascript. have written code incorporating suggested answers. code block working in once scenario , not working in other scenario. <script langugage="javascript"> var baseobject = { name:"sunrise", age:39, printproperties:function(){ console.log("base class-> name:age:"+this.name+":"+this.age); } } baseobject.printproperties(); console.log(baseobject); /* code block works fine */ var derivedobject2=object.create(baseobject); derivedobject2.education="m.c.a" derivedobject2.printproperties=function(){ console.log("derived -> name:age:education:"+this.name+":"+this.age+":"+this.education); } derivedobject2.printproperties(); console.log(derivedobject2); /* derivedobject.__proto__ = baseobject; derivedobject.printproperties(); // works fine */ /* code block not work */ var derivedobject=object.create(baseobject,{ education:{...

android - Pressing button through fragment -

i'm trying create application fragment on side menu bar. my main problem when open fragment can see buttons behind , press them. of course don't want that. tried adding property android:clickable="true" layout didn't help. this code: <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" android:paddingbottom="@dimen/activity_vertical_margin" tools:context="ibuy.ibuy.addupdateitem"> . . . <button android:layout_width="wrap_content" android:layout_height="wrap_content" ...

iphone - Issue: iOS UITableView scrolling stops other task -

i developing application running based on async socket communication on tcpip. aim of app fetch data cyclicly(2 second) server , list down datas on tableview. up point have done coding , everything. app working fine. however, when start scrolling in uitableview, cyclic fetching stops until tableviews declares end of scrolling. instead of adding codes adding sample code having same behavior. in sample project have created timer. there label show counter , button start/stop timer on screen. in screen have added uitextview has quite long text have scrolling enabled. here code #import <uikit/uikit.h> int i; @interface viewcontroller : uiviewcontroller{ } @property (strong, nonatomic) nstimer *timer; @property (strong, nonatomic) iboutlet uilabel *label; @property (strong, nonatomic) iboutlet uibutton *txtbtn; - (ibaction)btnstartstop:(id)sender; @end #import "viewcontroller.h" @interface viewcontroller () @end @implementation viewcontroller @synt...

memory leaks - GPU throws "CL_OUT_OF_RESOURCES" for any programs -

whatever program ran on gpu, if programs ran before, gpu throws error: cl_out_of_resources clenqueuereadbuffer function. then remembered ran deep learning framework last night crashed , may ate memory on gpu. tried restart computer, doesn't work. is possible gpu ran out of memory due dl framework's crash? if so, how should solve problem? cl_out_of_resources generic error given nvidia implementation @ clenqueueread , more or less means: something went out of bounds (resources) when trying write buffer most kernel launched before writes buffer went out of bounds of buffer.

metaprogramming - Multiple @:build macros -

to give class multiple build macros, stacked @:build() tags. updated dev haxe, , it's recognizing last tag. syntax changed recently, or bug? @:build(macros.thismacrodoesntrunatall()) @:build(macros.thismacroworksnormally()) class test { i don't remember dev version of haxe used on, after 3.2.0 master release. it's haxe bug, , seems simon aware . oh well.

apply command to list of files in python -

i've tricky problem. need apply specific command called xritdecompress list of files extension -c_ , should python. unfortunately, command doesn't work wildcards , can't like: os.system("xritdecompress *-c_") in principle, write auxiliary bash script for cycle , call inside python program. however, i'd not rely on auxiliary files... what best way within python program? you can use glob.glob() list of files on want run command , each file in list, run command - import glob f in glob.glob('*-c_'): os.system('xritdecompress {}'.format(f)) from documentation - the glob module finds pathnames matching specified pattern according rules used unix shell. if _ (underscore) , wanted match single character , should use - ? instead , - glob.glob('*-c?') please note, glob search in current directory according wanted original trial, seems maybe want. you may also, want @ subprocess module, more pow...

How to switch D'Link CCTV wireless SSID without using a LAN cable -

ok, here got more comprehensive solution switch d'link cctv wireless ssid or change password without physically touching on device or using lan cable tedious job. this guide useful change new router / or change wireless password @ home/office , cctv located @ top roof or area difficult them take them off (cctv use wireless connected with). existing router = (192.168.0.1) new router = b (192.168.2.1) --switching router ssid-- make sure still can connect dlink cctv using existing router a. look ip address of dlink cctv @ dhcp list (example : 192.168.0.101) access directly http://192.168.0.101/ , enter username/password. go setup > wireless setup. click on "site survey" button. select new router b. change "pre-shared key" passsword (make sure password correct or else screwed up) restart dlink cctv powering physically (or restart @ admin page). the dlink cctv should connect router b after being restarted. --switching password of ssi...

c# - Reuse UserControl in TabControl with Various ViewModels -

i have 1 user control reuse multiple viewmodels, implement same interface. have these embedded in tabcontrol. currently can single instance struggling reuse usercontrol. single instance can either bind viewmodel in usercontol's xaml or instantiate in code behind, can't figure out how set higher level. here have, <tabcontrol horizontalalignment="left" height="800" margin="0,0,0,0" verticalalignment="top" width="600"> <tabitem header="tab1"> <frame source="someusercontrol.xaml" borderthickness="0" margin="0" /> </tabitem> </tabcontrol> here pseudo code achieve, <tabcontrol> <tabitem header="tab1"> <frame source="{someusercontrol.xaml, datacontext=viewmodel1}" /> </tabitem> <tabitem header="tab2"> ...

c# - Incorrect syntax near ')'. while creating table -

i newbie sqlserver , have came across error : system.data.sqlclient.sqlexception (0x80131904): incorrect syntax near ')'. @ system.data.sqlclient.sqlconnection.onerror(sqlexception exception, boolea n breakconnection, action`1 wrapcloseinaction) @ system.data.sqlclient.sqlinternalconnection.onerror(sqlexception exception , boolean breakconnection, action`1 wrapcloseinaction) @ system.data.sqlclient.tdsparser.throwexceptionandwarning(tdsparserstateobj ect stateobj, boolean callerhasconnectionlock, boolean asyncclose) @ system.data.sqlclient.tdsparser.tryrun(runbehavior runbehavior, sqlcommand cmdhandler, sqldatareader datastream, bulkcopysimpleresultset bulkcopyhandler, tdsparserstateobject stateobj, boolean& dataready) @ system.data.sqlclient.sqlcommand.runexecutenonquerytds(string methodname, boolean async, int32 timeout, boolean asyncwrite) @ system.data.sqlclient.sqlcommand.internalexecutenonquery(taskcompletionsou rce`1 completion, string method...

python - pip fails to install anything, error: invalid command 'egg_info' -

i downloaded python website in addition python version comes mac osx. when began have problems installing packages pip. sudo pip install -vvv pygoogle will output following: the directory '/users/robot/library/caches/pip/http' or parent directory not owned current user , cache has been disabled. please check permissions , owner of directory. if executing pip sudo, may want sudo's -h flag. directory '/users/robot/library/caches/pip/http' or parent directory not owned current user , cache has been disabled. please check permissions , owner of directory. if executing pip sudo, may want sudo's -h flag. collecting pygoogle getting page https://pypi.python.org/simple/pygoogle/ starting new https connection (1): pypi.python.org "get /simple/pygoogle/ http/1.1" 200 233 1 location(s) search versions of pygoogle: * https://pypi.python.org/simple/pygoogle/ getting page https://pypi.python.org/simple/pygoogle/ "get /simple/pygoogle/ ht...

javascript - AB Testing (GA) - Menu bar changes for multiple web pages -

i using google analytics ab testing. did test using multiple variations 1 page without using redirects this article , worked well. i want use same test menu of website. css changes , planning on using jquery change class of menu depending on variation user gets. my main concern whether possible achieve. if include ga code layout code, should have condition see if menu available page run test? need add url's other pages have menu? or do test similar how 1 in article like? if has done test this, advice appreciated. 1st - relevant audience make sure have equal possibility display menu both tested groups (menu available visitors) - original variant - changed menu variant 2nd - custom dimensions create custom dimension in google analytics (session scope) 3rd - decision mechanism use math.random() reach 50% probability each variant. dave information cookie , since time, use variant particular user time test running 4th - set ga tracker ga("set...

Debugging a java jar file -

i have jar file , don't have source. should connect server. doesn't run @ first time , need run second time. trying find way it's logs. how can enable it's logs? here how call it java -xms512m -xmx512m -jar mcon.jar i have found , tried code below think server sockets java -xdebug -xrunjdwp:server=y,transport=dt_socket,address=4000,suspend=n -jar mcon.jar what found correct not need address , remote debugging connect server from command line , need is java -agentlib:jdwp=transport=dt_shmem,address=jdbconn,server=y,suspend=n -jar mcon.jar then can connect java debugger jdb -attach jdbconn you can refer doc find out command can use

php - codeigniter mysql sql query -

hello mysql query can output example , how can echo. need here's example.. 'table 1 | id |date | | 1 |01/01/2015 | | 2 |01/02/2015 | | 3 |01/01/2015 | | 4 |01/02/2015 | 'table 2 |id |table1_id| value1| value2| | 1 | 1 | 5 | 2 | | 2 | 2 | 40 | 3 | | 3 | 3 | 5 | 2 | | 4 | 4 | | 4 | output must $value_total = value1 * value2; if(value1 == ''){ }else{ $value_total = value1 * value2; } here's final output. add same date date value 01/01/2015 20 01/02/2015 120 try this if(!empty(value1){ $value_total = value1 * value2; }

java - How do I convert a Windows-1251 text to something readable? -

Image
i have string, returned jericho html parser , contains russian text. according source.getencoding() , header of respective html file, encoding windows-1251. how can convert string readable? i tried this: import java.io.unsupportedencodingexception; public class program { public void run() throws unsupportedencodingexception { final string windows1251string = getwindows1251string(); system.out.println("string (windows-1251): " + windows1251string); final string readablestring = convertstring(windows1251string); system.out.println("string (converted): " + readablestring); } private string convertstring(string windows1251string) throws unsupportedencodingexception { return new string(windows1251string.getbytes(), "utf-8"); } private string getwindows1251string() { final byte[] bytes = new byte[] {32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, -17, -65, -67, -17, -...

angularjs - Continuous Integration/Deployment - MEAN Stack Project based on 2 Git Repositories -

i starting new project using mean stack. front-end , back-end in 2 different git repositories, hosted on bitbucket. each project/repo has own unit/e2e tests. backend restful json api , front-end angularjs spa. grunt task available in front-end project output optimised/minified version of client code. my idea first run unit/e2e tests on client's code, "grunt deploy" task, somehow automatically commit result of grunt task backend project/git repo, run unit test of backend code , deploy backend project on amazon. i not sure how setup kind of project on platforms travis or codeship it's using 2 git repo instead of one... if has experience/recommendation setup one, appreciated. cheers, niko avoid hand-crafted solutions as possible, e.g. copying/committing files across repositories - lead pain , maintenance nightmare. use standard tool this. the standard way of handling dependencies these using dependency management tool. on backend, typically usin...

Using :owner in Ruby on Rails -

sorry simple , maybe stupid quation. in model have next line code: belongs_to :owner, polymorphic: true i cant found in project model owner. owner in rails , how use it? can found more information this? this association polymorphic. means in database have 2 columns: owner_id , owner_type , , in owner_type column have class name of associated model. you can read more here: http://guides.rubyonrails.org/association_basics.html#polymorphic-associations

android - How GridLayout works when specifying the columnspan and rowspan -

Image
i have made layout desing listview in android project. it's that; i have read , researched on other gridlayout samples , have written xml in accordance have got. <?xml version="1.0" encoding="utf-8"?> <gridlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/card_background" android:columncount="30" android:orientation="horizontal" android:rowcount="6" android:id="@+id/grid_layout_notification"> <com.ei.dizitakip.android.circlednetworkimageview android:id="@+id/fancy_notification_thumbnail" android:layout_columnspan="5" android:layout_rowspan="6" /> <textview android:layout_columnspan="25" android:textappearance=...

java - HibernateQueryException with mapping a class with a composite key with Hibernate version 2.1.7 -

i'm maintaining old software using hibernate 2.1.7c version (released 2004) object-relational mapping mysql-database. database table old , contains following columns: remoteid bigint(20) label varchar(255) locale varchar(255) primary key ('remoteid', 'locale') i'm trying create new class uses hibernate-mapping file map columns. mapping-file looks this: localizednames.hbm.xml <?xml version="1.0"?> <!doctype hibernate-mapping public "-//hibernate/hibernate mapping dtd 2.0//en" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd"> <hibernate-mapping> <class name="package.package.localizednames" table="localizednames"> <composite-id> <key-property access="field" column="remoteid" name="remoteid" type="java.lang.long"/> <key-property access="field" column=...

ios - AutoLayout programmatically cause issue in iphone 4 -

Image
i learning auto layout code. learning purpose doing sample apps using autolayout. in sample app decided keep text field below 20 points top margin. here code #import "sampleviewcontroller.h" @interface sampleviewcontroller (){ uitextfield *username; } @end @implementation sampleviewcontroller - (void)viewdidload { [super viewdidload]; self.edgesforextendedlayout = uirectedgenone; [self prepareviews]; } -(void)prepareviews{ username = [[uitextfield alloc]init]; username.placeholder = @"username"; [username setborderstyle:uitextborderstyleroundedrect]; username.translatesautoresizingmaskintoconstraints = no; [self.view addsubview:username]; [self prepareconstraint]; } -(void)prepareconstraint{ nslayoutconstraint *constraint = [nslayoutconstraint constraintwithitem:username attribute:nslayoutattributecenterx relatedby:nslayoutrelationequal toitem:self....

java - Regex - No match if trailing character is "-" -

i have regex below ^schedule\s?(a|b|c|d|e|f|h|j|k|l|m|r|se)? so match " schedule a need help". i want restriction character "-" i.e should not give match if string "schedule - need help" . but should give match if schedule followed other space , "-". negative aheads helpful here ^schedule\s*([abcdefhjklmr]|se)(?!\s+-) (?!\s+-) negative ahead, checks if matches string not followed space ( \s+ ) , - . note optional quantifiers ? not required causes regex engine skip them. [abcdefhjklmr] character class, matches single character set . regex demo

c# - Method containing foreach statment to have only one return -

i have following method prepared unit tests , know run for-each loop, there way rid of second return statement? public enums.gyrstatus getstatusfortransformer( string factorycode, enums.technology technology, string transformertype, int transformersize, string transformermodel) { fakestandardsandsizesfictionary = new dictionary<tuple<string, enums.technology, string, int, string>, int>() { { tuple.create("selud", technology.cvt,"---", 0, ""), 1} }; } foreach (var pair in fakestandardsandsizesfictionary) { if (pair.key.item1 == factorycode && pair.key.item2 == technology && pair.key.item3 == transformertype && pair.key.item4 == transformersize && pair.key.item5 == transformer...

java - Method chaining + inheritance don’t play well together? -

this question has been asked in c++ context i'm curious java. concerns virtual methods don't apply (i think), if have situation: abstract class pet { private string name; public pet setname(string name) { this.name = name; return this; } } class cat extends pet { public cat catchmice() { system.out.println("i caught mouse!"); return this; } } class dog extends pet { public dog catchfrisbee() { system.out.println("i caught frisbee!"); return this; } } class bird extends pet { public bird layegg() { ... return this; } } { cat c = new cat(); c.setname("morris").catchmice(); // error! setname returns pet, not cat dog d = new dog(); d.setname("snoopy").catchfrisbee(); // error! setname returns pet, not dog bird b = new bird(); b.setname("tweety").layegg(); // error! setname returns pet, not bird } in sor...

java - Getting resource from ExternalContext in Servlet -

in bean getting url of image this: externalcontext ec = facescontext.getcurrentinstance().getexternalcontext(); url url = ec.getresource("/myimagedirectory/image.png"); how can in httpservlet? i tried following, did not work: servletcontext sc = getservletcontext(); url url = sc.getresource("/myimagedirectory/image.png"); the httpservlet in same application bean. getservletcontext().getrealpath("/")+"/myimagedirectory/image.png"; the "/" represents web content root. more

function - How to get base of a random URL with PHP? -

i need function base of url. (urls submit users, , everything!) example: https://en.wikipedia.org/wiki/murphy%27s_law => wikipedia.org https://en.m.wikipedia.org/wiki/murphy%27s_law => wikipedia.org http://userpage.chemie.fu-berlin.de/diverse/murphy/murphy_e.html => fu-berlin.de http://www.murphyslawpetone.co.nz/ => murphyslawpetone.co.nz you need use domain name parser has information ever changing list of public suffixes, incorrectly referred "tlds". otherwise wrong results in cases. suggest take @ jemery kendalls php-domain-parser on github. comes documentation , examples. <?php require_once __dir__ . '/vendor/autoload.php'; use pdp\publicsuffixlistmanager; use pdp\parser; // obtain instance of parser $pslmanager = new publicsuffixlistmanager(); $parser = new parser($pslmanager->getlist()); $url = 'http://www.murphyslawpetone.co.nz/'; $urlobj = $parser->parseurl($url); $hostobj = $url->host; $baseu...

android - Running ProgressBar on busy UI thread -

i need work done on ui thread, means can't (that know of) display progressbar ui busy executing other tasks. i know sounds bit illogical, there way display indefinite progressbar on ui thread while ui thread busy? i aware of using runnables , asynctasks, i'd use them complete actual work if could, can these used displaying progressbar itself? just show textview loading... in it, or other static view (imageview progress, doesnt spin). other solution need work on ui. i check code in order free ui because if u use ui long user wouldnt able press or , feel the app stuck.

php - How can we have Static website on front end Yii -

i want create website in 2 modules 1st 5 static pages existing website. want add database , login access other pages other module. how can use existing website on first load clicking sign in redirect other module. i'm using yii 1.1.14 first, in default sitecontroller (or other controller if like), override actions() method follows, public function actions() { return array( 'page'=>array( 'class'=>'cviewaction', ), ); } second, create folder protected/views/site/pages. third, save each static page php file under folder. example, can save "about site" page about.php. note, these pages use application's default layout. therefore, main content needs saved in each file. we done! access static page, e.g., page, can use following url: http://www.example.com/index.php?r=site/page&view=about more detail in : http://www.yiiframework.com/wiki/22/how-to-display-static-pages-in-yii/ ...

asp.net mvc 5 - Image gallery in MVC 5 -

i'm working on image gallery (or products images) , getting weird error in uploadimagemethod in productscontroller. here's method, i'll explain error is: [httppost] public actionresult uploadimagemethod() { //make sure have files upload if (request.files.count != 0) { //parallel.for loop loop through each image being uploaded parallel.for(0, request.files.count, index => { //new httppostedfilebase hold each image httppostedfilebase file = request.files[index]; //get file size int size = file.contentlength; //get file name string name = file.filename; //save image our desired directory file.saveas(server.mappath("~/content/productimages/") + name); //now create new product , set it's properties product p = new product() { ...

Polymer.fire is not a function -

my web-component (polymer 1.0) changes light-dom given <content> , tries convert click custom event. <link rel="import" href="path/to/polymer.html"> <dom-module id="x-custom"> <template> <content></content> <!-- used way <x-custom><div></div></x-custom> --> </template> <script> (function() { function init() { var myroot = polymer.dom(this); var firstdiv = myroot.queryselectorall("div")[0]; var itemdiv = document.createelement("div"); itemdiv.textcontent = "yadda"; firstdiv.appendchild(itemdiv); itemdiv.addeventlistener("click", follow); } function follow() { console.log("follow"); polymer.fire("custom-event"); } polymer({ is...

email - How to use date and time received in a outlook mail in a event calender of outlook? -

like google calender, possible make functionality such when 1 register event website date , time, event added in outlook event calender automatically. i have found solution .ics file, not work. trigger error 'the file not valid internet calender file'. please solution. you can develop add-in can parse incoming emails , required actions if required. see walkthrough: creating first vsto add-in outlook more information. if deal exchange profiles in outlook may consider using ews. read more in ews managed api, ews, , web services in exchange article in msdn.

python - Mocking Django's RequestContext class -

i trying mock django's requestcontext class return key piece of data tests: here implementation: from django.template import requestcontext def oauth(request, provider): response = httpresponse() print(requestcontext(request)) --->>> prints out magic mock site_name = requestcontext(request)['site_name'] here test: @patch('core.views.authomatic') @patch('core.views.requestcontext') def test_new_user_redirects_to_sign_up_page( # noqa self, mockauthomatic, mockrequestcontext): mockrequestcontext.return_value = {'site_name': 'jacaranda'} print(mockrequestcontext()) --->>>> prints out dict my view prints out magicmock instance, doing wrong. go for @patch('core.views.requestcontext') @pa...

passing sqlplus output to a csh variable -

what correct csh syntax store output of sqlplus block? sqlplus -s / <<sql set feedback off set linesize 100 set lines 150 set pages 0 set head off set serveroutput on size 10000 select 1 dual; sql in example, i'd able assign value '1' variable in csh script. using shell variant not option. you need write variables in sql*plus file can source once control has returned csh program. note i'm showing how store output of sql*plus column value in sql*plus variable using column statement. can skip step if code simple, though worthwhile addition. sqlplus -s apps/apps@vis <<sql set feedback off set linesize 100 set lines 150 set pages 0 set head off set serveroutput on size 10000 column result new_value result select 1 result dual; prompt variable result = &result. spool output.csh prompt set result = &result. spool off sql source output.csh echo "back in csh , result = $result "

python - Update a increasing value by MySQL -

i have table in mysql, data this: +-----------+--------------------------------------+-------+ | address | subnet_id | major | +-----------+--------------------------------------+-------+ | 2.2.2.2 | 7ec1f191-476d-46cd-8fc9-0a8d24dfb8e9 | 0 | | 7.7.7.7 | 7ec1f191-476d-46cd-8fc9-0a8d24dfb8e9 | 0 | | 1.1.1.1 | 7ec1f191-476d-46cd-8fc9-0a8d24dfb8e9 | 0 | | 3.3.3.3 | 7ec1f191-476d-46cd-8fc9-0a8d24dfb8e9 | 0 | | 4.4.4.4 | 7ec1f191-476d-46cd-8fc9-0a8d24dfb8e9 | 0 | | 9.99.9.10 | 7ec1f191-476d-46cd-8fc9-0a8d24dfb8e9 | 0 | +-----------+--------------------------------------+-------+ i need update major column increasing number (from 0 1, 2, 3...) . example, update subnet_id equals'7ec1f191-476d-46cd-8fc9-0a8d24dfb8e9'. result should this: +-----------+--------------------------------------+-------+ | address | subnet_id | major | +-----------+--------------------------------------+----...

c# - Where clause with Join in lambda expression -

i using lambda expression clause join. here query var activeimages = db.tbl_advertise .where(i => i.isvisible == true) .join(db.tbl_shopmast.where(i => i.isvisible == true && i.fk_userid == userid), => i.fk_shop_id, j => j.shopid, (i, j) => new { advertise = i, shop = j}) .tolist(); or can right query : var activeimages = db.tbl_advertise .join(db.tbl_shopmast.where(i => i.isvisible == true && i.fk_userid == userid), => i.fk_shop_id, j => j.shopid, (i, j) => new { advertise = i, shop = j}) .tolist() .where(i=>i.advertise.isvisible == true); which 1 works faster? although have noticed both giving same output, way correct? with first query, where clause executed on database server, while second query executed on client machine. because of that, first query: the database server more work; the client machine less work; less data transfered server...

c++ - Rcpp How to change a value directly inside a R List -

i know how values list objet, , how create 1 within c function. but change value in list given parameter , modification effective when exiting function. some thing like: void myfunc(sexp *lst) ' list mylist (lst) // make modification } i need modify list within recursive loop. thanks in advance daniel there no magic. assign elements list object, , modify: r> rcpp::cppfunction("list foo(list l) { list l2 = l[0]; l2[1] = 42; return l2;} ") r> l <- list(list(0,1,2), 2:4, 3.3) r> foo(l) [[1]] [1] 0 [[2]] [1] 42 [[3]] [1] 2 r> we pick first element (and know list itself; there predicates testing). in list, set second element. can same returning original modified list: r> rcpp::cppfunction("list bar(list l) { list l2 = l[0]; l2[1] = 42; return l;} ") r> l <- list(list(0,1,2), 2:4, 3.3) r> bar(l) [[1]] [[1]][[1]] [1] 0 [[1]][[2]] [1] 42 [[1]][[3]] [1] 2 [[2]] [1] 2 3 4 [[3]] [1] 3.3 r> ...

php - Check if IP belongs to Belgium -

i need check users ip if it's belongs belgium country. i found list i.e: http://www.nirsoft.net/countryip/be.html but how can compare users ip these ips ? the solution suggested required basic programming , database skills. since not mentioned requirements, explain using use php , mysql in codes. download , load the ip2location lite db1 database mysql. can table definition page https://lite.ip2location.com/database-ip-country add following codes in php pages required detection. //configure mysql connection $host = 'localhost'; $user = 'root'; $password = 'your_password'; $database = 'ip2location_database'; $table_name = 'ip2location_db1'; //get visitor ip address $ip = $_server['remote_addr']; //in case testing locally 127.0.0.1, //you can uncomment below line assign ip address //to 8.8.8.8 (or whatever) testing. //$ip = '8.8.8.8'; try{ //create , perform sql query using pd...

login - Could not post data with Python -

this have far. attempting login , view members page can't seem accomplish that. appreciated! import requests s = requests.session() url = 'http://theocarinanetwork.com/login' uname = 'username' pw = 'password' headers = {'user-agent': 'mozilla/5.0 (x11; linux x86_64) applewebkit/535.11 (khtml, gecko) chrome/17.0.963.56 safari/535.11', 'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'accept-encoding': 'gzip,deflate,sdch', 'accept-language': 'en-us,en;q=0.8', 'accept-charset': 'iso-8859-1,utf-8;q=0.7,*;q=0.3'} data = {'uname':uname, 'pw':pw, ...

VBA byref argument type mismatch when calling a function from a function being called -

hope can help. simplification of set of code i'm working with. i'm calling function, , function calls function. variables passed calling sub first called function, should passed 2nd called function return value. however, i'm getting "byref argument type mismatch" error on below "parameter" in first function. suggestions? thanks! ' sub call function 1 sub testfunctionselect() dim x double ' x should = value of function msharemmtdaily called mfunctionselect x = mfunctionselect("msharemmtdaily", "sol", "2008/02/28", 12) end sub ' function 1 call function 2 , return value sub function mfunctionselect(functionname string, compcode string, currentmonth date, parameter double) double select case functionname ' case = "mvalue" ' mfunctionselect = mvalue(compcode, currentmonth, parameter) case = "msharemmtdaily" ' function calle...

ios - Core Data Performance issue while Saving -

i'm using core data of nssqlitestoretype store data in ios app. need store large amount of objects database. improve performance of core data, i'm considering many considerations like: saving batch wise saving after loop ends clearing context manage memory but taking time save 100k objects. please suggest me best practices improve performance of core data while saving large amounts of data. you should import on non-ui thread context bound directly persistent store coordinator, not child context of main contex you should invoke [managedobjectcontext save] once in every several hundreds of new objects inserted, depending on object size , graph complexity. see this answer details you should wrap batch step 2 in @autoreleasepool block , reset context after save before autorelease block exited. see this answer

IOS Wifi Configuration File for BYOD Devices -

is there type of file or script can made ios devices client can load on byod device automatically set wifi settings? don't want use apple configurator because don't want wipe device , apply policies or that. this set including connecting device wifi, setting ipv4 settings, dns settings, proxy settings, etc. or client have configure manually using instructions?

Length-1 Arrays and Python Scalars Via plt.text -

Image
i'm trying use plt.text plot temperature values @ associated lat/lon points on plot. after reviewing plt.text documentation, appears plotted value (third arg) has number , number has whole number, not number decimals. below code i'm trying work , associated traceback error i'm receiving: script code: data = np.loadtxt('/.../.../.../tmax_day0', delimiter=',', skiprows=1) grid_x, grid_y = np.mgrid[-85:64:dx, 34:49:dx] temp = data[:,2] #print temp grid_z = griddata((data[:,1],data[:,0]), data[:,2], (grid_x,grid_y), method='linear') x,y = m(data[:,1], data[:,0]) # flip lat/lon grid_x,grid_y = m(grid_x,grid_y) #m.plot(x,y, 'ko', markersize=2) def str_to_float(str): try: number = float(str) except valueerror: number = 0.0 return number fmt = str_to_float(temp) #annotate point temperature on plot plt.text(grid_x, grid_y, fmt, fontdict=none) traceback error: traceback (most recent call last): file "plo...