Posts

Showing posts from March, 2012

asp.net - PayPal IPN Sandbox response always INVALID -

i'm trying implement paypals ipn on website in asp.net using c#. using sample code given paypal found here: https://cms.paypal.com/cms_content/gb/en_gb/files/developer/ipn_asp_net_c.txt i have enabled ipn on account url of ipn on site. url used in code can see in link above sandox url paypal testing. i using ipn simulator , it's giving me "ipn sent response" on website displays invalid every time. i have tried displaying strrequest string in label , shows me "&cmd=_notify-validate" without quotes. thought meant add part on rest of returned data paypal. here button: this button i'm using <script src="paypal-button.min.js?merchant=myemail" data-button="buynow" data-name="name" data-quantity="1" data-amount="00.50" data-currency="gbp" data-shipping="0"

r - searchTwitter - search tweet but not handle -

trying dabble in doing basic sentiment analysis using twitter library , searchtwitter function. i'm searching tweets specific "samsung". can retrieve tweets below command: samsung_t = searchtwitter("#samsung", n=1500, lang="en",cainfo="cacert.pem") this know return tweets containing hash-tag #samsung. however, if wanted search tweets containing "samsung" in them: give same command without "#" samsung_t = searchtwitter("samsung", n=1500, lang="en",cainfo="cacert.pem") this return tweets containing term "samsung" in them including handle. example: return tweet: "@i_love_samsung: r programming", irrelevant criteria. if wanted sentiment analysis on say, "samsung phones", i'm afraid data can skew results. is there way can force searchtwitter in "tweet" not "handle"? thanks lot in advance. looking @ search api documenta

Google Org Chart - Draw a chart from JSON (mysql) -

Image
i'm trying draw organizational chart ( http://goo.gl/wgftfo ) json (php - mysql) doen'st display well. here html code: <script type="text/javascript"> google.load('visualization', '1', {packages:['orgchart']}); google.setonloadcallback(drawchart); function json(){ $.ajax({ type: "post", url: "function/ver.php", success: function(datos){ datos = eval(datos); (var i=0;i<datos.length;i++){ var id = datos[i].id; var nombre = datos[i].nombre; var jefe = datos[i].jefe; alert(id); drawchart(id, nombre); function drawchart(id, nombre) { //alert("id: " + id + " | nombre: " + nombre);

jQuery Slideshow that supports more than 1 image per slide? -

i'm looking jquery slideshow plugin allow more 1 image per slide. need place 4 different images 1 slide , have them rotate. unfortunately sliders i've viewed doesn't seem allow more 1 image. know of slideshow plugin this. try jcarousel you can take @ of examples or documentation better idea of it's capabilities. luck!

Specifying Units in Django -

i'm creating small app counts calories in recipes. i'm curious know if there better way this. each recipe has ingredients. each ingredient has amount, weight, , calorie profile. so instance: recipe: flourless nutella cake ingredient: eggs amount: 4 weight: large eggs (could cups or oz or whatever) calories: 312 (calculated amount * weight) ingredient: nutella amount: 8.5 weight: ounces calories: 850 here models.py: from foodlist.models import food, weight class ingredient(models.model): food = models.foreignkey(food) weight = models.foreignkey(weight) amount = models.floatfield(default=1.0) ... class recipe(models.model): ingredients = models.manytomanyfield(ingredient, blank=true, null=true) ... the problem every time want make new recipe different amount of eggs, first have make new ingredient containing correct amount of eggs. have 1 ingredient says "4 large e

entity framework - Allow asp.net sqlmembership users to create "subusers" -

Image
i've tried searching days , can't seem find adequate answer i'll ask here. i'm building asp.net membership website. what want is: allow user create account - usera want allow usera create "sub accounts" tied account, different roles different login names (i'll using email address login name) usera account admin of sorts. usera's sub accounts less "adminish" usera, data write db (entity framework) still tied main usera account referenced tables via membership.getuser() api calls. so 2 questions: 1) how reference membership tables in entitydatamodel using db first (i ran aspnet_regsql.exe) 2) how need go allowing usera create own sub users? here's image of custom tables: [masteraccountuser] masteraccountid = aspnet_membership.userid accountnumber = autoincrement number [useraccount] - subaccount of [masteruseraccount] accountid = aspnet_membership.userid (if have have each user create own) masteraccountid = aspnet_m

ios - Best way to redraw a custom view when orientation changes -

Image
i have custom view: -(id)initwithframe:(cgrect)frame { cgrect framerect = cgrectmake(0, navigation_bar_height , frame.size.width, 4 * row_height + navigation_bar_height + message_body_padding); self = [super initwithframe:framerect]; if (self) { _selectionviewwidth = &frame.size.width; [self initview]; } return self; } -(void)initview { cgrect sectionsize = cgrectmake(0, 0 , *(_selectionviewwidth), row_height * 4); _selectionview = [[uiview alloc] initwithframe:sectionsize]; [_selectionview setbackgroundcolor:[uicolor clearcolor]]; that use in view controller next way: _mailattributesview = [[mailattributesview alloc]initwithframe:self.view.frame]; _mailattributesview.delegate = self; [self.view addsubview:_mailattributesview]; so when orientation changes p l have next problem: what's best way orientation change callback , redraw custom view? you need override uiview layoutsubviews method , pro

c# - Finding Elbow Angle with Kinect -

vector3d rwrist = new vector3d(skel.joints[jointtype.wristright].position.x, skel.joints[jointtype.wristright].position.y, skel.joints[jointtype.wristright].position.z); vector3d relbow = new vector3d(skel.joints[jointtype.elbowright].position.x, skel.joints[jointtype.elbowright].position.y, skel.joints[jointtype.elbowright].position.z); vector3d rshoulder = new vector3d(skel.joints[jointtype.shoulderright].position.x, skel.joints[jointtype.shoulderright].position.y, skel.joints[jointtype.shoulderright].position.z); vector3d wristtoelbow = vector3d.subtract(rwrist, relbow); vector3d elbowtoshoulder = vector3d.subtract(relbow, rshoulder); elbowangle = vector3d.anglebetween(elbowtoshoulder, wristtoelbow); so keeps returning nan? appreciate :) guys!! you have normalize vectors. try adding code. recommend anglebetweenvector method (see code below). public class angles { public double angl

android - Turning screen on again after display timeout? -

my activity starts following code in order shown above keyguard/turn screen on standby: @override public void onattachedtowindow() { this.getwindow().setflags(windowmanager.layoutparams.flag_fullscreen | windowmanager.layoutparams.flag_dismiss_keyguard | windowmanager.layoutparams.flag_show_when_locked | windowmanager.layoutparams.flag_turn_screen_on, windowmanager.layoutparams.flag_fullscreen | windowmanager.layoutparams.flag_dismiss_keyguard | windowmanager.layoutparams.flag_show_when_locked | windowmanager.layoutparams.flag_turn_screen_on); } this works fine, however, activity receives intent after few seconds (30-45s) , on devices, default system display timeout have kicked in if user hasn't touched device. there way show activity again sleep when intent comes in? i've tried acquiring "screen-on"-wakelock when new intent arrives, no dice. thanks!

Android Airplane Mode - Different API versions -

can tell me how handle situation. aware api 17, testing airplane mode has been moved setting.system settings.global . knowing many of users on phones using older api, wanting handle deprecation correctly, i've written following method: @suppresswarnings("deprecation") public static boolean isairplanemodeon(context context) { try { return settings.global.getint(context.getcontentresolver(), settings.global.airplane_mode_on, 0) != 0; } catch (exception e) { return settings.system.getint(context.getcontentresolver(), settings.system.airplane_mode_on, 0) != 0; } } the problem in manifest, i've set minsdk value 9, want it. conflict error: call requires api level 17 (current min 9) what correct way handle type of situation? thanks! check version user has if(build.version.sdk_int <= build.version_codes.jellybean){ }else{ } then suppress lint error

c# - Avoid excessive type-checking in generic methods? -

my question concerns type-checking in chain of generic methods. let's have extension method attempts convert byte array int, decimal, string, or datetime. public static t read<t>(this bytecontainer ba, int size, string format) t : struct, iconvertible { var s = string.concat(ba.bytes.select(b => b.tostring(format)).toarray()); var magic = fromstring<t>(s); return (t)convert.changetype(magic, typeof(t)); } this calls method called fromstring translates concatenated string specific type. unfortunately, business logic dependent on type t. end megalithic if-else block: private static t fromstring<t>(string s) t : struct { if (typeof(t).equals(typeof(decimal))) { var x = (decimal)system.convert.toint32(s) / 100; return (t)convert.changetype(x, typeof(t)); } if (typeof(t).equals(typeof(int))) { var x = system.convert.toint32(s); return (t)convert.changetype(x, typeof(t)); }

Powershell script to check if a file exists on remote computer list -

i'm new @ powershell, , i'm trying write script checks if file exists; if does, checks if process running. know there better ways write this, can please give me idea? here's have: get-content c:\temp\svchosts\maquinasestag.txt | ` select-object @{name='computername';expression={$_}},@{name='svchosts installed';expression={ test-path "\\$_\c$\windows\svchosts"}} if(test-path "\\$_\c$\windows\svchosts" eq "true") { get-content c:\temp\svchosts\maquinasestag.txt | ` select-object @{name='computername';expression={$_}},@{name='svchosts running';expression={ get-process svchosts}} } the first part (check if file exists, runs no problem. have exception when checking if process running: test-path : positional parameter cannot found accepts argument 'eq'. @ c:\temp\svchosts\testpath remote computer.ps1:4 char:7 + if(test-path "\\$_\c$\windows\svchosts" eq &quo

installer - what is Hex representation of MSIUSEREALADMINDETECTION? -

i need run installer admin , not system needs connect sql server database using windows authentication. based on research, need set msiuserealadmindetection property "1" i figure these installer properties have hex representation shown in blog @ http://blogs.msdn.com/b/astebner/archive/2007/05/28/2958062.aspx var msidbcustomactiontypeinscript = 0x00000400; var msidbcustomactiontypenoimpersonate = 0x00000800 the script set value available here , not give hex representation of msiuserealadmindetection. know hex representation of msiuserealadmindetection? or has better solution editing installer post build? you can find definitions of these kind of identifiers on machine in windows sdk directory. didn't mention vs version, start looking in c:\program files (x86)\microsoft sdks\windows\x.x\include. if have vs2012+ start looking windows kits. msidefs.h file of interest. contains: // properties related uac #define ipropname_msi_uac_deployment_compliant

ruby on rails - Undefined method `on_ride_photo=' -

model: class coaster < activerecord::base extend friendlyid friendly_id :slug, use: :slugged belongs_to :park belongs_to :manufacturer attr_accessible :name, :height, :speed, :length, :inversions, :material, :lat, :lng, :park_id, :notes, :manufacturer_id, :style, :covering, :ride_style, :model, :layout, :dates_ridden, :times_ridden, :order, :on_ride_photo test: it { should validate_presence_of(:on_ride_photo) } { should ensure_inclusion_of(:on_ride_photo).in_array([true, false]) } { should_not allow_value(4).for(:on_ride_photo) } { should_not allow_value('lots').for(:on_ride_photo) } factory: factorygirl.define

AngularJS with Flask authentication -

i'm building web app using angularjs , rest-api build flask framework. the app consists of 2 parts: a part users don't have logged in: can register, login, check out features... a part users have logged in. to keep things simple thinking separate these 2 parts in 2 angular apps , let flask direct right app according being logged in or not. i wondering if approach? think can keep authentication pretty simple. i'm not sure 2 separate apps idea. it seems have fair amount of duplication if way, because don't think 2 apps mutually exclusive. @ least, imagine public options available when user logged in, right? means chunk of public application, client , server-side, have part of protected application. sounds hard maintain. also consider user experience. user have download entire new application @ login , logout time, @ least first time until gets in browser's cache. depending on size of application few seconds of waiting. the standard approa

ldap - BER Encoding of a "Choice" -

i trying parse ldap bind request using apache harmony asn.1/ber classes (could use library, chose has apache license). my question on encoding of "choice" in asn.1. rfc defines ldap asn.1 schema ( http://www.rfc-editor.org/rfc/rfc2251.txt ) gives following part bind request: bindrequest ::= [application 0] sequence { version integer (1 .. 127), name ldapdn, authentication authenticationchoice } authenticationchoice ::= choice { simple [0] octet string, -- 1 , 2 reserved sasl [3] saslcredentials } saslcredentials ::= sequence { mechanism ldapstring, credentials octet string optional } how choice there encoded? i generated sample bind request using jxplorer , captured raw data sent. looks this: 00000000 30 31 02 01 01 60 2c

jquery - Get all next siblings of element -

what best way next siblings of element? not next 1 , not siblings before it? this way found, there jquery selector it? $('.someclass').click(function () { var chosenone = $(this); $('.someclass').removeclass('extraclass'); chosenone.parent().find('.someclass').each(function () { var el = $(this).index(); if (el >= chosenone.index()) { $(this).addclass('extraclass'); } }); }); fiddle the .nextall() method made this: chosenone.nextall(".someclass").addback().addclass("extraclass") fiddle

codenameone - Codename one image component -

Image
what's best component include image layout? i found label job. i've problem customizing width , height of image. this android , feel: i'd migrate cno.so, created custom theme backgound gray , margin around container. layout of container tablelayout set have 4 columns , 1 row. i'd see content ( image, multiline label, label, image ) autoscale based on parent width , i'd defined components width percentage fraction of parent. for now, first image takes width , height icon, bigger needed. takes bit more space intend to. how can change image size without resizing image resource? by default label has small amount of padding/margin around (and components). you can test problem using label.setuiid("container") has 0 padding , margin (by default). you can edit app theme using designer tool , add new uiid label can override padding/margin 0.

Receive replies from Gmail with smtplib - Python -

ok, working on type of system can start operations on computer sms messages. can send initial message: import smtplib fromadd = 'gmailfrom' toadd = 'smsto' msg = 'options \nh - \nt - terminal' username = 'gmail' password = 'pass' server = smtplib.smtp('smtp.gmail.com:587') server.starttls() server.login(username , password) server.sendmail(fromadd , toadd , msg) server.quit() i need know how wait reply or pull reply gmail itself, store in variable later functions. instead of smtp used sending emails, should use either pop3 or imap (the latter preferable). example of using smtp (the code not mine, see url below more info): import imaplib mail = imaplib.imap4_ssl('imap.gmail.com') mail.login('myusername@gmail.com', 'mypassword') mail.list() # out: list of "folders" aka labels in gmail. mail.select("inbox") # connect inbox. result, data = mail.search(none

php - multiple callback using jquery .post ajax -

is possible multiple callbacks using jquery .post ajax upload of image php? sending image server processing thru binary string , hav front end display status when image has uploaded processing icon. currently using standard .post ideally scenario looking - jquery: $.post( 'process.php', { myvar:myvar}, function(data){ if(data=='callback_1'){ // process 1 }else if(data=='callback_2'){ // process 2 } }); php: $myvar = $_post['myvar']; // after process 1 echo 'callback_1' // after process 2 echo 'callback_2' i set array in php script $r['callback_one'] = 'complete'; $r['callback_two'] = 'fail'; echo json.encode($r); javascript: r = json.parse(data); if (r.callback_one === 'complete){//do something}; of course still sends callbacks @ once, may not after. the thing can think of if need try , things sequentially use flushing: how flush ou

c# - How to get decimal number without decimal separator using OleDbDataAdapter (Fixed Length Text File)? -

let's suppose have fixed length text file 3 columns, 2 of them double 2 decimal places have no separator (like dot or comma): 21318545 22422523 65498798 65465463 using oledbdataadapter have create schema.ini file, , i'm trying this: [numbers.txt] colnameheader=false format=fixedlength numberdigits=2 decimalsymbol= col1="a" short width 2 col2="b" double width 3 col3="c" double width 3 and retrieve datatable: var dataadapter = new oledbdataadapter("select a, b, c [numbers.txt]", "provider=microsoft.ace.oledb.12.0;data source=numbers.txt;extended properties="text;hdr=no;"); var datatable = new datatable(); dataadapter.fill(datatable); i datatable following values: b c 21 3.18 5.45 22 4.22 5.23 65 4.98 7.98 65 4.65 4.63 but assigning empty decimalsymbol= in schema.ini doesn't work. woudn't calculations retrieve these fields or iterate file/datatable add decimal separator ea

android - Trying to get the key hash of my released key for facebook -

i'm trying key hash facebook using release key hash saved in facebook still gives me invalid android_key parameter. can't seem figure out why. i entered right command c:\program files (x86)\java\jdk\bin>keytool -exportcert -alias my.keystore - keystore "c:\users\gateway\school work\my stuff\my.keystore" | "c:\users \gateway\downloads\openssl-0.9.8e_x64\bin\openssl.exe" sha1 -binary | "c:\users\ gateway\downloads\openssl-0.9.8e_x64\bin\openssl.exe" base64 enter keystore password: ...... and worked, returned hash still doesn't work. i figured out, alias wrong, gave me wrong hash key.

osx - Open php file in browser using http://localhost with applescript -

i'm trying write applescript textwrangler open active document in chrome. script looks @ moment: tell application "textwrangler" set thefile file of document 1 tell application "finder" open thefile using (path application "google chrome") let's working on file absolute path 'applications/mamp/www/index.php'. script open file in browser 'file:// localhost/applications/mamp/www/index.php', showing php code. instead of need script replace 'file:// localhost/applications/mamp/' 'http:// localhost/' showing actual site. i have tried bunch of stuff found online, have little experience applescript achieve this. how this, following chase's lead , using javascript string replacing. property delim : "mamp" -- break path , prepend localhost tell application "textwrangler" set thefile file of document 1 tell application "finder" set p posix path of thefile -- convert un

java - My program gives an index out of bounds error -

int i=0; while(!a.isempty()) { if(a.tochararray()[i]==' ') { system.out.println(a.tochararray()[i]); } i++; } when run program it's giving me error: index out of bounds. how can solve it? you're not changing a in loop, a.isempty() not change , you'll continue looping until i goes out of bounds. did mean: while (i < a.length()) { and aside, a.tochararray()[i] can (and should) a.charat(i) (as @martijncourteaux points out).

ios - '-[UITextView autocapitalizationType]: unrecognized selector sent to instance? -

i create custom subclasses(subcustomview) of uiview when click on button , added uitextview class on subcustomview subview. when initiate uitextview use initwithframe:textcontainer: method. when used method, project crashed. when use initwithframe: method project not crashed. using following code: textcontainer1 = [[nstextcontainer alloc] initwithsize:cgsizemake(2, cgfloat_max)]; stringtextview = [[uitextview alloc] initwithframe:cgrectmake(0, 0, frame.size.width, frame.size.height) textcontainer:textcontainer1]; //stringtextview = [[uitextview alloc] initwithframe:cgrectmake(0, 0, frame.size.width, frame.size.height)]; stringtextview.keyboardappearance = yes; stringtextview.autoresizingmask = uiviewautoresizingflexibleheight | uiviewautoresizingflexiblewidth; stringtextview.scrollenabled = yes; stringtextview.backgroundcolor = [uicolor redcolor]; stringtextview.autocapitalizationtype = uitextautocapitalizationtypewords;

java - Scanner class skips over whitespace -

i using nested scanner loop extract digit string line (from text file) follows: string str = teststring; scanner scanner = new scanner(str); while (scanner.hasnext()) { string token = scanner.next(); // here each token used } the problem code skip spaces " " , need use "spaces" too. can scanner return spaces or need use else? my text file contain this: 0 011 abc d2d sdwq sda those blank lines contains 1 " " each, , " " need returned. use scanner's hasnextline() , nextline() methods , you'll find solution since allow capture empty or white-space lines.

oracle - PL/SQL calling a function inside a trigger -

i trying create function using oracle pl/sql stores current date variable. function called inside trigger. trigger (among other things) insert variable new table has been created. code complies , runs without errors, doesn't work. nothing happens. trigger on delete trigger, when delete 1 row original table, stays. clues missing? thank you. function: create or replace function get_date (i_stdid archive_student.stdid%type) return date v_date date; begin select current_date v_date dual; return v_date; end; function call inside trigger: create or replace trigger archive_deleted_student after delete on student each row declare v_date archive_student.change_date%type; begin -- other if statements here working v_date := get_date(:old.stdid); insert archive_student (change_date) values (v_date); end; you doing well, check this sqlfiddle . only 1 thing - missed stdid whil

Pattern Recognition in comparison -

i totally new pattern matching or recognition. question that, if have series of strings, say, str1: abcaaaaaaaefg, str2: abcbbbbbbbbcc, str3: sssccccccccefg, etc. want compare strings , find out shared patters in same positions. for example, want compare str1 str2, result of matching there shared pattern: abc beginning. second step compare str1 str3, result there shred pattern: efg end. want make comparison every 2 pairs in set: (str1,str2), (str1,str3), (str2, str3). etc. how can programmatically. question may general, totally new area , need know if there tools or functions out there can me efficiently. edit: 1) normally, strings have same length. it shouldn't difficult write own program this. start @ 0 both strings, compare. if != move next index, else mark match , move next char. keep going till don't match , note matching substring. can skip ahead next index in string because know if had matched 0-n, starting @ 1 still break @ n , of smaller length.

javascript - Modifying server side text file -

currently working on static html website. using following javascript code read server side text file: <!doctype html> <html> <head> <script> function loadxmldoc() { var xmlhttp; if (window.xmlhttprequest) {// code ie7+, firefox, chrome, opera, safari xmlhttp = new xmlhttprequest(); } else {// code ie6, ie5 xmlhttp = new activexobject("microsoft.xmlhttp"); } xmlhttp.onreadystatechange = function () { if (xmlhttp.readystate == 4 && xmlhttp.status == 200) { document.getelementbyid("mydiv").innerhtml = xmlhttp.responsetext; } } xmlhttp.open("get", "results.txt", true); xmlhttp.send(); } </script> </head> <body> <div id="mydiv"><h2>content</h2></div> <button type="button" onclick="loadxmldoc()">

javascript - Drag and Drop over grid and revert back if size is greater than grid -

this canvas element: <canvas id="canvas" width="280px" height="280px" style="background: #fff;"></canvas> and element section want drag elements each grid unit of canvas. <div id="element1" style="width:55px; height:55px; border: 1px solid; background: lightblue"></div> <div id="element2" style="width:111px; height:55px; border: 1px solid; background: lightgreen"> <div id="element1" style="width:55px; height:55px; border-right: 1px solid"></div> and script: <script type="text/javascript" language="javascript"> var bw = 280; var bh = 280; var canvas = document.getelementbyid("canvas"); var context = canvas.getcontext("2d"); context.strokestyle = "black"; function drawgrid() { (var x = 0; x <= bw; x += 56) { context.moveto(x, 0); context.lineto(x, 280);

how to simulate json format and parse in ruby -

i'm trying simulate json response attaching variable. myjson = {'link':{ 'href':'erwerweirwierwe', 'rel':'self' }, 'plan':{ 'shortname':'chrome', 'shortkey':'masterfull', 'type':'chain', 'enabled':true, 'link':{ 'href':'something', 'rel':'self' }, 'key':'masterfull', 'name':'teserere' } when try parse above, error: parsedjson = json.parse(myjson) do need format raw json before reading way? you have use double quotes, not single quotes. you can validate json using this web service . also, in example, you're missing last closing brace. the following json validates: { "link": { "href": "erwerweirwierwe", "rel": "self" }, "plan&qu

php - Mysql execute data. What separator to choose for a string, further to explode to create an array? -

mysql query select companyname, registrationnumber, vatcode 18_6_transactionpartners (companyname = ? or registrationnumber = ? or vatcode = ?) ? replace $data_show_existing_records . $data_show_existing_records in form of string (user input). at first decided create such $data_show_existing_records = $data_show_existing_records. $data_a[$i]. ','. $data_b[$i]. ','. $data_d[$i]. ','; (this created within foreach, because $i may 0, may 100) and convert array in such way $data_show_existing_records = substr($data_show_existing_records, 0, -1); $data_show_existing_records = explode(",", $data_show_existing_records); but example companyname user may input my, company or leave input empty. in such case error sqlstate[hy093]: invalid parameter number: number of bound variables not match number of tokens . because there more $data in array ? . then decided replace , | (because suppose | less used , ). but seems not solution.

PayPal Subscription Cancellation from Merchant Website -

we have paypal payment system integrated our website people can register , choose subscription. subscription part works fine payment goes through , ipn hits our website , updates our systems. want users able cancel subscription within our website have custom cancellation button when clients click, should send request paypal , cancel subscription. managed going on sandbox test system since have brought system live testing can not cancellation feature work. when user clicks on cancel button, think paypal not being notified , hence no ipn received paypal. do know info need in order cancel subscription our website. know there way users can log paypal , cancel subscription or can log our paypal , cancel subscription want work our website. please help! thanks. when have working on sandbox not live, going wrong when try live? i'm little confused that, because initial answer going can't kill subscriptions via api unless you're using recurring payments. standa

javascript - Calling ko.applyBindings on dynamic elements not working -

i have chat room style application , each entry processed on client once received , html generated display it. messages have tooltips , other bits of data embedded within them use knockout bindings display. now after looking on posts around answers problem seem be: make sure elements exist front empty call ko.applybindings on new elements when added the first 1 not feasible create elements chat comes in server, second option seems way it, require calling each chat message comes in. lot of people ko.applybindings can incur significant overheads, think mean if call upon elements rather targeting specific ones. just on same page, here basic snippet of view around area matters: <!-- ko foreach: {data: chatroom.entries, afterrender: chatentryrendered } --> <div class="entry-content" data-bind="html: processedcontent"></div> <!-- /ko --> ignoring bits around that, loop around each entry, add div contain html contain bindings n

jsp - Syntax error occured when retrieveing JSTL variables from JQuery -

i want use jsp variables in jquery. please guide me how figure out.. here code in jsp.. <c:set var="fontclass" value="unicode ieunicode" /> and in js file , retrieve , out put jquery . .. (1). var fontclass = '${fontclass}'; console.log("result values are--- "+fontclass); (2). console.log("result values are--- "+$('fontclass'); but , these 2 things can not satisfied problems. , fond article how use jstl var in jquery . , tried that... jsp :: <c:set var="fontclass" value="unicode ieunicode" /> <script type="text/javascript"> var fontclass = "${fontclass}"; </script> js file:: var fontclass = '${fontclass}'; alert($("#${fontclass}")); but got error: syntax error, unrecognized expression: #${fontclass} what wrong codes or suggestion ? in advance.. you can't jstl <c:set/> value in js fil

c# - Accessing images from isolated storage in XAML using "isostore:/" scheme -

i've downloaded images web , saved them isolated storage , want access images in xaml file, giving uri reference them. i have verified isostorespy stored expect them , can create bitmapimages them if open file , read in byte stream. want optimize image handling passing uri model isolatedstorage location , letting xaml load image. <image height="120" width="120" stretch="uniform" horizontalalignment="left"> <image.source> <bitmapimage urisource="{binding podcastlogouri}" decodepixelheight="120" decodepixelwidth="120" /> </image.source> </image> this podcastlogouri uri value bound bitmapimage.urisource: "isostore:/podcasticons/258393889fa6a0a0db7034c30a8d1c3322df55696137611554288265.jpg" here's how i've constructed it: public uri podcastlogouri { { uri uri = new uri(@"isostore:/" + podcastlogolocation);

ajax - jquery on success to process data returned from the server -

i sending jquery $.ajax(); request server, , want onsuccess function work according params sent server rather params received server because each time site supposed behave depending on sent, rather received how attach "sent" parameters, without making them global onsuccess function ? this function : $.ajax({ url : this.soaptarget, type : "post", datatype : "xml", data : this.soapmsg, processdata : false, beforesend : function(xhr) { xhr.setrequestheader("soaptarget",this.soaptarget); xhr.setrequestheader("soapaction",this.soapaction); }, contenttype : "text/xml; charset=\"utf-8\"", success : onsuccess, error : onerror }); when function parameter in more global function , why has "this.soapmsg" , this.soaptarget , this.soapaction parameters

Zend and Wordpress not playing nice -

ok got odd install have work with, , causing me grief. firstly though, can't change how installed. believe me to. i have zend 1 install. has wordpress installed inside it. whole site zend except /public/blog wordpress. problem when go /blog frontpage loads expected. second try go /blog/post-1 zend grabs url , tells me there no blog controller. there isn't, zend supposed leaving alone. the frustrating thing had working on local install, remote install won't play ball. anyone got ideas?

javascript - How to understand this jquery function -

this question has answer here: a simple question on jquery closure 6 answers what (function($) {})(jquery); mean? 4 answers what mean?: (function($){ })(jquery); and reason use it? thanks. you creating new scope in javascript using function (as {} not create new scope). calling function , capturing jquery outer scope , make available inside variable $

android - Encountering an Error when trying to install application using ADB -

i trying install application using adb. getting error file path. checked many times , path correct. other functions able using adb restarting, checking versions etc. not able install. can me that? make sure have not set path c:\...\...\tools\ and change c:\...\...\platform-tools

feature detection - Active frame extraction from motion capture -

i new area - have background in gait , posture. i have series of motion files of timestamped coordinates (containing x, y, , z in mm) number of joints (30). what simplest way extract following motion observations. 1) number of active features (i.e. active joints). 2) average speed of motion. same file format of nxp. p number of joints , n number of frame observations. what looking pointers possible areas explore. regards, dan a couple of possibilities might explore - both using free , (and open source), software : python + numpy / scipy can read in coordinate values , calculate data require - possible plot in 3d using matplotlib . you use positional data animate stick figure in blender - of test blends provide starting point this .

c++ - unformatted i/o to and from memory -

i'm looking way write unformatted data memory using c++ standard library. i'd class inherits istream/ostream , works ifstream/ofstream, backed memory instead of file on disk. this way can work istreams , ostreams , use operator<< , operator>> read/write binary data, , don't need know whether data streaming memory or onto disk. i thought perhaps istringstream/ostringstream configured write unformatted output via operator<< , operator>>, couldn't see simple way this. so wasn't able find in c++ standard library or in boost, seems sort of thing should there. advice appreciated! you can't use << , >> operators write/read unformatted data (they dealing textual input , output), can use write method of output streams , read method of input streams. and std::string don't care data holds should able use stringstream (and output/input variants).

How to solve different Preview/Picture sizes returned by android.hardware.camera? -

so i've been playing android camera library , using in surfaceview. have found there's no way capture pictures match preview. in fact, 1 has check preview , picture sizes , set camera parameters best match possible. also, can't set camera have same sizes both since app crash if camera doesn't support them. how can be? there no other solution? mean instagram seems use (it doesn't launch phone's camera app) , there seems perfect match. any ideas? thanks! simplest, , largely practical, approach treat preview mere feedback mechanism , concentrate program logic on getting best - , desired - quality of image capture. there little novelty in mixing 2 together. also, desired image capture quality may depend on different factors/options. based on post capture processing times, storage constraints, upload constraints, , more; best quality image may not desired one. implementation wise, camera apps follow common practices below: use camera.getpara

c++ - Low Level keyboard hook never catches WM_KEYDOWN -

i'm trying create macro application start running operations when key pressed (system wide shortcut). did created windows form application visual studio 2012. when form loaded keyboard hook installed: hookhandle = setwindowshookex( wh_keyboard_ll, (hookproc)keyboardhookhandler, getmodulehandle(null), null); if( hookhandle == 0){ messagebox::show("error setting hook!"); } my hook callback function is: public: static lresult callback keyboardhookhandler( int code, wparam wparam, lparam lparam ) { if(code>=0 && wparam == wm_keydown){ messagebox::show("key down"); } return callnexthookex( hookhandle, code, wparam, lparam); } when compile application , run message box never shown. more know call function fired wparam contains value 45 (i did checked , none of wm constants should returned has value 45). after few key events application crashes. what reason why code doesn't work should to? update: did removed cas

shell - change background color in zsh (ubuntu 12.04) -

i installed zsh package. so, when type zsh in terminal switches bash zsh. also, downloaded oh-my-zsh framework customize zsh. when change theme name in .zshrc file 1 of themes given here , changes color/type of prompt among other things background color stays same. want background color change ones given on theme wiki page. so, how do change background color automatically ones on page whenever change theme? changing background color should dependent on terminal emulator. this answers questions using setterm: change background color in gnome terminal through command? another link xterm: xterm: how change background color?

ios - Turn off part of the iPhone Screen -

i'm trying work on ios app turns off screen (so when in dark, doesn't show light @ all), can turn on , off pixels of screen. does know way this? assuming it's either or nothing... either turn off screen, or turn on, maybe knows better? i guessing best turn background black little light possible comes through. however, tried using ipad , still generates light in pitch black room. want instance, 1 pixel shine brightly, , rest not glow @ all. , if not possible, there way mimic this? as far i'm aware screen either on or off, there's no controller setting specific regions on/off. also can't change pixel level brightness, screen isn't illuminated way. can control overall screen brightness, not each pixel, screen lighting technology doesn't work way, it's led backlight.

C# performance curiosity -

really curious below program (yes run in release mode without debugger attached), first loop assigns new object each element of array, , takes second run. so wondering part taking time--object creation or assignment. created second loop test time required create objects, , third loop test assignment time, , both run in few milliseconds. what's going on? static class program { const int count = 10000000; static void main() { var objects = new object[count]; var sw = new stopwatch(); sw.restart(); (var = 0; < count; i++) { objects[i] = new object(); } sw.stop(); console.writeline(sw.elapsedmilliseconds); // ~800 ms sw.restart(); object o = null; (var = 0; < count; i++) { o = new object(); } sw.stop(); console.writeline(sw.elapsedmilliseconds); // ~ 40 ms sw.restart(); (var = 0; < count; i++)

java - Each thread on separate processor - is it possible? -

this question has answer here: java thread affinity 5 answers let's have server 4 processors. want implement cache served 4 threads. requirement - each thread should act on it's own processor? how can achieve this? you need set thread affinity each thread specify cpu want run on. there's examples on web on how it, there's nice github repository here sample code on how done. esentially, set each threads affinity different core.

jquery - Disable/enable touch events on flexslider -

im using flexslider slide content: http://iea.uili.com.br/v4/ thing whant disable touch when zoom in , enable when zoom out, same keyboard control! here function when click on building zoom in function janelas(){ $('.popup').click(function() { var $id = $(this).attr('class').split(' ')[2]; $('.menu_janela').fadeout('fast'); $("ul.flex-direction-nav").addclass('hide'); settimeout(function(){ console.log('.'+$id+'-popup') $('.'+$id+'-popup').fadein('fast'); },600); }); } here function when zoom out function fecha(){ $('.fechaa').click(function() { $("ul.flex-direction-nav").removeclass('hide'); $('.menu_janela').fadeout(); $('.view1').click(); }); $('.fechab').click(function() { $("ul.flex-d

android - Save RSA PublicKey / PrivateKey safely -

i create , use rsa public/private key encrypt/decrypt message.i store them sharedpreferences string , when need them create string. works perfectly, secure store private key in sharedpreferences string. question : sharedpreferences mode_private security i learned that, can reach sharedpreferences , can generate private key string. can make private key secure while save on phone? it depends on the level of sensitivity of private/public key pair. think, storing them in sharedpreferences not bad idea. key pair stored relative app directory , has system protection external access. but, word "shared"preferences implied, key pair shared among app components. so, if need better protection, consider storing key pair in keystore class instead . of now, best solution key pair protection. provides password based key protection. update: there great article on android keystore , keychain usage here .