Posts

Showing posts from June, 2013

objective c - Create IOS 3D effect -

how go implementing kind of 3d effect: http://www.youtube.com/watch?v=1i2jnjwdcem i cmmotionmanager class devices attitude (pitch, roll, yaw) , move background image accordingly.. and vague formulation, thats get! :p good luck -v

android - Action Bar icon as up enabled not the title -

how make app icon enabled in actionbarsherlock (not title icon) in whats app. the title clickable icon since android 4.2.2. whatsapp uses custom view display 2 line title. disables title click along way. can same way: actionbar actionbar = getsupportactionbar(); actionbar.setdisplayhomeasupenabled(true); actionbar.setdisplayshowtitleenabled(false); actionbar.setdisplayshowcustomenabled(true); actionbar.setcustomview(r.layout.ab_title); textview title = (textview) findviewbyid(android.r.id.text1); title.settext("title"); /res/layout/ab_title.xml: <textview xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/text1" style="@style/textappearance.sherlock.widget.actionbar.title" android:layout_width="match_parent" android:layout_height="match_parent" android:ellipsize="end" android:gravity="center_vertical" />

sql - query for search results with 'like' -

i'm looking query string better search results. at moment use operator like select title table lower(column) '%data%' but results not accurate enough. my "search engine" looking events, news , webcontent on website, want results 'data' word 'big-data' , 'big data.' , 'all data' , no results 'maxdata' , 'bigdata' , 'datapool' . can use regexp_like ? select title table regexp_like(column, '(\w|^)data(\w|$)', 'i')

arrays - vector with 10^7 elements in scala -

i testing ruby, python , scala see 1 has better support huge arrays. ruby (each) -> 84 mb, 2s # = [];(0...1e7).each{|i| a[i]=i} ruby (expand) -> 254 mb, 60s #a = [*(0...1e7)] python (numpy) -> 95 mb, < 1s # = np.arange(0, 1e7) python (range) -> 391 mb, < 1s # = list(range(0, int(1e7))) scala (range) -> memory limit exceeded :-) # var = range(0, 1e7.toint).map(_.toint) as can see, memory limit exceeds when using scala, what's problem?!!! --update ok should've used var = array.range(0, 1e7.toint) but, if want map array strings? var b = a.map(_.tostring()) failure here... scala's range isn't identical array in pure sense (inside doing additional work besides keeping n items, less memory efficient , eats memory faster). array.range(0, 1e7.toint) closer python's np.arange , work fine.

ios - Sencha Touch 2 app doesn't work on mini iPad -

i have created sencha touch 2 application , packaged ios after doing required provisioning in apple portal. application gets installed , works fine on ios devices except ipad minis, although "devicetype" in packager.json file set "universal". bug in st2 sdk ipad minis not supported? if not, workarounds can it?

How to get all occurance of a string in clob data in MySQL -

i have 1 clob field 'class_data' in table 'school' , in clob there 1 tag name '<fee-value>' , want select occurrences of tag clob data. used below query in mysql , select first occurrence of tag(there 12 occurrence of vallue) select substr(class_data, instr(class_data,'fee-value'),30) school class='s013' , grade='a' , date ='20130301'; the value showing : <fee-value>200</fee-value> and there 11 more such kind of tags not shown please suggest how do?

tkinter - shell is not opening on running a linux executable that was created by freezeing a python script -

this happenned: i wrote simple script: print 'welcome' name = input('type name:') print 'hi, %s' %name raw_input() i wrote on linux machine. freezed cx_freeze , ran linux executable. , nothing happenned. shell(as have happenned in windows) did not open. , confused. took following tkinter script: from tkinter import * root = tk() w = label(root,text="hello") w.pack(side="top") b = button(root,text="quit",fg = "red", bg = "black",command=quit) b.pack(side="bottom") root.mainloop() i freezed script using cx_freeze , when ran executable noticed window opened , worked well. doubt why shell not opening in linux? (i believe because there not shell in linux, not convinced. , if want confirm it.) details i used following setup.py file freezing both scripts: from cx_freeze import setup, executable setup( name = "hello.py" , \ version = "0.1" , \ d

matplotlib - Python - reading a csv and grouping data by a column -

i working csv file 3 columns this: timestamp, value, label 15:22:57, 849, cpu pid=26298:percent 15:22:57, 461000, jmx mb 15:22:58, 28683, disks i/o 15:22:58, 3369078, memory pid=26298:unit=mb:resident 15:22:58, 0, jmx 31690:gc-time 15:22:58, 0, cpu pid=26298:percent 15:22:58, 503000, jmx mb the 'label' column contains distinct values (say total of 5), include spaces, colons , other special characters. what trying achieve plot time against each metric (either on same plot or on separate ones). can matplotlib, first need group [timestamps, value] pairs according 'label'. i looked csv.dictreader labels , itertools.groupby group 'label', struggling in proper 'pythonic' way. any suggestion? thanks you don't need groupby ; want use collections.defaultdict collect series of [timestamp, value] pairs keyed label: from collections import defaultdict import csv per_label = defaultdict(list) open(inputfilename, 'rb') inp

listview - Android OnTouchEvent: Debugging InputEventConsistencyVerifier messages -

i have layout configured gesture listener ontouchevent() . layout contains listview , using gestures capture row id of listview. have following code - itemslist.setontouchlistener(new ontouchlistener() { @override public boolean ontouch(view arg0, motionevent evt) { // todo auto-generated method stub // int action = evt.getaction(); final string debug_tag = "debug"; detector.ontouchevent(evt); switch(action) { case (motionevent.action_down) : log.d(debug_tag,"action down"); return true; case (motionevent.action_move) : log.d(debug_tag,"action move"); return true; case (motionevent.action_up) : log.d(debug_tag,"action up"); return true; case (motionevent.action_cancel) :

string,list pair in a row in data frame in R -

i have data frame follows: date = "2000" values = c("a","b","d") df <- data.frame(date=date,values= values) df date values 1 2000 2 2000 b 3 2000 d actually have thousands of values in values field. instead of printing separate rows want make data frame contains 1 row contains information.ie, : 1 2000 a,b,d is possible in r, map<string,arraylist(string)> in java? it's not clear want, here's code aggregate started: > df$values <- as.character(df$values) > # `list` of values > (da1 <- aggregate(values ~ date, df, i, simplify=false)) date values 1 2000 a, b, d > str(da1) 'data.frame': 1 obs. of 2 variables: $ date : factor w/ 1 level "2000": 1 $ values:list of 1 ..$ 0:class 'asis' chr [1:3] "a" "b" "d" > # values collapsed 1 string > (da2 <- aggregate(values ~ date, df, paste, collapse = "

c# - Windows Azure Cloud Service - Access to deployed xml file denied -

i have mvc app runs fine on premise, runs fine on azure web sites. when deployed cloud service have access denied problems accessing xml files. these xml files bits of data required application determine settings within application. there large number of these under hierarchical folder structure, idea each of these processed allow inheritance of these settings need within application. anyway largely irrelevant @ end of day these xml files stored in folder under web root. the build action properties of xml files set content deployed publish. in fact have rdp'd onto cloud service vm check xml files getting deployed , can confirm are. however whenever application tried read 1 of these files following access denied error. access path 'e:\sitesroot\0\templates\applications\controlproperties.xml' denied. (note : not hard coded path assumed answer below, using httpcontext.current.server.mappath determine physical path of file relative web root) this standard ac

GWT: How to extract a content of a javascript function using (JSNI) -

i calling javascript function gwt client side using jsni follow: anchor.addclickhandler(new clickhandler() { public void onclick(clickevent event) { execute(notification.getactioncode(), notification.getparams()); } }); private static native string execute(string functionname, string params)/*-{ try{ $wnd[functionname](params); }catch(e){ alert(e.message); } }-*/; my problem javascript function contains window.open("servletname?...."). when clicking on anchor, window opened error below: the requested resource (/es/ gwt/core /servletname) not available. if replace window.open("servletname?....") window.open("../../servletname?...."), window open successfully, these javascript functions used outside gwt cant modify . i dont know why part /gwt/core being added url causing problem. there way in gwt before executing javascript function, extract content , adding &q

yii - Double Join Select -

three tables project , users , issues . project table columns: p_id,name,... users table columns: u_id username... issues table columns: i_id i_name... relations: project has many users - 1..* project has many users - 1..* project has many issues - 1..* users has many issues - 1..* what want do: in yii framework logic: select project it's users, these users has have issues of selected project. in tables logic: select issues of project and user. what sql code want mimic: select issue.i_name issue join project on issue.i_id = project.p_id join user on issue.i_id user.u_id what want in yii: //get project $model = project::model()->findbypk( $p_id ); //get project's users $users = $model->users; //get each of users issues of selected project foreach( $users $user ) $issues = $user->issues; to solve have use through in ralations method. project model relations method should this: public function relations() {

version control - Using git flow, how would I revert back to a previous release? -

Image
i'm using git flow projects. when release has been merged master branch tagged release version (e.g. 1.2.0) , deployed production servers. now want quickly revert previous release tag (e.g. 1.1.0) deployment should not have happened. elaboration: i merge 1.2.0 release branch master branch. i tag master branch 1.2.0. i push local repo origin. i conclude released early. i want revert state of master tagged 1.1.0. i want master @ origin revert 1.1.0 state well. how this? assuming want keep history, undo changes 1.2.0 release did. use git-revert create new commit reverts 1.2.0 did: git checkout master git revert head

linux - Why it is copying one file only -

it copying 1 file. find ../../ -type f -name <filename.pdf> -print0 | xargs -0 -i file cp -rv file --target-directory=directory name path why copying 1 file. want copy file having same name created on different date , different folders. try this: cnt=1 find ../../ -type f -name filename.pdf | while read fname f=$(basename $fname) cp $file /target/directory/${f}.${cnt} cnt=$(( $cnt + 1 )) done give each destination file unique number.

jquery - when URL SET SELECTED in select option -

guru! i have url: /montazh_form/#slide1 /montazh_form/#slide2 /montazh_form/#slide3 when enter site first links, select option should selected value in code. , id in url. <option value="#slide1" selected>city_1</option> <option value="#slide2">city_2</option> <option value="#slide3">city_3</option> thanks! only if link's of kind - montazh_form/#slide1 ( no other # ) $("#yourselectid").val(location.hash);

cocoa - making insertRowAtIndexes:withAnimation visible when inserting new row at end -

i'm using insertrowatindexes:withanimation add new row nstableview. if rect of new row visible works fine there problem when inserting new row @ end. row gets inserted expected since scroll position doesn't adjust, animation happens offscreen! any obvious fix i'm missing? you have make new row visible manually. can't call -rectofrow: on row inserting, because it's not in table yet -- instead, @ rect of last row in table, add expected height of new row, , see if resulting rect visible onscreen; if not, need scroll. see nstableview scrollrowtovisible animation if want animate scroll. note on 10.7+ want call -flashscrollers on scrollview well.

html - Logic to Flip Image in jquery -

anyone please explain logic should use flip image in image slider. making image slider, on click on image, should flip , behind want display description of image. i have tried examples. working single image,but when trying in example not working. know how sliding works, explain logic flip image. just give me logic try write code. thanks in advance, html <head> <meta charset="utf-8"> <title>html</title> <link rel="stylesheet" href="main.css" type="text/css" /> <script src="jquery.js" type="text/javascript"></script> <script src="main.js" type="text/javascript"></script> </head> <body> <div id="f1_container"> <div id="f1_card" class="shadow"> <div class="front face"> <img src="http://media-cdn.tripadvisor.c

android - Webservice in PhoneGap -

i newbie phonegap. m stuck. m unable result while calling webservice in phone gap. used both ajax , getjson method. getting result undefined, realdata variable undefined. feeling missing something. please guys. here code.... function ondeviceready() { console.log("device ready111111"); alert("alert device ready"); /*var jqxhr = $ .getjson( 'http://www.infoline.in/mobdata.aspx? reqfor=area_list&city=ahmedabad', function() { console.log("device ready111111....."+jqxhr); alert('success'); }).error(function() { alert('error'); });*/ $(document).ready(function () { $.ajax({ url: "http://www.infoline.in/mobdata.aspx", data: { "reqfor&qu

jquery - $.mobile.changePage not changing page? -

here html code: <div data-role="page" id="mainmenu"> <div data-role="header"> </div> <div data-role="content"> <ul data-role="listview" data-inset="true" style="margin-top:50%; margin-left:20%;"> <li id="prayerid" data-theme="b"><a href="#"><img src="css/images/namazimage.jpg" />prayers </a> </li> <li id="goalid" data-theme="e"><a href="#"><img src="css/images/namazimage.jpg" />goal </a> </li> </ul> </div> </div> <!-- //////////////////////// prayer page start /////

html5 - AS3 .swf file not playing or previewing when uploaded to server -

help needed. i have .swf file of flash game created using as3. have added html file using object tag. when test file locally in browser window on mac plays .swf file. file contained in same folder html file. when upload server , review on ff/chrome/safari display white boxes. previously tried using jquery swfobject, same issue. i've stripped down code bear minimun , used different examples found online , having no luck. code sample: <!doctype html> <html> <body> <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash /swflash.cab#version=8,0,0,0"> <param name="src" value="bodyshopgame.swf"> <embed src="bodyshopgame.swf"></embed> </object> <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#versi

PHP, Merge keys in multidimensional array -

if have array looks this: array ( [0] => array ( [data] => array ( value1 = 1 value2 = 2 ) ) [1] => array ( [data] => array ( value3 = 3 value4 = 4 ) ) ) and turn this: array ( [0] => array ( [data] => array ( value1 = 1 value2 = 2 value3 = 3 value4 = 4 ) ) ) i want merge identical keys @ same level. best route accomplish this? array_merge functions of use? i hope makes sort of sense , in advance can get. you can use array_merge_recursive merge items in original array together. , since function takes variable number of arguments, making unwieldy when number unknown @ compile time, can use call_user_func_array convenience: $result = call_user_func_array('array_merge_recursive', $array); the result have "top level" of input pruned off (logical, since merging multiple items o

tree - SWI prolog make set of variables name with rbtrees or others means -

i have got term want set of variables name. eg. input: my_m(aa,b,b,c,max(d,c),d) output: [b,c,d] (no need ordered order of appearance in input) (that call set_variable_name(input,output).) i can [b,c,d,c,d] input, don't know how implement set (only 1 appearance in output). i've tried storing in rbtrees failed, because of only_one([],t,t) :- !. only_one([x|xs],b,c) :- rb_in(x,x,b), !, only_one(xs,b,c). only_one([x|xs],b,c) :- rb_insert(b,x,x,u), only_one(xs,u,c). it returns tree 1 node , unification b=c, c=d... . think why - because of unification of x while questioning rb_in(..). so, how store once name of variable? or fundamentally wrong idea because using logic programming? if want know why need this, it's because asked implement a* algorithm in prolog , 1 part of making search space. you can use sort/2 , removes duplicates.

d3.js - D3 tree: lines instead of diagonal projection -

i using d3.js create tree using this example . this handles data have , produces desired outcome except 1 detail: don't want wiggly connector lines between nodes, want clean , simple line. can show me how produce that? i've been looking @ api documentation d3.js, no success. understood, svg.line function should produce straight line given set of 2 pairs of coordinates (x,y). think need know is: given data, how create line given (cx,cy) of each pair of nodes in links array: var margin = {top: 40, right: 40, bottom: 40, left: 40}; var width = 960 - margin.left - margin.right; var height = 500 - margin.top - margin.bottom; var tree = d3.layout.tree() .size([height, width]); var diagonal = d3.svg.diagonal() .projection(function(d) { return [d.y, d.x]; }); var svg = d3.select("body").append("svg") .attr("width", width + margin.left + margin.right) .attr("height", height + margin.top + margin.bottom) .a

android - problems with Request.executeMeRequestAsync(session, Request.GraphUserCallback()) function -

i'm following tutorial login on android application using facebook. i've had many problems hash keys , , think i've solve them all, because session gets opened state. the problem i'm having after log in facebook, when session opened, code executes request.executemerquestasync() , never enters oncomplete() part... idea? here code... package com.example.firstandroidapp; import java.security.messagedigest; import java.security.nosuchalgorithmexception; import android.app.activity; import android.content.intent; import android.content.pm.packageinfo; import android.content.pm.packagemanager; import android.content.pm.packagemanager.namenotfoundexception; import android.content.pm.signature; import android.os.bundle; import android.util.base64; import android.util.log; import android.widget.textview; import com.facebook.request; import com.facebook.response; import com.facebook.session; import com.facebook.sessionstate; import com.facebook.model.graphus

android - Invoke a method in Singleton class using reflection in java -

i have following class: public class abcinfo { private static abcinfo instance = null; public static abcinfo getinstance(param param); // instance private abcinfo(param); // making singleton class public void methoda(param1 param1); // need invoke method } using reflection in java, how can invoke methoda() . writing android application, want use method in existing(assume present time) application in phone. below things have tried: string apkname = activity.getpackagemanager().getapplicationinfo(packagename, 0).sourcedir; pathclassloader mypathclassloader = new dalvik.system.pathclassloader( apkname, classloader.getsystemclassloader()); class<?> handler = class.forname(classname, true, mypathclassloader); method m0 = handler.getdeclaredmethod("getinstance", new class[] { param.class }); m0.setaccessible(true); object b = m0.invoke(null, new object[]{ param}); method m = handler.getmethod("methoda", new class[] { param

Do I need two different PartnerLinks for two different calls to the same Web Service in BPEL? -

if want make 2 parallel calls (in 1 flow activity) same web service in bpel , need create 2 different partnerlinks or can use same one? you can invoke same partnerlink multiple times in parallel in same flow . not need define new one. if expect result invocation, need different outputvariables , however. if write same variable in parallel, have race conditions in other programming language.

excel - vba: change event code for dropdown missing -

Image
i have dropdown box in excel sheet. @ point vba assigned event code dropdown, deleted. now can not use drop down, because @ each value change complains not being able execute deleted code. if want see code assigen throws error "invalid reference". how can delete event code? edit whole error disappears if add requested function public sub dropdown4_beiÄnderung() ' must exist end sub but want able delete it. if know name of combobox shape, in vba: sub dropdown4nomacro() dim shpname string shpname = "drop down 4" '## modify needed.' activesheet.shapes(shpname).onaction = vbnullstring end sub edit without vba: you should able right-click on control, , choose assign macro , see presently dropdown4_beiÄnderung (or thisworkbookname!dropdown4_beiÄnderung ). just delete field empty, , press ok . see screenshot, highlighted field should empty before press ok . original answer (assumed connected worksheet_change event.

jquery - where to add jQueryUI scripts in MVC page -

i'm using editortemplates folder, , following datetime.cshtml add date picker (jquery ui) datetime fields: @model nullable<system.datetime> @if ( model.hasvalue ) { @html.textbox( "" , string.format( "{0:yyyy-mm-dd hh:mm}" , model.value ) , new { @class = "textbox" , @style = "width:400px;" } ) } else { @html.textbox( "" , string.format( "{0:yyyy-mm-dd hh:mm}" , datetime.now ) , new { @class = "textbox" , @style = "width:400px;" } ) } @{ string name = viewdata.templateinfo.htmlfieldprefix; string id = name.replace( ".", "_" ); } <script type="text/javascript"> $(document).ready(function () { alert("adding date picker"); $("#@id").datepicker ({ dateformat: 'dd/mm/yy', showstatus: true, showweeks: true, highlightweek: true, numberofmonths: 1,

java - What is this design (or anti-) pattern and more importantly is there a better way? -

i'm receiving webservice list of key-value pairs, , have inherited following code: public string iconvalue = null; ... (over 50 class variables assigned in myobject constructor below) public myobject(list<attribute> attrs) { string attrname, attrvalue; (attribute : attrs) { try { attrname = a.getname(); attrvalue = a.getvalue(); if (attrvalue == null || "".equals(attrvalue.trim())) continue; if (icons.equals(attrname)) { //do including assignment this.iconvalue = attrvalue; } else if (url.equals(attrname)) { //do including assignment } else if (...) giant list of on 50 different attributes hardcoded { //do including assignment } ... so,except keeping hashmap - there better way above keep hard coded variable

Displace z-axis with gnuplot -

is possible displace z-axis middle of x-axis gnuplot? i've found great gnuplot script here fits needs perfectly, except z-axis should going @ middle of x-axis. by default gnuplot draws border , places labels on border. draw border @ bottom, i.e around (x,y)-plane : set border 1+2+3+4 or disable completely: set border 0 draw zaxis through x,y-origin, , place ztics on same: set zzeroaxis lt -1 set ztics axis same x , y, if like.

split up a matrix in matrices by value of column nodes in R -

i have matrix in r: [,1] [,2] [,3] [,4] [,5] 19992 -33.54971 23.35746 0.0000000 2.107680e+01 19980219 19993 -33.54203 23.40079 0.0000000 2.107696e+01 19980219 19994 -33.53453 23.44445 0.0000000 2.107713e+01 19980219 19995 -33.52719 23.48840 0.0000000 2.107730e+01 19980219 19996 -33.51965 23.53200 0.0000000 2.107746e+01 19980219 19997 -33.51183 23.57565 0.0000000 2.107763e+01 19980219 19998 -33.50446 23.61958 0.0000000 2.107780e+01 19980219 19999 -33.49678 23.66313 0.0000000 2.107796e+01 19980219 its lot bigger (2.000.000 rows) think example question. i want extract rows have value between e.g. -33.52... , -33.55... in first column , create new matrix of these extracted rows. the output matrix example: 19992 -33.54971 23.35746 0.0000000 2.107680e+01 19980219 19993 -33.54203 23.40079 0.

How to add impulsive and gamma noise to an image without using imnoise function in matlab? -

i wondering if give me advice on how add impulsive , gamma noise image separately? it's easy imnoise function of matlab, i'm not allowed use imnoise, our ta said can use rand function. i came across code seems doesn't work should(for impulse noise): noisyimage=originalimage+255*rand(size(originalimage)); there's few issues line of code: if image rgb (e.g., loaded colour jpeg or something), you'll have add 3 layers of noise; e.g., use rand([size(originalimage) 3]) 255*rand() generates double-valued numbers, whereas image of type uint8 or (check class(originalimage) ). fix, use randi instance: noisyimage = randi(255, [size(originalimage) 3], class(originalimage)); you add noise of maximum magnitude 255 all pixels. might overflow many of pixels (that is, assigned values higher 255). avoid, use noisyimage = min(255, originalimage + randi(...) ); the noise direction positive . true noise brings down values of pixels. so, use noi

Make Postal Code un required for Ireland in Magento -

i have magento 1.7.0.0 intalled on server. facing issue regarding optional postal code country. mean want make postal/zip code optional ireland, have selected ireland in list of optional countries in admin panel (system > configuration > general). when visit checkout page , select ireland, removes asterisk zip/postal code field it's fine when click on continue, shows alert box ("zip/postal code required value"). why? please me! in advance... i thinks becuase postal code input has html class required-entry if edit template , quit class js not check input , alert not triggered. remember use conditional or quit class ireland.

powershell - Loading app.config into the AppDomain -

i can't app.config file load app domain. i'm using [system.appdomain]::currentdomain.setdata("app_config_file", $config_path) from powershell calling .net assembly uses app.config app.config file still not loaded. i've tried resetting cache explained in using currentdomain.setdata("app_config_file") doesn't work in powershell ise . here test script: $configfile = "{actualphysicalpath}\app.config" gc $configfile add-type -assemblyname system.configuration [configuration.configurationmanager].getfield("s_initstate", "nonpublic, static").setvalue($null, 0) [configuration.configurationmanager].getfield("s_configsystem", "nonpublic, static").setvalue($null, $null) ([configuration.configurationmanager].assembly.gettypes() | {$_.fullname -eq "system.configuration.clientconfigpaths"})[0].getfield("s_current", "nonpublic, static").setvalue($null, $null) [config

How to rename many variable names at once (c/c++) -

is there tool allow me rename large number of variable names @ once. i have large number of variables want put c structure , therefore, need add param. beginning of each name included in structure. if want @ once, put regular expression advanced search/replace function. ^(name1|name2|name3)$ ought work. no guarantee won't catch other things besides variable uses (in particular, variable declarations). if want that, have work clang's tooling.

ruby on rails - Return string from multiple array items -

i have multiple arrays have code string items in them. need match code given string , return class name matched array. might better if show i've got. below arrays , underneath string need return if given string matches item within array. lets send string of '329' should return 'ss4' string: ['392', '227', '179', '176'] = 'ss1' ['389', '386'] = 'ss2' ['371', '338', '335'] = 'ss3' ['368', '350', '332', '329', '323', '185', '182'] = 'ss4' i need know best approach this. create helper method , have array each code block , check each array see if given string code contained , return string, ss1 or ss4. idea? the efficient approach generate translator hash once can perform lookup super fast: codes = { ss1: ['392', '227', '179', '176'], ss2: ['389',

arrays - Unable to open a file with uigetfile in Matlab -

Image
i building code lets user open files. reference = warndlg('choose files analysis.'); uiwait(reference); filenames2 = uigetfile('./*.txt','multiselect', 'on'); if ~iscell(filenames2) filenames2 = {filenames2}; % force cell array of strings end numberoffiles = numel(filenames2); data = importdata(filenames2{i},delimiterin,headerlinesin); when run code, prompts show up, press ok, , nothing happens. code stops, telling me : error using importdata (line 137) unable open file. error in freqvschampb_no_spec (line 119) data=importdata(filenames2{1},delimiterin,headerlinesin); i don't have opportunity select file. cellarray stays empty showed in following image. matlab can't find file have selected. variable filenames2 contains name of file, not full path. if don't provide full path importdata , search whatever file name provide on matlab path, , if can't find it error see. try - i'm doing single selection ea

javascript - How do I use global variables to access plugin methods in jQuery? -

my experience jquery limited, hence please feel free edit question in case verbiage incorrect. while initiating plugin i'm assigning variable: var test = $('.fancybox').fancybox({ padding : 0, margin : 10, closebtn : false }); now, i'm trying access instance of plugin , call it's method as: $(document).on('keyup', function(e) { var code = (e.keycode ? e.keycode : e.which); if (code == 40) { test.cancel(); return false; } }); this throws error — "test undefined". per understanding appears problem scope of variable test . however, test has been declared inside of jquery(document).ready(function($) , such should globally available functions inside of jquery(document).ready(function($) . doing wrong here?

paypal - How to split payments to two accounts using common payment systems? -

i'm creating service people can sell stuff , middle man want make cut. i don't want accept whole payment tho , split later when customer paying not become trader. i know how make transfers on paypal , co. possible split these payments right away? well if use right keywords googling you'll find this: split paypal payment 2 accounts what needed delayed chained payments can found here.

javascript - trying to generate bar chart in d3 using object-oriented approach -

ploti'm new d3 , new javascript (most of experience python). went trough tutorial in book interactive data visualization: web scott murray on creating bar chart. didn't have nay issues completing tutorial, approach takes in book seems procedural using global variables. create similar chart, use object-oriented approach able encapsulate variables , reuse code generate multiple charts in 1 script without having repeat code on , on again. i've tried far without luck: function d3chart(id, data, width, height, padding) { this.id = id this.data = data this.width = width this.height = height this.padding = padding this.svg = d3.select("body") .append("svg") .attr("width", width) .attr("height", height) .attr("class", "chart") .attr("id". this.id);

c# - Can I force RavenDB to allow IDocumentSession.Store() to accept an entity with existing id? -

i have application upgrading ravendb 1 ravendb 2. application not store domain object in database directly. instead, domain objects converted document objects prior persistance (and vice versa when reading). example, domain object: public class user { public string id { get; private set; } public string email { get; set; } public string passwordsalt { get; private set; } public string passwordhash { get; private set; } public void changepassword(string oldpassword, string newpassword) { ... } . . . } and corresponing document object (which gets stored in database): class userdocument { public static userdocument fromentity(user user) { ... } public string id { get; set; } public string email { get; set; } public string passwordsalt { get; set; } public string passwordhash { get; set; } public user toentity() { ... } } so, if want change user document stored in database, typically

algorithm - HSV color removal/dropout of form fields -

Image
i'm writing system dropout field borders form image. fields may have writing in them need correctly keep if handwriting crosses field border. i have 2 images: 1 color image (converted hsv colorspace) , 1 black/white image line pixel per pixel (these produced scanner) i remove (pluck) field border pixels black , white image, given colors in color image. i have advantage in know apriori exact location of field, , widths/heights of field border lines. my current implementation consists of (for each field), scanning field border on color image , calculating average hsv value field border (since know field border is, visit "field border" pixels, may visit few handwriting pixels if cross field border, idea won't skew average much). once have "average" hsv value field border, scan field border again, , each pixel compute following delta function: if delta value between "current" pixel , average hsv less 0.07 (found empirically) set pixe

java - Dijkstra with a heap. How to update the heap after relaxation? -

i trying implement dijkstra algorithm. foreach distance d d = infinity d[source] = 0 create_heap_based_on_distances(); while(true) bestedge = heap[0] remove_minimum_from_heap //it heap[0] foreach adjacency of bestedge if (weight + bestedge_distance < current_distance) { current_distance = weight + bestedge_distance // have update heap, how can that? } if (heap_empty) break so, in relaxation, how can update heap, have correct order? don't have heap's index node in step. mean have create new array nodes[edge] = heapindex , heap's index node? seems inefficient need update insert_to_heap , remove_minimum functions. c or java code okay. does mean have create new array nodes[edge] = heapindex, heap's index node? yes. but seems inefficient need update insert_to_heap, remove_minimum functions. array updates cheap, both in theory , in practice, , have few of per heap operation, not

edit the program to sumif with visible cells in MS excel -

i got countifv thats counts visible , sumifsv sum visible cells ... want sumif visible using vba default using sumifs on visible lines only i have large table, lots of rows , lots of columns has material (sand, stone, etc.) batched information. wanted able allow user use filters select data want view, able review summary information (totals hour of day, totals material, etc.) on other sheets. i had working , fast using dsum and/or subtotal, these functions don't exclude non-visible (filtered) lines in list. using previous posts saw on site, able come works, extremely slow. i hoping more experienced folks advise me on faster. what need take list of records on sheet contain 30 material columns of information (target , actual batch weight amounts.) need group each of these lines material relative time bucket (12:00 12:59 am, 1:00 1:59 am, etc.) user can of course select time bucket want view i using sumifs function 2 critieria ( i.e. time >=12:00 , time < 1:00

java - Why won't my array print out correctly? -

this question has answer here: what's simplest way print java array? 23 answers i trying write simple program using code below make single dimensional array can call value using index numbers. using java , eclipse compiler. whenever try debug or run program, full array prints out this: [i@1fa8d3b . class array { public static void main(string[] args) { int[] myarray = new int[] {15, 45, 34, 78, 65, 47, 90, 32, 54, 10}; system.out.println("the full array is:"); system.out.println(myarray); system.out.println("the 4th entry in data is: " + myarray[3]); } } the correct data entry prints out when called though. have tried answers online should do, not find works. starting learn java there simple answer overlooking. if has ideas, appreciative. java object oriented language. when calling system.out.print(myarr

actionscript 3 - Creating a mobile VSliderSkin for VSlider - with test case and screenshots -

Image
hslider has been optimized mobile, vslider not - can see here: at same time mobile-themed hsliderskin.as looks pretty simple. so i've copied file "vsliderskin.as" in simple test project , - replaced obvious references "hslider" "vslider" in measure() method swapped "width" <-> "height" in layoutcontents() swapped "width" <-> "height" , "x" <-> "y" slideapp.mxml (just add blank flex mobile project): <?xml version="1.0" encoding="utf-8"?> <s:application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" applicationdpi="160"> <s:vslider skinclass="vsliderskin" horizontalcenter="0" height="80%" /> <s:hslider skinclass="spark.skins.mobile.hsliderskin"

sql server - SQL SUM() condtions questions -

i have table looks this: +----+------+--------+----------+ | id | code | optype | quantity | +----+------+--------+----------+ | 0 | | in | 7 | | 1 | b | in | 8 | | 2 | | out | 2 | | 3 | b | in | 7 | | 4 | b | out | 12 | +----+------+--------+----------+ i want sum(quantity) depending on optype. when optype out, quantity field should multiplied -1. the result of query should be: code in out final 7 2 5 b 15 12 3 i've tried this, doesn't work: select(select sum(quantity) table optype = 'in') as[in], (select sum(quantity) table optype = 'out') as[out], (select sum(quantity) table optype = 'in') - (select sum(quantity) table optype = 'out') as[final] table group code sql server has pivot functionality. select [code], [in], [out], [in] - [out] [final] ( select [code], optype, sum(quantity) quantity

Get Django sessions on Node.js -

i'm trying add node.js web application in django have real time. i'm doing functionality of "like" in facebook, when users click "like" ajax post id of song domain.com:3000 (node.js server). i have user id on session variable, don't know how access session variable node.js. here code: node.js var express = require('express'); var app = express(); app.use(express.static('./public')); app.use(express.bodyparser()); app.use(express.cookieparser()); app.get('/', function(req, res){ res.send("id user: " + req.session.user_id); }); app.listen(3000); console.log("working under 3000") django def auth(request): if request.is_ajax() , request.method == 'post': email = request.post.get('username', '') password = request.post.get('password', '') autenti = jayapalbackend() auth = autenti.authenticate(email, password)

jquery - Setting Highcharts Series and Category data dynamically -

im trying update chart via ajax call using following code $j(document).ready(function () { $j("#filter").click(function () { buildreport(); }); $j("#container").highcharts({ chart: { type: 'column', marginright: 130, marginbottom: 100 }, title: { text: 'ses open group', x: -20 //center }, yaxis: { title: { text: '' }, min: 0, allowdecimals: false }, xaxis: {}, tooltip: { formatter: function () { return '<b>' + this.x + '</b><br/>' + this.series.name + ': ' + this.y + '<br/>' + 'total: ' + this.point.stacktotal; } }, plotoptions: { column: {