Posts

Showing posts from January, 2014

javascript - Do I need to enable CSRF protection? -

if none of post endpoints in api server consume application/x-www-form-urlencoded or multipart/form-data , need concerned csrf? understanding, csrf can executed through form-backed post requests. other kind of request requires use of xmlhttprequest , won't go through because of same origin policy. sure, can send json forms in modern browsers. applies application/x-www-form-encoded applies equally other form data encoding types. moreoever - there no guarantee support more types won't added in future there's that.

javascript - Angularjs Multidimensional array and two relative select boxes -

i have multidimensional array holds product names , versions. want create interface lets user select product select box, , version number in second select box. second select box should show versions numbers of product user selected in first select box. this mutidimensional array: [object]0: name: "product 1" versions: [array]0: number: "1.0" number: "1.5.2" 1: name: "product 2" versions: [array]0: number: "0.0" number: "0.5" the user has option choose multiple products, created array hold users selection. my controller setup this: app.controller('maincontroller', function ($scope) { $scope.products = [{id: 1, name: '', versions: []}]; $scope.packages = []; $scope.packages[0] = { id: 1, name: 'product 1', versions: [{number: 1.0}

java - Spring Integration: send object in json to jms -

i'm bit confused , need clarification: i'm trying transform object in json , send using jms each second. here context.xml: <bean id="connectionfactory" class="org.springframework.jms.connection.cachingconnectionfactory"> <property name="targetconnectionfactory"> <bean class="org.apache.activemq.activemqconnectionfactory"> <property name="brokerurl" value="tcp://localhost:61616" /> </bean> </property> <property name="sessioncachesize" value="10" /> </bean> <bean id="requesttopic" class="org.apache.activemq.command.activemqtopic"> <constructor-arg value="testconf" /> </bean> <bean id="confbean" class="demo.deviceconfiguration"> <property name="id" value="thermo_001" /> <property name=&qu

ios - selector is not called for navigationitem barbutton -

after set right bar navigation button custom view, selector never called when button pressed. here code: uiimageview *navview = [[uiimageview alloc] initwithimage:[uiimage imagenamed:@"notification_alert.png"]]; navview.frame = cgrectmake(0, 0, 40, 40); self.navigationitem.rightbarbuttonitem = [[uibarbuttonitem alloc] initwithcustomview:navview]; [self.navigationitem.rightbarbuttonitem settarget:self]; [self.navigationitem.rightbarbuttonitem setaction:@selector(btnclick:)]; the button appears correctly selector never called. appreciated! -(ibaction)btnclick:(id)sender { nslog(@"nav button clicked"); } from documentation init(customview:) : the bar button item created method not call action method of target in response user interactions. instead, bar button item expects specified custom view handle user interactions , provide appropriate response. see uibarbuttonitem class reference more information. a workaround use uibutton cus

ios - rounded navigation bar image iphone sdk -

Image
i trying set navigation bar's titleview rounded image. similar profile images see in messaging applications. i believe should able create rounded scaled down image doing following: uiimageview* profileimageview = [[uiimageview alloc] initwithimage:logoimage]; [profileimageview setframe:cgrectmake(0, 0, 30, 30)]; //profileimageview.contentmode = uiviewcontentmodescaleaspectfit; // xxx contentmode commented out because enabling causes rounded corners have no effect? profileimageview.layer.cornerradius = 15; profileimageview.layer.maskstobounds = yes; profileimageview.clipstobounds = yes; self.navigationitem.titleview = profileimageview; this appears create image desire split second when load emulator, image appears in top left corner of screen , snaps center of navigation bar. once @ center of navigation bar rescales take entire space of navigation bar instead of remaining small circle. missing? seems must need disable ever mechanism causing image scale fill entire naviga

sqlite3 - SQLite porting to STM32 having issue with memory allocation -

i trying port sqlite ucos rtos running in stm324xg_eval board. using micrium file system making ram based file system used sqlite. have tried different build configurations , used sqlite3_config api define different memory regions heap, scratch , page memory. able initialize (sqlite3_initialize) , open(sqlite3_open) db. when trying create tables(sqlite3_exec), getting errors "journal file not found", "out of memory". may issue thanks, shijo thomas

Mongoose / MongoDB replica set using secondary for reads -

i changed server setup include replica set. secondary dbs located in multiple regions around world decrease latency. problem think of reads being done master , not secondary servers. i'm seeing 500ms+ latency in newrelic on servers far away master db, staging server, in same region master ~20ms. how can check if secondary read or nearest working, or have setting missing / wrong? (i have tried both secondary_preferred, , nearest) url: mongodb://1.1.1.1:27017,1.1.1.2:27017,1.1.1.3:27017,1.1.1.4:27017,1.1.1.5:27017/mydatabase my options this: "replset": { "rs_name": "myrepset" "readpreference": "readpreference.secondary_preferred", "read_preference": "readpreference.secondary_preferred", "slaveok": true } mongoose version: 3.8.x as per project issues on github there issue read preference not seem working when upgrading newest version (mongoose@3.8.1 & mongodb@1.3.23

dplyr - How can I calculate the percentage change within a group for multiple columns in R? -

i have data frame id column, date column (12 months each id), , have 23 numeric variables. obtain percentage change month within each id. using quantmod package in order obtain percent change. here example 3 columns (for simplicity): id date v1 v2 v3 1 jan 2 3 5 1 feb 3 4 6 1 mar 7 8 9 2 jan 1 1 1 2 feb 2 3 4 2 mar 7 8 8 i tried use dplyr , summarise_each function, unsuccessful. more specifically, tried following (train name of data set): library(dplyr) library(quantmod) group1<-group_by(train,examid) foo<-function(x){ return(delt(x)) } summarise_each(group1,funs(foo)) i tried use function in dplyr, not successful either (having bad night guess!). i think issue delt function. when replace delt sum function: foo<-function(x){ return(sum(x)) } summarise_each(group1,funs(foo)) the result every variable summed across date each id. how can percentage change month-over-month each id? how using pct <- func

javascript - Print only jasmine focused tests -

Image
it difficult describe how useful , convenient "focused specs" feature of jasmine >=2.1 is. using fdescribe and/or fit can run specified tests without modifying protractor config. the problem output on console. it prints out every single spec matching pattern in protractor configuration . first, focused specs test results printed. information useful: using chromedriver directly... [launcher] running 1 instances of webdriver started open case screen should display correct url ... passed . should display summary description ... passed then, there huge output containing "disabled" tests (~20 seconds scroll down): click button after switching environment should redirect queue in previous environment ... disabled 1 of 1 passed (0 skipped, 1 disabled). ... 'you have been logged out.' alert message should show alert message after closing sessions in browser window ... disabled 1 of 1 passed (0 skipped, 1 disabled). success: 202 specs,

jquery - Making a header/menu bar for an off-canvas navigation menu fixed? -

i'm having trouble making element fixed off-canvas navigation design. http://codepen.io/stuffiestephie/pen/wajxxa (resize viewport it's less 1000px, header isn't visible otherwise.) in desktop styles, nav bar fixed, in mobile header isn't though have !important declaration $(".toggle-nav").click(function() { // calling function in case want expand upon this. togglenav(); }); function togglenav() { if ($('#drawer').hasclass('show-nav')) { $('#drawer').removeclass('show-nav'); $('#nav-icon').removeclass('open'); } else { $('#drawer').addclass('show-nav'); $('#nav-icon').addclass('open'); } } $('#closebutton').click(function() { $('#drawer').removeclass('show-nav'); $('#nav-icon').removeclass('open'); }); $("nav h3").click(function(){ $("

java - Add ArrayList into another ArrayList -

i have 2 classes: products : 01; desinfectante 02; aerosol 03; limpia vidrio 04; desengrasante 05; mata mosquitos 06; mata cucarachas 07; aceite en aerosol instructions : 01;1;elevar la masa hasta llegar tal punto;0;10 01;1;mezclar este material con anterior;1;15 01;2;relevar;2;5 01;3;llevar;00;0 02;1;descripcion;7;2 02;2;descripcion;6;2 02;2;descripcion;00;0 03;1;descripcion;1;1 03;1;descripcion;2;9 03;2;descripcion;00;0 03;3;descripcion;5;2 03;4;descripcion;6;2 03;4;descripcion;3;10 04;1;descripcion;00;0 04;2;descripcion;1;2 04;3;descripcion;1;0 04;3;descripcion;2;2 04;3;descripcion;3;2 04;4;descripcion;7;1 04;4;descripcion;6;2 05;1;descripcion;7;20 05;1;descripcion;6;9 05;2;descripcion;00;0 05;3;descripcion;1;2 05;3;descripcion;2;10 06;1;descripcion;2;12 06;1;descripcion;4;1 06;1;descripcion;6;8 06;2;descripcion;5;4 06;2;descripcion;7;2 07;1;descripcion;1;12 07;1;descripcion;2;2 07;2;descripcion;3;19 07;2;descripcion;4;4 07;2;descripcion;00;2 07;2;descripcion;5;12 the

java - JFXPanel Dynamic Sizing -

in process of converting swing fx. have jfxpanels within jinternalframes. when displaying new screen, fine because first setting scene , calling pack() method on jinternalframe. the problem lies screens new nodes added (typically based on choicebox selection) screen require panel wider. tries fit nodes in causing of labels become ellipsis. best way go having jfxpanel/jinternalframe resize when needed?

How to access variables in another scope inside a function using closure in javascript? -

i have following function makestopwatch trying work through better understand javascript closures: var makestopwatch = function() { var elapsed = 0; var stopwatch = function() { return elapsed; }; var increase = function() { elapsed++; }; setinterval(increase, 1000); return stopwatch; }; var stopwatch1 = makestopwatch(); var stopwatch2 = makestopwatch(); console.log(stopwatch1()); console.log(stopwatch2()); when console.log calls stopwatch1 , stopwatch2 0 returned each time respectively. as understand intended functionality of makestopwatch variable elapsed 0 if returned inner function stopwatch . inner function increase increments variable elapsed . setinterval calls increase after delay of 1 second. finally, stopwatch returned again time updated value expected 1 . but doesn't work because inside makestopwatch , inner stopwatch , increase , , setinterval functions in independent scopes of 1 another? how can revise work understand

How to use save() function in R when variable names are stored in a vector? -

i have vector varnames has "name" of variables "character". want save particular variables rdata using save(). how should go that? i trying following: > varset [1] "blah1" [2] "blah2" > str(vatset) chr [1:44] "blah1" "blah2" ... > foo <- lapply(varset, function(x) as.name(x)) as expected foo list of symbols. thinking of doing like eval(unlist(foo), file="filename") i guess unlist(foo) not working. how should solve issue? can clear concept why unlist(foo) not unlisting list of symbols? edit: adding artificial example > x <- c(1,2,3) > y <- data.frame(m=c(1,2), n=c(1,2,3)) i can save x , y. > save(x, y, file="filename.rda") but suppose have > varset <- c("x", "y") in example varset big set. need use varset save corresponding variables names stored. you can save data object as: save(varset, file="varset.rdata&

c# - How ways to return to "void" kind? -

i'm using on windows phone 8.1 try { var url = "https://...../oauth/authorize?client_id=" + uri.escapedatastring("4a3e...") + "&response_type=code&redirect_uri=" + uri.escapedatastring("http://localhost:8888/callback") + "&show_dialog=true"; var starturi = new uri(url); var enduri = new uri("http://localhost:8888/callback"); webauthenticationbroker.authenticateandcontinue(starturi, enduri,null, webauthenticationoptions.none); } catch (exception error) { // // bad parameter, ssl/tls errors , network unavailable errors handled here. // var dialog = new messagedialog(error.message); await dialog.showasync(); } because webauthenticationbroker.authenticateandcontinue void kind cant put var t=webauthenticationbroker.authenticateandcontinue on i want return below code public async void continuewebauthentication(webauthenticationbrokercontinuationeventargs args) {

java - Apache Spark and Spring Transaction Management -

i using apache spark in clustered environment 3 workers. spark's 'foreachpartition', sending data in batches spring jdbctemplate.batchupdate in transaction mode. i dont have idea spring transactions. spring transaction using below code : defaulttransactiondefinition paramtransactiondefinition = new defaulttransactiondefinition(); transactionstatus status = transactionmanager.gettransaction(paramtransactiondefinition ); //sql , jdbcargs preparation... //.... jdbctemplate.batchupdate(finalsql, jdbcargs); transactionmanager.commit(status); above code getting called : .foreachpartition(...params..) { call(..params..) { if(basicdatasource == null || transactionmanager == null) { basicdatasource bds = getbasicdatasource(basicdatasrc, istransactionrequired);//for transaction transactionmanager2.setdatasource(bds);//datasourcetransactionmanager jdbctemplate.se

javascript - How to upload image file from computer and set as div background image using jQuery? -

the html code image file input: <input type="file" autocomplete="off" name="background-image" accept="image/*" /> the destination div block want dynamically set background image: <div class="clock"></div> the jquery function i'm using setting image file uploaded div background image: $(".background>div>input[type=file]").change(function () { var fileextension = ['jpeg', 'jpg', 'png', 'gif', 'bmp']; if ($.inarray($(this).val().split('.').pop().tolowercase(), fileextension) == -1) { alert("only '.jpeg','.jpg', '.png', '.gif', '.bmp' formats allowed."); } else { $(".clock").css("background-image",'url("' + $(".background>div>input[type=file]").val() + '")'); } }); the issue background-image not

windows - I want to fetch the name of the latest updated folder at particular path of FTP server -

using command able latest updated folder in unix ls -t1 | head -1 but how can same in ftp server windows? i want name of latest updated folder @ particular path of ftp server. 1 please help? there's no easy way windows shell commands. you can: use ftp.exe execute ls /path c:\local\path\listing.txt save directory listing text file. exit ftp.exe . parse listing , find latest files. not easy task windows shell commands. it way easier powershell script. you can use ftpwebrequest class . though not have easy way retrieve structured directory listing either. offers listdirectorydetails , getdatetimestamp methods. see retrieving creation date of file (ftp) . or use 3rd-party library task. for example winscp .net assembly can do: param ( $sessionurl = "ftp://user:mypassword@example.com/", $remotepath = "/path" ) # load winscp .net assembly add-type -path "winscpnet.dll" # setup session options $session

I need a browser chrome/firefox extension to list all iframe src in the current page. Any recommendation? -

i looking browser (chrome/firefox) extension list iframe src in current page. this pretty trivial in javascript: var alliframesonpage = document.queryselectorall('iframe'); var len = alliframesonpage.length; window.console.log('there ' + len + ' iframes on page.'); (var = 0; < len; i++) { var current = alliframesonpage[i]; window.console.log('iframe[' + + '].src == "' + current.src + '"'); } combine bookmarklet generator such this one , , should go.

Android:show list of data in notification -

Image
i data json , save in sqlite eith for ,i want when each data save in db make notification data my for for(int i=0;i<jnews.length();i++){ jsonobject c = jnews.getjsonobject(i); string id = c.getstring(tag_id); string title = c.getstring(tag_onvan); string text = c.getstring(tag_matn); string data = c.getstring(tag_tarikh); string nid = c.getstring(tag_cnid); hashmap<string,string> nnews = new hashmap<string,string>(); nnews.put(tag_id,id); nnews.put(tag_onvan,title); nnews.put(tag_matn,text); nnews.put(tag_tarikh,data); nnews.put(tag_cnid,nid); newslist.add(nnews); db.setnewnews(id, title, text, data, nid); } i use code in for ,but not good string ns = context.notification_service; notificationmanager mnotificationmanager = (notificationmanager) getsystemservice(ns); int icon = r.drawable.ic_launcher; charsequence tickertext = "ثبت اختراع"; // ticker-text long when = system.current

ruby on rails - Active Record callbacks throw "undefined method" error in production with classes using STI -

i have many instances in application use single table inheritance , works fine in development environment. when release production (using passenger) following error: undefined method `before_save' inventoryorder:class (nomethoderror) why work in dev environment , not work in production? both using rails 4.2 , ruby 2.1.5. problem passenger? here inventoryorder class: class inventoryorder < order def self.model_name order.model_name end before_save :ensure_only_feed_types def ensure_only_feed_types order_products.each |op| if !producttypes::is_mix?(op.product_type.type) raise exceptions::failedvalidations, _("can't have inventory order mixes") end end end def self.check_if_replenishment_order_is_needed(product_type_id) prod_type = producttype.find(product_type_id) return if prod_type.nil? || prod_type.min_system_should_have_on_hand.nil? || p

java - How to Call the class that extends RelativeLayout programatically in android? -

i've made layout in java class extending relativelayout , want call view programatically when button clicked. able set custom layout in xml file this <com.sample.customlayout android:layout_width="wrap_content" android:layout_height="wrap_content"/> i have set sample of code below public class card extends relativelayout { textview tutorialok; public card(context context) { super(context); init(); } public card(context context, attributeset attrs) { super(context, attrs); init(); } public card(context context, attributeset attrs, int defstyle) { super(context, attrs, defstyle); init(); } } how call class when button clicked ? since, i'm new android, tips or code helpful ! //custom layout called qualified name ... package.classname <com.sample.card android:layout_width="wrap_content" android:layout_height="wrap_content"

c++ - Stack information disappears when I add exception information to my minidump -

i'm writing out of process minidump child process. here relevant code snippet: context thread_context{}; thread_context.contextflags = context_full; assert(getthreadcontext(child_thread_handle, &thread_context)); exception_pointers exception_ptrs; exception_ptrs.exceptionrecord = &exception_info.exceptionrecord; exception_ptrs.contextrecord = &thread_context; minidump_exception_information minidump_exception_info; minidump_exception_info.threadid = evt.dwthreadid; minidump_exception_info.exceptionpointers = &exception_ptrs; minidump_exception_info.clientpointers = false; auto success = minidumpwritedump(child_handle, evt.dwprocessid, file_handle, minidump_flags, &minidump_exception_info, nullptr, nullptr); this gives me exception information, , call stack every thread except thread raised exception. if change &minidump_exception_info nullptr, call stack no exception information. there way both exception information , call stack? calli

Series imported but unused error Python -

import numpy np pandas import series, dataframe import pandas pd import matplotlib.pyplot plt iris_df = dataframe() iris_data_path = 'z:\work\programming\python\irisdata.csv' iris_df = pd.read_csv(iris_data_path,index_col=false,header=none,encoding='utf-8') iris_df.columns = ['sepal length','sepal width','petal length','petal width','class'] print iris_df.columns.values print iris_df.head() print iris_df.tail() irisx = irisdata[['sepal length','sepal width','petal length','petal width']] print irisx.tail() irisy = irisdata['class'] print irisy.head() print irisy.tail() colors = ['red','green','blue'] markers = ['o','>','x'] irisyn = np.where(irisy=='iris-setosa',0,np.where(irisy=='iris-virginica',2,1)) col0 = irisdata['sepal length'] col1 = irisdata['sepal width'] col2 = irisdata['petal length&

vba - remove alt+enter in excel while generating values -

i having end of line problem, can guys tell me how fix it? when enter value in excel , alt + enter values in cell breaks , moves next line. wanted make in single line. not sure how it. for example right getting output this: envname=testing testing testing testing` but generated output should this: envname=testing testing testing testing providing code below sub export() dim long value = sheets(itm).cells(i, 4).value 'if instr(1, sheets(itm).cells(i, 4).value, " ") ' value = """" & sheets(itm).cells(i, 4).value & """" 'end if close 1 end sub whenever pick value cell on sheet, if might have line break in need replace it, avoid getting same line break in output: value = replace(sheets(itm).cells(i, 4).value, vblf, "") not sure you'd want replace line break with: here i've used empty string can use else.

ios - 1 App Built for Enterprise and App Store -

Image
we have app build both enterprise , app store. requires make couple settings the bundle identifier the development team currently use 2 branches enterprise branch master , app store branch secondary, , merge master app store branch before submitting. i eliminate step , build both versions @ same time. what best way this? i have 1 additional requirement. mixed swift , objective-c project , want ability have code specific app store version , code specific enterprise version. envision using #ifdef any suggestions on solution this, or keeping on 2 branches make technical sense. first can duplicate release configuration in settings add appstore configuration. add prepocessor macros every configuration have. manage schemes have app store build configuration you have 2 targets need build 1 after other. for code part, on code have manage every macros in code.

javascript - Uncaught ReferenceError: i is not defined -

i'm trying make for-loop base on array var lists = [ "a", "b", "c", "d" ]; js for ( = 0; < lists.length; i++) { // console.log(lists[i]); $(".sa-report-btn-"+lists[i] ).click(function () { $(".sa-hide-"+lists[i]).removeclass("hidden"); $(".sa-report-"+lists[i]).addclass("hidden"); }); $(".sa-hide-btn-"+lists[i]).click(function () { $(".sa-hide-"+lists[i]).addclass("hidden"); $(".sa-report-"+lists[i]).removeclass("hidden"); }); } am doing correctly ? got uncaught referenceerror: not defined can concat each loop jquery selector --> $(".sa-hide-"+lists[i]) ? curious ... first off, sounds you're using strict mode — good ! it's saved falling prey the horror of implicit globals . there 2 issues code. the first 1 you're missing declaration

php - Unittesting Laravel 5 Mail using Mock -

is there way test mail in laravel 5? tried legit mock example see on internet seems works on laravel 4. current code below. $mock = mockery::mock('swift_mailer'); $this->app['mailer']->setswiftmailer($mock); ...some more codes here... $mock->shouldreceive('send')->once() ->andreturnusing(function($msg) { $this->assertequals('my subject', $msg->getsubject()); $this->assertequals('foo@bar.com', $msg->getto()); $this->assertcontains('some string', $msg->getbody()); }); this contents of apiclient.php, last line line 155, indicated in stack trace. mail::queue('emails.error', [ 'error_message' => $error_message, 'request' => $request, 'stack_trace' => $stack_trace ], function ($message) use ($error_message) {

obfuscation - GIT - Maintaining obfuscated repositories for working with untrusted 3rd party developers? -

our git repositories typically contain code our entire websites & services. includes painstakingly worded text marketing, legal, ui, etc. essentially rogue developer clone it, change few things, , become competitor of ours (all legal issues aside). or more likely, include others work own in portfolios without authorization. in cases leads disclosure of features , functions don't want out there yet. in case, has been recognized risk since work developers around globe , have need add more -- granting them access entire code base work on. have ever encountered issue? or have implemented solution reduce or mitigate similar risks? i thinking 1 potential strategy create 3 individual git repositories different purposes (not branches) this: git repo: project1_developers $git branch master dev issue_feature1 issue_feature2 etc.. workflow above: issue/feature branch style. developer delegated task, checks out issue/feature branch. when completed, submits branch & me

c# - Having a certain layout when adding labels to a Panel -

i have winform panel , keep adding labels it. possible set panel everytime add label have layout ? layout looking having single column of labels , everytime add new label added next row. haven't found property panel that. possible ? use flowlayoutpanel instead of panel. , set flowdirection property topdown

SQL Query using pivot and group by on SQL 2008 -

i have punch clock database in sql 2008 , select data results using pivot , group date (not time) , name. 1 name, want have punchtime of same day in same row. original table result table | name | punchtime | | name | time1 | time2 | time3 | time4 | ------------------------------- ------------------------------------------------------------------------------------------ | john |2015-06-01 10:00:00| | john |2015-06-01 10:00:00|2015-06-01 12:00:00|2015-06-01 13:00:00|2015-06-01 21:00:00| | john |2015-05-30 21:34:27| | amy |2015-06-01 11:14:00|2015-06-01 17:00:00| | | | john |2015-06-01 10:00:00| | amy |2015-06-02 09:15:00|2015-06-02 12:25:00| | | | amy |2015-06-01 11:14:00| | amy |2015-06-03 17:35:00| | | | | john |2015-06-01 12:00:00| | john

formula - Excel find text value in string -

i have string such k68272caa6a1 , need that, formula pass first character (i mean string 68272caa6a1 in mind) , formula find first text character. , cell value 7. because first text character "c" , it's 7th character of string (include "k" character). and after i'll split rest of them. i'm confused issue. if understand correctly, looking position of 2nd letter in string. number given following array-entered formula. to enter array formula, hold down ctrl+shift while hitting enter . if correctly, in formula bar see braces {...} around formula: =match(false,isnumber(mid(a1,row(indirect("2:99")),1)/1),0)+1 the 99 needs number larger length of longest string.

excel - Plotting separate charts for columns below each merged cell dynamically -

what changes should make in ranges of code below code search each unique merged cell, , and plot chart of columns below merged cell particular department. can have dynamic number of columns below different merged cells (like different number of months). also, number of departments dynamic. suggest other changes in code this. (i have used 'columnmax' in code used long ranges, , used in place of '7') kindly find data here sample chart http://bit.ly/1drovfs . want code plot same type of charts departments dynamically. code following: sub charts() dim rchart1 range dim icolumn long dim lastcol4 long dim currentrcol long dim cht1 chart lastcol4 = activesheet.cells(2, activesheet.columns.count).end(xltoleft).column const strtrow long = 1 const endrow long = 7 dim columnmax long columnmax = lastcol4 - 4 activesheet set rchart1 = .range(.cells(strtrow, "a"), .cells(endrow, "a")) icolumn = 2 7 step 2 set rchart1 = union(rchart1, .range(.cells(s

setting environment int variable in Linux for use in a while loop in python but loop doesn't stop -

i'm controlling led on raspberry pi 2 python. want led go on x seconds. when set environment variable in linux. example, export t=5 . led goes on won't go off. if set variable in python script works fine. i'm setting environment variable in linux so: export t=5 sudo python test.py and getting in python so: #!/usr/bin/env python import rpi.gpio gpio import time import os gpio.setmode(gpio.board) gpio.setup(11,gpio.in, pull_up_down=gpio.pud_down) gpio.setup(12,gpio.out) gpio.output(12,0) s = 0 t = os.environ.get('t') while s <= t: if (gpio.input(11) == 1): gpio.output(12, 1) time.sleep(0.1) s += 0.1 else: gpio.output(12, 0) gpio.output(12, 0) the values of environment variables — , values of os.environ — stored strings. thus, need convert t number in order

python - Tkinter: How to move widgets on canvas? -

im tryin app move every widget on canvas. first step moved rectangle, want move widget! thought "it same thing!" im wrong :( here code: from tkinter import * clicked = false def callback(event): global clicked, start, pre_x,pre_y if clicked: clicked = false else: if event.x >= canvas.coords(rec)[0] , event.x <= canvas.coords(rec)[2] , event.y >= canvas.coords(rec)[1] , event.y <=canvas.coords(rec)[3]: clicked = true canvas.itemconfig(rec,fill = "blue") pre_x = event.x pre_y = event.y canvas.bind("<b1-motion>",movement) def movement(event): global clicked, start, pre_x,pre_y if clicked: x_diff = event.x - pre_x y_diff = event.y - pre_y #print("reccoord[1]=" + str(canvas.coords(rec)[1])) pre_x = event.x pre_y = event.y #print("reccoord[1] = " + str(canvas.coords(rec)[

Read both key values and files from multipart from data post request in ASP.NET WebAPI -

i have endpoint needs accept file upload , other information client request. following code can upload file can't seem figure out how read other info. i make test request postman following form data: image -- myimage.jpg -- of type file email -- a@b.com -- of type text the backend code looks this: [httppost] public async task<httpresponsemessage> sharephoto() { try { var provider = new multipartmemorystreamprovider(); var data = await request.content.readasmultipartasync(provider); // how image succesfully passing emailservice var item = (streamcontent)provider.contents[0]; using (var stream = new memorystream()) { await item.copytoasync(stream); string emailaddress; emailservice.sendsharedphoto(emailaddress, stream); return request.createresponse(); } } catch { // stuff } } in ex

visual c++ - Updating define value in C++ -

i'm learner of c++ , i'm making assignment , can't seem update value. it's must use define balance: #define balance 5000.00 in end of statement can't seem able update balance: printf("deposit successful!\nyou have deposited following notes : \n"); printf("rm100 x %d = rm %.2f\n",nd100,td100); printf("rm 50 x %d = rm %.2f\n",nd50,td50); printf("rm 20 x %d = rm %.2f\n",nd20,td20); printf("rm 10 x %d = rm %.2f\n\n",nd10,td10); dtotal=td100+td50+td20+td10; printf(" total = rm %.2f\n\n",dtotal); newbalance=5000+dtotal; printf("your current balance rm %.2f\n\n",newbalance); i want update newbalance become balance can continue withdrawal. can show bit of withdrawal printf("\nwithdrawal successful!\n"); printf("%d notes x rm 50 = rm%d.00\n",wnotes,wamount); printf("your current balance rm %.2f\n\n",newba

python - PyQt4 how to get button size -

i have seen this , this , have tried: self.mybutton = qtgui.qpushbutton("click") = self.mybutton.size() print things these, i'm still unable single button's size info. when print a , returns size of parent window, think. returns size not button's size because return value big button's size. yes feel newbie question stuck this. i'd appreciate this, thank in advance. you have parent widget or put in layout able calculate size. without specified parent, kind of lost... ...or rather thinks going window , uses minimum size window platform on. hope helps.

c# - Is there anyway to replace something in the HttpPostedFileWrapper filename in all of my project in mvc? -

i have many actions used httppostedfilewrapper, want change space " " dash "-" in of filenames before call httppostedfilewrapper.filename , can 1 one in of actions many, there way change on somewhere else? in onactionexecuting in filters example, note override not solution because have change name of input type in actions again. in fact, in wrong way because httppostedfilewrapper.filename readonly , can not change it!