Posts

Showing posts from January, 2014

javascript - node-js: expree-formidable parse value - array overwritten -

i have problem parsing forms in node js , express-formidable. i figured out problem occurs don't know why , how fix correctly. my problem when want add people array , save them in .json file can add first person --> ok if want add second,third,... second person added, existing person in array(and json-file) overwritten second person. if add 1. howard stored in array. if add 2. michael array has 2 entries michael , no howard. the problem is: app.post('/profiles', formidable()); because if delete line , re-write storeprofil function normal formidableparse works , can add people array: storeprofile: function (req) { var form = new formidable.incomingform(); form.keepextensions = true; form.parse(req, (err, fields, files) => { //var err =""; app.fixtures.push(fields); ............. }); i have mvc pattern - can find code below: could please tell me why not work express-formidable? thanks! entr

Invalid xml with ssml in C# -

i having hard time trying figure out how xml invalid ssml code within c#. here line of code in c#: synth.speakssml("<speak version=\"1.0\" xmlns=\"http://www.w3.org/2001/10/synthesis\" xml:lang=\"en-us\">< voice gender=\"male\" age=\"15\" xml:lang=\"en-us\"><prosody contour=\"(0%,+20hz) (25%,+20hz) (50%,+20hz) (75%,+20hz)\" volume=\"100\">" + + "</prosody></voice></speak>"); and ssml: <speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xml:lang="en-us"> < voice gender="male" age="15" xml:lang="en-us"> <prosody contour="(0%,+20hz) (25%,+20hz) (50%,+20hz) (75%,+20hz)" volume="100"> text </prosody></voice></speak> thank you! i figured out! there space in voice tag!

babeljs - Babel does not transpile code when using Webpack's resolve modules -

or seems, the code transpiles if use regular relative paths, when use resolve.modules error message: you may need appropriate loader handle file type. | export default class test { | | name = 'joe'; | | constructor() { ... webpack.config: ... resolve: { modules: [ path.resolve(__dirname,'resources/assets/app'), path.resolve('./node_modules') ], }, module: { ... app/core/test.js: export default class test { name = 'joe'; constructor() { console.log('construct test'); } } usage: import test 'core/test'; does know if bug or missing something? i same error when using resolve.alias have tried using babel-plugin-transform-class-properties .babelrc { "presets": [ "es2015", "stage-0", "react" ], "plugins": [ "babel-plugin-transform-class-properties", "react-hot-loade

javascript - Service Worker recurring -

can make service worker, run in background , poll server @ specific interval , return response or show notification(push notification) when chrome browser closed. working website, ask service worker permission , sync request @ specific intervals in background based on request received server show notification. edit 1: of can see chrome working on this, post old dec 2015. have written introduce in first half of 2016. not available till yet. we're aiming ship background sync stable version of chrome in first half of 2016. we’re working on variant, “periodic background sync”. allow request “periodicsync” event restricted time interval, battery state , network state. require user permission, of course, down of browser when , how these events fire. e.g., news site request sync every hour, browser may know read site @ 07:00, sync fire daily @ 06:50. idea little further off one-off syncing, it’s coming.

compilation - -fopenmp flag in compile and link -

i have openmp code #include <omp.h> #include <stdio.h> int main() { #pragma omp parallel { fprintf(stderr, "thread %d\n", omp_get_thread_num()); } return 0; } when compile , link , use -fopenmp gcc-6 -std=c99 -wall -wextra -pedantic -fopenmp -iinclude -c -o build/main.o src/main.c gcc-6 -o bin/main build/main.o -fopenmp the code work $ ./bin/main thread 0 thread 1 thread 2 thread 3 but don't when put flag in link gcc-6 -std=c99 -wall -wextra -pedantic -iinclude -c -o build/main.o src/main.c src/main.c: in function 'main': src/main.c:6:0: warning: ignoring #pragma omp parallel [-wunknown-pragmas] #pragma omp parallel gcc-6 -o bin/main build/main.o -fopenmp the code work not in parallel $ ./bin/main thread 0 why need add -fopenmp in compile , link time? why need add -fopenmp in compile , link time? because required both @ compile time (to enable #pragma omp handling) , @ link time (to link

javascript - Zapier.com zipcode autofill city and state -

we using zapier.com connect many programs, 1 function need autofill city , state zip code. available in zapier.com setup code zapier run javascript. can't seem figure out , appreciated. <script type="text/javascript">//<![cdata[ $(function() { // important: fill in client key var clientkey; // deleted stack overflow var cache = {}; var container = $("#example1"); var errordiv = container.find("div.text-error"); /** handle successful response */ function handleresp(data) { // check error if (data.error_msg) errordiv.text(data.error_msg); else if ("city" in data) { // set city , state container.find("input[name='city']").val(data.city); container.find("input[name='state']").val(data.state); } } // set event handlers container.find("input[name='zipcode']").on("

ghostscript - pdf2dsc error: invalidaccess --.locksafe-- -

this problem encountered in preview-latex auctex. believe problem should caused ghostscript, pdf2dsc tool. the command executed in shell environment pdf2dsc input.pdf output.dsc (where input.pdf generated pdflatex) generate empty output.dsc , following error message, breaks preview command chain, error: /invalidaccess in --.locksafe-- operand stack: true --nostringval-- --dict:1152/1684(ro)(g)-- getenv --nostringval-- execution stack: %interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1862 1 3 %oparray_pop 1861 1 3 %oparray_pop 1845 1 3 %oparray_pop 1739 1 3 %oparray_pop --nostringval-- %errorexec_pop .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- 1870 0 3 %oparray_pop 1869 0 3 %oparray_pop --nostringval-- dictionary stack

swift3 - animation not working in xcode 8 playground swift 3 -

i trying learn more animations in xcode 8 playground using swift 3. have learned swift no longer uses xcplayground, instead, using "import playgroundsupport". i can not show in assistant editor. know fix or bug new xcode 8 any awesome. thanks. import uikit import playgroundsupport let containerview = uiview(frame: cgrect(x: 0.0, y: 0.0, width: 375.0, height: 667.0)) playgroundpage.current.needsindefiniteexecution = true playgroundpage.current.liveview = containerview let circle = uiview(frame: cgrect(x: 0.0, y: 0.0, width: 50.0, height: 50.0)) circle.center = containerview.center circle.layer.cornerradius = 25.0 let startingcolor = uicolor(red: (253.0/255.0), green: (159.0/255.0), blue: (47.0/255.0), alpha: 1.0) circle.backgroundcolor = startingcolor containerview.addsubview(circle); let rectangle = uiview(frame: cgrect(x: 0.0, y: 0.0, width: 50.0, height: 50.0)) rectangle.center = containerview.center rectangle.layer.cornerradius = 5.0 rectangle.backgroundc

c# - String.Replace() will not change the source string of the variable -

this question has answer here: c# string replace not work [duplicate] 3 answers i have following code inside c# application:- string[] excludechar = { "|", "\\", "\"", "'", "/", "[", " ]", ":", "<", " >", "+", "=", ",", ";", "?", "*", " @" }; var currentgroupname = curitemsitename; (int = 0; < excludechar.length; i++) { if (currentgroupname.contains(excludechar[i])) currentgroupname.replace(excludechar[i], ""); } site.rootweb.sitegroups.add(currentgroupname) now in abive code currentgroupname variable passing inside .add function have special characters have replaced inside loop. can adivce if can modify code .replace re

java - RCP IWorkbenchPage is returning null -

i trying create rcp application. far have menu 2 menuitems. (file -> data , file -> exit) exit works fine, when click on data, gives me error: !entry org.eclipse.ui 4 0 2017-01-18 21:49:31.066 !message unhandled event loop exception !stack 0 org.eclipse.e4.core.di.injectionexception: java.lang.nullpointerexception @ org.eclipse.e4.core.internal.di.methodrequestor.execute(methodrequestor.java:68) @ org.eclipse.e4.core.internal.di.injectorimpl.invokeusingclass(injectorimpl.java:252) @ org.eclipse.e4.core.internal.di.injectorimpl.invoke(injectorimpl.java:234) @ org.eclipse.e4.core.contexts.contextinjectionfactory.invoke(contextinjectionfactory.java:132) @ org.eclipse.e4.core.commands.internal.handlerservicehandler.execute(handlerservicehandler.java:152) @ org.eclipse.core.commands.command.executewithchecks(command.java:493) @ org.eclipse.core.commands.parameterizedcommand.executewithchecks(parameterizedcommand.java:486) @ org.eclipse.e4.core.commands.internal.handlerserviceimp

python - Generating Model code with pwiz Error -

i trying generate model values using pwiz. database in question sqlite database, contains django tables in addition regular tables generated using python script. when try following in linux terminal python -m pwiz -e sqlite -t mapping_table db.sqlite3 i following error: /python2.7/site-packages/peewee.py", line 3001, in get_indexes _, name, is_unique in cursor.fetchall(): valueerror: many values unpack the table trying retrieve 1 generated using python script. has couple of columns , rows in it. not sure how proceed here exactly. python -m pwiz -e sqlite db.sqlite3 > db_map.py pwiz reads database , creates file database mapping. db.sqlite3 name of database (put database filename) db_map.py filename of output file (name keep .py extension)

java: Trying to return a string value from an array of strings via a method -

public string getvalue(string key) { (int = 1; i<=length; i++) { if (key.equals(keyarr[i])) { return valuearr[i]; } } } public string getkey(string value) { string key; (int = 1; i<=length; i++) { if (value.equals(valuearr[i])) { key = keyarr[i]; return key; } } } i error "this method must return result of type string". 2 arrays valuearr , keyarr both string type arrays. know value of keyarr[i] , valuearr[i] strings because if change return type of method else says expected else , got string. that's because not return string. e.g. if key not found, if (key.equals(keyarr[i])) { never true , hence, return valuearr[i]; never executed. to fix this, need following: add return statement after for loop , return something if no match found, e.g.: public string getvalue(string key) { (int = 0; < length; i++) { if (key.equals(keyarr[i])) {

python - Handling Depth Processing With The Kinect V2 -

i trying deal processing depth data kinect v2. wish filter out points not within specific distance. problem can't find reliable docs on how possibly done, let alone on how retrieve depth data itself. if has experience extracting depth data kinect v2, appreciated. i using pylibfreenect2 bindings openkinect library, flexible dependencies. thanks in advance. you found answer question.if not here solution. there open source library on github , called openkinect-for-processing library. use friendly , easy-to-use library runs on browser. quick tutorial can check link , through small youtube tutorial . on youtube tutorial can find easy way thresholding , extracting depth data. can check video quick glance how extracts , thresholds depth data.

javascript - jQuery not serialize correctly -

i want ajax submit 2 form (for user , client ). 2 forms identical user serialized expected, other 1 isn't. 2 forms return js function onsubmit="return edituser();" , onsubmit="return editclient();" respectively. try alert out serialize data , show user: id=7&username=somethingelse&password=123&is_admin=0&client=1 and client: id=2&name=&logo=&phone=&email=&active=1&street=&city=&state=43&zip_code= with fields filled (the 3 values prefilled php code). here js code ajax: function edituser() { console.log($('#edituserform').serialize()); $.ajax({ type: 'post', url: 'edituser.php', data: $('#edituserform').serialize(), cache: false, datatype:'json', contenttype: "application/x-www-form-urlencoded; charset=utf-8", }).always(function(){ renderusers(); $('body').removeclass('modal-open'); $(

Quicksort in SML using foldr -

i'm working on assignment partition function of quicksort in sml may done foldr , , no library functions may used. i've gotten partitioning down fine, , have fundamentals of quicksort fine, running problems seems merge wrong lists together/merge in wrong order. (*comp placeholder, given comparator function , list input*) fun comp b = > b; (*both partition functions working intended.*) fun getgreater (a::b) c = foldr (fn (a, lst) => if (comp c) a::lst else lst) [] (a::b); fun getlesserorequal (a::b) c = foldr (fn (a, lst) => if not (comp c) a::lst else lst) [] (a::b); fun merge (a::b) (c::d) = foldr (op::) (c::d) (a::b); fun triplemerge (a::b) c (d::e) = merge (a::b) (c::(d::e)); (*removes head, uses head pivot. recursive calls on results on getlesserorequal , getgreater*) fun sort [] = [] | sort (a::b) = if ([a] = (a::b)) [a] else triplemerge (sort(getlesserorequal b a)) (sort(getgreater b a)); as example, here of tests i'm running. when follow logi

linkedin post share limit -

Image
i doing application, access linkedin, when post request implementation of interface, when api found there restrictions, 125,000, how improve value thanks

javascript - how to display image horizontal and vertical dynamic -

i wanna display images in imagelist. i wanna see ab cd how can that? not or odd maybe list can below abcde fg i wanna new row or display:block when count==2 .list can (1,1,1,1,2,1 ) first row 4 elements second row 2 element.list can (1,1,1,2,1,2,1) first row 3 elements second row 2 elements third row 2 element link here *****jsfiddle.net/jpkwhfv3/ ***** how : <div ng-repeat="key in items"> <div class="row" ng-if="$even"> <div>{{items[$index]}}</div> <div>{{items[$index + 1]}}</div> </div> </div> with $scope.items= object.keys(m); http://jsfiddle.net/0momap0n/302/

javascript - Scrolling to make div visible -

i trying make fullcalendar scheduler scrolls area person clicks on, , code works somewhat, depending on screen size, actual area should zoom scrolled past, , not visible within window. is there way ensure table header cell's left border aligned window's left border? in view, there horizontal scrolling table inside div $('.fc-time-area.fc-widget-header .fc-scroller') , , cell want visible can found this: $(".fc-time-area.fc-widget-header .fc-content th[data-date='2017-2-11t10:00:00']") var centertime = function (day) { $('.fc-time-area.fc-widget-header .fc-scroller').animate({ scrollleft: $(".fc-time-area.fc-widget-header .fc-content").find("th[data-date='" + day + "']").offset().left }, 750); }; i figured out. apparently there difference between using offset() , position() . changing simple thing, works great now. var centertime = function (day) { $('.fc-time-

python - Match from list -

i still learning python, trying things. i have code search word 'lorem' in text , replace random word list. working. what wanna how check if word list (words = ['and', 'a', 'is', 'the']) in text , replace word list (t = ['text', 'replace', 'word']). i wanna replace 'lorem' variable or loop thru list or open txt file words check. res = re.sub('lorem', lambda x: random.choice(t), text) if possible if can show me 3 options: -loop through list -variable -open file words inside or maybe there other, better way? thanks! here full code import re import random t = ['text', 'replace', 'word'] text = '''lorem ipsum dummy text of printing , typesetting industry. lorem ipsum has been industry's standard dummy text ever since 1500s, when unknown printer took galley of type , scrambled make type specimen book. has survived not 5 centuries, leap electr

Regex Javascript - Remove text between two html comments -

well have 2 html comments this: <!--delete--> blah blah blah blah <!--delete--> and want remove (including comments, character , newlines). btw using javascript , grunt make replacement. thanks regex use following javascript regular expression match multiple instances of custom .html comments , content inside them: /\<\!\-\-delete\-\-\>((.|[\n|\r|\r\n])*?)\<\!\-\-delete\-\-\>[\n|\r|\r\n]?(\s+)?/g then register custom function task inside gruntfile.js shown in following gist: gruntfile.js module.exports = function (grunt) { grunt.initconfig({ // ... other tasks }); grunt.registertask('processhtmlcomments', 'remove content inside custom delete comments', function() { var srcdocpath = './src/index.html', // <-- define src path .html outputdocpath = './dist/index.html',// <-- define dest path .html doc = grunt.fil

php - Proper syntax when using a javascript variable in an HTML link -

i trying combine simple html (php) link , include js variable. have syntax incorrect. suggestions? $.each(playlist, function(index, val) { playlisthtml += "<form name="form" method="post" action="../_inc/process_track_move.php?track="+val.sources[0].title" }); you should not assembling raw html manually in javascript; it's easy wrong. in case, if code worked, vulnerable encoding errors , xss security issues because doesn't encode attribute value. the safer choice use dom api, framework, or default-safe templating engine create elements need, automatically care care of encoding attribute values. here's how use dom api instead of raw html case. var playlist = document.createelement('div'); // or document.queryselector('#playlist')? $.each(playlist, function(index, val) { var form = document.createelement('form'); form.setattribute('name', 'form'); form.set

c# - Unity 5 unresponsive after a piece of code is executed -

Image
i absolute beginner in unity. have been working on ui simple login form. in have 2 toggle selecting gender i.e male or female. have been doing calling method checks if male selected remove check male when other toggle pressed. my unity freezes when click female toogle . here code. toggle female; toggle male; void start(){ female = gameobject.find ("toggle_female").getcomponent<toggle> (); male = gameobject.find ("toggle_male").getcomponent<toggle> (); } public void ismale(){ if (female.ison) female.ison = false; male.ison = true; } public void isfemale(){ if (male.ison) male.ison = false; female.ison = true; } you running infinite loop toggle . when female toggle changes, onvaluechanged event triggered. assume isfemale() function linked toggle onvaluechanged event, isfemale() called. when isfemale() called, male.ison = false; causing ismale() function called run female.ison = f

android - Is there an equivalent to the camera 2 API method camera.autoFocus() in the camera API? -

in first camera have such method private void takepicture() { camera.autofocus(new camera.autofocuscallback() { @override public void onautofocus(boolean success, camera camera) { camera.takepicture(shuttercallback, picturecallback_raw, picturecallback_jpeg); } }); } and convinient , when user take picture , app trying focused , take picture... question : how can implement in camera2api callback or way wait until camera take focus , take picture? try this sample project google (or camera2basicfragment ). in general should request focus, determine "focus lock" state in cameracapturesession.capturecallback capture image , request unlock focus.

recursion - recursive itemgetter for python -

this question has answer here: xpath query nested python dictionaries 7 answers is there recursive itemgetter in python. let's have object d = {'a': (1,2,3), 'b': {1: (5,6)}} and wanted first element of tuple d['a'] ? far can tell itemgetter 1 level, i.e. me a or b or both. is there clever way of combining itertools itemgetter produce desired result. so want able call from operator import itemgetter d = {'a': (1,2), 'b': (4, (5,))} itemgetter({'a': 0})(d) --> 1 itemgetter({'b': 0})(d) --> 4 itemgetter({'b': {1: 0}})(d) --> 5 d = {'a': {'b': (1,2,3)}} itemgetter({'a': {'b': 2}})(d) --> 3 i don't 'clever' ways. obvious better. you can write getter iterates along list of subscripts: def getter(x, *args): p = x s in

How to efficiently match hundred thousands of substring in one string using elasticSearch -

my problem simple: have database containing 400,000 substrings (movies , tv shows titles). i'd match these titles in message such as: i love game of thrones , suits , spotlight awesome movie. what need match game of thrones , suits , spotlight in string. i tried send titles wit.ai seems can't handle 100,000 substrings. i'm wondering if elasticsearch job? if that's common problem, sorry, me search in right direction. thanks! one of best algorithms find strings dictionary in text aho-corasick one dictionary-matching algorithm locates elements of finite set of strings (the "dictionary") within input text. matches strings simultaneously. complexity of algorithm linear in length of strings plus length of searched text plus number of output matches. but wonder database engine not provide possibilities such searching... can, don't know?

recursion - Solution tracking and Optimal Solution recursive Knapsack R -

i relatively new using r, hope me recursive knapsack problem. think first part correct, unable find items selected in optimal solution. 2 computing value function f f <- function(i,k){ if (i==0 || k==0){ output <- 0 } else if (length( w[i]) && w[i] > k) { output <- f(i-1,w) } else { output <- max(v[i]+ f(i-1, k-w[i]), f(i-1,k)) }'' return(output) } f(4,15) 3 tracking solution given state (i, k) keep <- function(i,k){ if (k < w[i]){ keep(i,k) <- 0 } else if (f(i-1,k) <= v[i]+f(i-1,k-w[i])) { keep(i,k) <- 1 } else { keep(i,k) <- 0 } return(keep) } 4 find optimal solution selection <- rep(0,4) remainingcap <- k (i in 1:4) if (keep(i, remainingcap) <- 1){ output <- 1 remainingcap <- (k-w[i]) } else { output <- 0 } print(selection)

maximo anywhere - Refresh one lookup data -

using anywhere - work execution app (v7.5.2), refresh data option refresh complete data. how refresh 1 changes item actual materials ? ex: if assign new device, every time technician need refresh latest assigned item in up. how mitigate in 7.5.2 ? in our current releases there's no way without downloading lookup data. can reduce amount of lookup data being downloaded device using anywhere admin app make lookup data refresh faster. have enhancement request support delta download of lookup data in our backlog.

c# - open webpage from within a desktop application with arguments as username and password -

i have developed asp.net web application user can access , login providing username password. have develop windows form application in user can login using same credentials web application. clicking button in application, want open browser , navigate user web application , automatically login web application same credentials. problem how pass credentials web app? i using process.start(" http://localhost:8080/myapplogin.aspx ") open browser , load login page. can pass credentials in query string encrypted format doesn't sound safe method of doing it. want pass credentials webpage more secure method. any suggestions? this question incorrectly edited , lost meaningful information in it. have re edit question below edit i have developed asp.net web application user can access , login providing username password. have develop windows form application.the win form application contains user's web app credentials in file.there's button in win form app , want

java - Display inherited methods in NetBeans -

Image
i have interface default methods layers of abstract classes build upon each other , class actual work. see methods in top-most implementation in single view. i have problem more once , in different projects, i'm looking general solution. hope there option toggle display, willing try plugins this. having 'navigator' style window lists methods in tree view fine well, can directly click through proper methods. example: public interface ifoo { string getname(); string getversion(); default string getdefaultversion() { return "1.0.0"; } default string getdefaultgroup() { return "de.fuchs.sample"; } } public abstract class abstractfoo { protected string getnamewithversion() { return getname() + " " + getversion(); } protected string getdefaultversion() { return "8.8.8"; } } public class concretefoo { public string getname() { return "foo&q

How to draw a directed network graph with texts on both sides of edges in R (via iGraph, network or some other package)? -

Image
how draw directed network graph texts on both sides of edges in r (via igraph, network or other package)? variables (in vector autoregressive model (var)) in nodes. the granger causalities (p values of f statistics) on both sides of edges. put p values beginning of each arrow. draw near-significant causalities added emphasize. i not figure out how such network diagram via igraph or network package or else. you can use edge.label , vertex.label options together. library(igraph) el <- data.frame(sender = c("lnbist1f","lnbist1f","lnbist1f", "kur1f","kur1f","kur1f", "lnaltin","lnaltin","lnaltin", "mfaiz1f","mfaiz1f","mfaiz1f"), receiver = c("mfaiz1f","lnaltin","kur1f", "lnbist1f&qu

javascript - Jquery 1.11.1 - download file and additional callback -

i have form submit django server calling. $("#my_form").submit(); it server returns xml file executing code: content = some_data_retrieved_from_database_as_xml() response = httpresponse(content, content_type='text/xml') response['content-disposition'] = 'attachment; ' response['content-disposition'] += 'filename=my_file.xml' response['content-encoding'] = 'utf-8' return response google chrome downloads file, want register additional callback function, called myfunction(data). chrome should download file , next call myfunction(this xml file). tried code, doesn't work: $("#my_form").bind('ajax:complete', myfunction); i tried use $.post, after callback function called , unfortunatelly file not downloaded. so want post asynchronously, download returned file, , execute callback. 1 possibility "fake" download link: $.post(post_url, post_data, function(response) {

android - Button from an activity overlapping a fragment -

i have activity buttons , text fields , more stuff, , in activity 1 of buttons opens fragment dynamically on top of activity: btngate.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { sgfrag = new setgatefragment(); fragmentmanager = getfragmentmanager(); transaction = fragmentmanager.begintransaction(); transaction.add(r.id.container,sgfrag); transaction.addtobackstack(null); transaction.commit(); } }); in fragment have few buttons. now, when tested app on phone check if buttons in activity buttons in fragment working worked fine, able click buttons in activity buttons in fragment , correspondent accordingly, decided test app on galaxy note5 , , time when clicked button open fragment 1 of buttons activity overlapped fragment , clickable while neither of buttons in fragment clickable. wasn't sure cause , here fragment opening tag:

.htaccess - how to hide index.php from my url in yii framework -

my code runs url: http://localhost/yii/index.php/adminlogin i want url like: http://localhost/yii/adminlogin .htaccess file options +followsymlinks indexignore */* rewriteengine on # if directory or file exists, use directly rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d # otherwise forward index.php rewriterule . index.php main.php 'urlmanager'=>array( 'urlformat'=>'path', 'showscriptname'=>false, 'rules'=>array( 'redirect/<redirecturl>'=>'site/index', 'login'=>'site/login', 'privacy'=>'site/privacy', 'password'=>'site/forgot', '<controller:\w+>/<id:\d+>'=>'<controller>/view', '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<acti

How to horizontally offset odd and even rows of pixels in an image using Python? -

i learning how use python image manipulation , trying create image odd , rows of pixels shifted horizontally same amount (e.g. odd rows shifted 10 pixels right , rows shifted 10 pixels left). the image consists of single black word printed on white background, this: http://oi63.tinypic.com/2i255bn.jpg with code below, can odd , rows of pixels in 2 separate images, not sure how combine them single 1 20 pixels total horizontal offset. from pil import image im = image.open('myimage.bmp') print im.size white = 255,255,255 = image.new('rgb',[1024,768], white) in range( im.size[0] ): j in range(im.size[1]): if j % 2 == 0 : even.putpixel(( int(i), int(j) ), im.getpixel((i,j)) ) even.show() odd = image.new('rgb',[1024,768], white) in range( im.size[0] ): j in range(im.size[1]): if j % 2 != 0 : odd.putpixel(( int(i), int(j) ), im.getpixel((i,j)) ) odd.show() i new python , grateful this! as rad

function - Cannot read property 'props' of undefined (React) -

i've got react component renders content conditionally, it's bit verbose , repetitive. i've tried wrap repeated code in function call later (the output dependent on whatever argument give function) isn't working. original (verbose) solution: render() { const userid = parseint(this.props.params.userid) const {posts} = this.props if(userid) { const postsforuser = posts.filter( post => post.userid === userid ) return ( <div> {postsforuser.map( post => <post {...this.props} post={post} key={post.id} /> )} </div> ) } else { return ( <div> {this.props.posts.map( post => <post {...this.props} post={post} key={post.id} /> )} </div> ) } } // end render() (unsuccessful) attempt trim down render() { const userid = parseint(this.props.params.userid) function renderpostlist(posts

bash - Capturing exit status of a failed command in a shell script -

i have shell script multiple commands below cmd-1 cmd-2 cmd-3 .... cmd-n i want shell script execution continue if there failure in middle e.g cmd-3 or cmd-7. achieve used set +e. allows me continue execution, unable capture exit status of failed command (since exit status of script based on last command). there way set status of complete script based on last failed command. you can achieve that. not clean way, quite easy. exit_code=0 cmd-1 || exit_code=$? cmd-2 || exit_code=$? cmd-3 || exit_code=$? .... cmd-n || exit_code=$? exit $exit_code the clean way split code functions , check result of commands there.

Android testing via spoon not equal test counts -

Image
i trying use spoon parallel running instrumental tests on connected devicesÑŽ in situation have 3 connected devices @ same time now. have 96 tests @ all. , 2 devices can see in test html spoon report test run, 1 53 run. see picture below: did face same behavior? ideas why can happened?

Multi-user timer with Google App Engine -

we implementing multi-user timer google app engine. when timer ends need calculations , send results users. several users should able start , pause timer different browsers. use channels api communication. how trigger calculations @ specific time? one idea have is, when timer starts, create push task eta set timer finish time. when task runs, check timer state stored in memcache or datastore, , create task if state modified due pausing timer. if timer finished task launches calculations. there better approaches, since there no guarantee task run @ eta ? you have repeating task (re-enqueing itself, delay specified in seconds) check timer state , perform calculations if appropriate or return if not.

javascript - How to fetch password from Alfresco UI page which has been created by admin for the new user? -

i had used code auto generation of mails. problem password shown in mail password generated script. want password fetched alfresco new user page, admin has created password new user not random string. below script generated automatic mail generation. if (document.iscontainer && document.displaypath == "/company home/user homes") { var owner = document.properties["cm:owner"]; var pnode = people.getperson(owner); if (pnode!=null && pnode.exists()){ var username = pnode.properties.username; var email = pnode.properties.email; var randpassword = math.random().tostring(36).substr(2, 30)+"-"+(date.now()); people.setpassword(username, randpassword); logger.debug("invitation mail: user "+username+" password has been changed."); var mail = actions.create("mail"); //mail.parameters.from = "noreply@customdomain"; mail.parameters.to = email; mail.parameters.subject =

c# - Edit Text in Custom Listview Adapter Loses Value on Scroll -

i have custom list view adapter edit text changes value on own , if 1 row filled value, gets on other rows also. here's adapter using system; using system.collections.generic; using system.linq; using system.text; using system.data.sqlclient; using android.app; using android.content; using android.os; using android.runtime; using android.util; using android.views; using android.widget; namespace kites { public class marks { // add if need more public string studentname { get; set; } public string marksscored { get; set; } } public class markslistviewadapter : baseadapter<marks> { private list<marks> mstuduentmarks; private context mcontext; public markslistviewadapter (context context, list<marks> stud) { mstuduentmarks = stud; mcontext = context; } public override int count { { return mstuduentmarks.count; // return mat

Oracle SQL - Unable to Update when using WITH statement -

i trying update column based on virtual dataset created via statement. have simplified statement as possible root issue. appears update not work when using statement, can't believe accurate. error getting ora-00928: missing select keyword here sql statement. with temp1 ( select nn_name smb.accounts ) update sales_play_matrix_working set fy16_focus = 'y' nn_name in ( select temp1.nn_name temp1) if convert 2nd portion of statement pure select, works... with temp1 ( select nn_name smb.accounts ) ( select temp1.nn_name temp1) in oracle, with not go @ beginning of query. can go before select . so: update sales_play_matrix_working set fy16_focus = 'y' nn_name in ( temp1 ( select nn_name smb.accounts ) select temp1.nn_name temp1 );

c++ - Why is my overloaded << not returning any data? -

i have class loads vector<unsigned char> using asio's asynchronous methods. overloaded << operator return data. the problem though buffer full , valid, operator not return data. my buffer: vector<unsigned char>read_buffer; operator declaration: friend std::vector<unsigned char> operator<<(const vector<unsigned char>output, const shared_ptr<socket>socket) noexcept; the implementation: std::vector<unsigned char> operator<<(const vector<unsigned char>output, const shared_ptr<socket>socket) noexcept { std::cerr << output.size() << std::endl; std::cerr << socket->read_buffer.size() << std::endl; return socket->read_buffer; } where std::cerr << socket->read_buffer.size() << std::endl; has right size , step step debugging show content valid. but when data back: vector<unsigned char> res

bash - Does pipexec create some subprocesses? -

i using pipexec tool manage communication between processes. task requires me retrieve ids of processes communicate. example: pipexec -- [ ./cmd1 ] [ b ./cmd2 ] "{a:1>b:0}" "{b:1>a:0}" & then: ps --ppid xxxx where xxxx pid of pipexec process. can sure there 2 processes displayed or there possibility pipexec run internal process @ point of running? from pipexec man page: pipexec creates arbitrary network (directed graph) of processes , pipes in between - cycles possible. overcomes shortcomings of shells typically able create non cyclic trees. pipexec monitors it's child processes , able restart whole network of processes , pipes if 1 crashes. therefore pipexec can used in sysv-init or systemd configuration run network of processes. so, it's possible in case of failures when pipexec restarts the "network", create more processes know. assuming there no failures, appears pipexec creat

javascript - How to create a ready to publish to npm angular 2 library -

i specific , divide question points. 1. want achieve in overall: creating ready published npm angular 2 boilerplate library (latest version) 2. not working: both tutorials beneath, cited @ stackoverflow earlier not working in many aspects or outdated or not clear. in internet there more confusion information how prepare valid , working angular 2 library. http://blog.angular-university.io/how-to-create-an-angular-2-library-and-how-to-consume-it-jspm-vs-webpack/ https://medium.com/@ocombe/how-to-publish-a-library-for-angular-2-on-npm-5f48cdabf435#.c3yuzcrgj 3. want achieve in specific: i know steps , summarize here essential creating library in latest angular 2 version scratch. code examples. may serve stackoverflowers future working boilerplate. what propose write down shortest possible list needs done in points, code examples. if understand question well, want create component , publish library. 1. create component you need create foo.com

ios - Possible bug in libc++ for mac os ,string destructor is not called when string obj goes out of scope -

in libc++ have found basic_string destructor not gets called , once string goes out of scope memory freed calling delete operator rather calling destructor , calling delete operator destructor , why so? can 1 explain this? see sample program void * operator new ( size_t len ) throw ( std::bad_alloc ) { void * mem = malloc( len ); if ( (mem == 0) && (len != 0) ) throw std::bad_alloc(); return mem; } void operator delete ( void * ptr ) throw() { if ( ptr != 0 ) free( ptr ); } int main(int argc, const char * argv[]) { std::string mystr("testing very big string string class"); std::string mystr2(mystr1.begin(),mystr.end()); } put break point on new , delete , check call stack. new operator gets called basic_string class while delete gets called end of main, while ideally basic_string destructor should have called first , delete operator should called via deallocate call of allocator , valid 2nd string creation.

Django - How does a query query itself? -

i have 2 models product id: delivery_date: datetimefield contract: fk contract id: safety_days: integerfield i need products deliver in next x days. x defined in contract safety_days. products = product.objects.filter( q(delivery_date__lte=(datetime.datetime.now() + timedelta(days=contract__safety_days))) ) however,i not able do: days = contract__safety_days i not know how can reference object inside query dynamically. best regards, ruben barros you need use f expressions query. query following way: products = product.objects.filter( q(delivery_date__lte=(datetime.datetime.now() + timedelta(days=f('contract__safety_days')))) )

how to write Spark data frame to Neo4j database -

i'd build workflow: preprocess data spark, ending data frame write such dataframe neo4j set of nodes my idea basic: write each row in df node, each column value represents value of node's attribute i have seen many articles, including neo4j-spark-connector , introducing neo4j 3.0 apache spark connector focus on importing spark data neo4j db... far, wasn't able find clear example of writing spark data frame neo4j database. any pointer documentation or basic examples appreciated. you can write routine , use opensource neo4j java driver https://github.com/neo4j/neo4j-java-driver for example. simple serialise result of rdd (using rdd.tojson) , use above driver create neo4j nodes , push neo4j instance.

themes - Swatches in magento -

i using custom theme in magento , after adding swatches showing dropdown list colors in product description page, want add normal color swatches in page. can it. swatch image option works on default rwd theme. if use custom template should add swatches outlined in post - https://magento.stackexchange.com/questions/45948/how-to-use-magento-1-9-1-0-configurable-swatches-in-default-package-theme-or-a afterwards should upload swatches media/wysiwyg/swatches folder, enable them in admin , proceed attribute settings. follow these instructions

hadoop - Hive - Insert data into partitioned table: partition not found -

i'm having issue while trying inserting new data in hive external partitioned table. table partitioned day, error got is: failed: semanticexception [error 10006]: line 1:51 partition not found ''18102016'' my query following: alter table my_source_table recover partitions; insert overwrite table my_dest_table partition (d = '18102016') select 'iii' primary_alias_type, iii_id primary_alias_id, my_source_table d = '18102016' the my_dest_table has been created as: create external table my_dest_table ( primary_alias_type string, primary_alias_id ) partitioned (d string) row format delimited fields terminated '\t' location 's3://my_bucket/my_external_tables/' any idea on i'm doing wrong? thanks! i believe should alter table my_source_table recover partitions; destination table. alter table my_dest_table recover partitions; try this. note: of course should remove comma alex l