Posts

Showing posts from February, 2013

Quotes within php quote -

i put quotes around "name" within php header sending email. gives me php error when doing so. $headers = "from: "name" " . "\r\n"; how can work quotes around name? i tried 'name' doesnt work when email shows server. you have escape quotes backslash: $headers = "from: \"name\" " . "\r\n"; for more information on possible escapes refer php manual on strings . another solution using single quoted strings, don't have variables or other escapes in there: $headers = 'from: "name" ' . "\r\n"

types - Fibonacci Sequence in C generating negatives? -

i'm new programming , need in c. writing program generate fibonacci sequence values 1000 digits. here code: #include <stdio.h> int main(void) { int seq[1000]; int i,n; printf("how many fibonacci numbers want?: "); scanf("%d",&n); seq[0] = 0; seq[1] = 1; for(i = 2; < n; i++) seq[i] = seq[i-1] + seq[i-2]; (i = 1; < n; i++) printf("%d: %d\n", i, seq[i]); return 0; } now problem is, numbers correct until 47th number. goes crazy , there's negative numbers , wrong. can see error in code? appreciated. i writing program generate fibonacci sequence values 1000 digits. not yet aren't. storing values in variables of type int . commonly such variables 32 bit values , have maximum possible value of 2^31 - 1 . equals 2,147,483,647 way short of goal of reaching 1,000 digits. the 47 th fibonacci number first number exceed 2,147,483,647 . according wolfram al

django - Store JSON input -

i'm new django , trying content security policy reporting running on application , running issues parsing , storing json violation output. have reports posting /csp_reports/ , have built new app called security_report , added following urls.py: url(r'^csp_report/$', 'security_report.views.secreport'), my models this: import os from django.db import models django.contrib.auth.models import user django.conf import settings class security_report(models.model): id=models.autofield(primary_key=true) received=models.datetimefield(null=true) csp_report=models.charfield() blocked_uri=models.charfield() column_number=models.charfield() document_uri=models.charfield() line_number = models.integerfield() original_policy= models.charfield() referrer = models.charfield() status_code = models.integerfield() violated_directive = models.charfield() source_file = models.charfield() script_sample = models.charfield()

java - Getting exception error when setting custom font in fragments android -

here code, simple menu driven app, trying use custom font inside fragment , causing problem. have used font in activity, menu activity launches activity inside fragment inflated. not sure if causing problem me out please. package com.cbs.coronathecarnival; import android.app.fragment; import android.graphics.typeface; import android.os.bundle; import android.view.view; import android.view.layoutinflater; import android.view.viewgroup; import android.widget.textview; /** * created aditya on 2/4/14. */ public class aboutfragment extends fragment{ view rootview; public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate){ view rootview = inflater.inflate(r.layout.fragment_about, container, false); initfonts(); return rootview; } public void initfonts(){ textview tv_title = (textview) rootview.findviewbyid(r.id.tv

jquery - Mobile site - on native android browser doesn't resize right (and can't always get keyboard focus), does on Chrome -

the layout our new mobile site, when viewed on android phones, works fine in chrome not in native android browser or dolphin. (note: not coder, i'm troubleshooter, don't know why choices made) problem 1: layout isn't @ proper zoom. page displays wider window. can zoom out proper zoom, it's not being automatic should be. problem 2: clicking doesn't lead focus i'm supposed able click on icon on landing page taken login page. can, happens after i've been frustratedly tapping @ same point while. , then, if manage login page, tapping on input fields doesn't bring keyboard. (it highlight box in blue, indicating part of action has been recognized). in other words, can't log in (and can't other symptoms elsewhere in site). needless say, rather large blocker, both usability , testing. i've been doing lot of research, , trying variety of things (like setting initial-scale and/or maximum-scale 1), no luck yet. i'm 2 steps

php - How to render a pyramide with each row by level property? -

array ( array( ['name'] => 'test1', ['level'] => 1 }, array( ['name'] => 'test2', ['level'] => 2 }, array( ['name'] => 'test3', ['level'] => 2 }, array( ['name'] => 'test4', ['level'] => 3 }, array( ['name'] => 'test5', ['level'] => 3 }, array( ['name'] => 'test6', ['level'] => 3 }, array( ['name'] => 'test7', ['level'] => 3 }, ) i have array of arrays sorted level, want make this: ________ | | | test1 | |________| ________ ________ | | | | | test2 | | test3 | |________| |_____

java - Do I need to check for valid sessions in every controller in Spring? -

suppose in web applicaiton spring mvc need check valid sessions in every controller or in jsps too? how can solve session management thing in mvc? do? other things can add security application? we check if session expired in filter layer , map dispatcherservlet , way, incoming request handled spring filtered first, , not allowing interaction spring controller if session expired. if session found expired, send redirect page user informed session expired. sample filter code public class myfilter implements filter{ ... public void dofilter(servletrequest request, servletresponse response, filterchain chain) throws ioexception, servletexception { if (issessionexpired((httpservletrequest) therequest)) { response.sendredirect(((httpservletrequest) therequest).getcontextpath() + "/expired.jsp"); response.flushbuffer(); }else{ //..its not yet expired, continue thechain.dofilter(thereq

web services - REST and SOAP Webservices -

this question has answer here: representational state transfer (rest) , simple object access protocol (soap) 14 answers if given rest or soap webservices url, how can find method offers. for ex: http://ipaddress:port/projectname/services just tack ?wsdl onto end of url. if returns xml based wsdl document, soap based service.

jquery - javascript math calculation case -

update: can see 2 votes closing problem because not clear need. here need: need once value on 1,100,000 price calculated accordingly, example points between 1,100,001 , 1,200,000 price $220, points between 1,200,001 , 1,300,000 $240, etc, without limit, example 4,500,001 , 4,600,000 price $720. i need javascript caluclation goes this: 1-500,000 points $30/100,000 points 500,001-999,999 points $25/100,000 points 1,000,000+ points $20/100,000 points i have case switch check value , correct sum want know how can example if user enter 4,500,000 points or random value more 1,100,000. have currently: if (number(amountofpoints) > number(0)) { switch (true) { case (amountofpoints > 0 && amountofpoints <= 100000): { price = 30; break; } case (amountofpoints > 100000 && amountofpoints <= 200000): { price = 60; break;

javascript - jQuery Plugin 101 -

i new this, after searching tutorials etc. don't understand why (and every single other jscript plugin have pasted in code*) isn't working. *both within html , in separate js file... <html> <head> <link rel="stylesheet" type="test/css" href="stylesheet.css"/> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> </head> <body> <div class="imgcontent"><div id="map"><script type="text/javascript"> $('#map').mobilymap({ position: 'center', // map position after loading - 'x y', 'center', 'top left', 'top right', 'bottom left', 'bottom right' popupclass: 'bubble', markerclass: 'point', popup: true, // show popup on marker click - true/false cookies: true, // remember last map pos

arm - How to get perf_event results for 2nd Nexus7 with Krait CPU -

all. i try pmus information such instructions, cycle, cache miss , etc. on 2nd nexus7 krait cpu. the perf tool not working correctly. therefore, using follow sample source code in perf_event tutorials. #include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <string.h> #include <sys/ioctl.h> #include <linux/perf_event.h> #include <asm/unistd.h> static long perf_event_open(struct perf_event_attr *hw_event, pid_t pid, int cpu, int group_fd, unsigned long flags) { int ret; ret = syscall(__nr_perf_event_open, hw_event, pid, cpu, group_fd, flags); return ret; } int main(int argc, char **argv) { struct perf_event_attr pe; long long count; int fd; memset(&pe, 0, sizeof(struct perf_event_attr)); pe.type = perf_type_hardware; pe.size = sizeof(struct perf_event_attr); pe.config = perf_count_hw_cpu_cycles; pe.disabled = 1; pe.exclude_kernel = 1; pe.exclud

arrays - Java: Local variable scope -

i error saying compiler cannot find variable "complexarray" don't know why. how fix program returns array of complex numbers read file? public static complex[] parsefromfile(string filename) { int numofcomplex = 0; try { scanner sc = new scanner(new file(filename)); string firstline = sc.nextline(); firstline = firstline.trim(); numofcomplex = integer.parseint(firstline); complex[] complexarray = new complex[numofcomplex]; (int = 0; < numofcomplex; i++) { string nextline = sc.nextline(); nextline = nextline.trim(); complexarray[i] = parsecomplex(nextline); } } catch(exception e) { } return complexarray; } your complexarray variable declared inside try{} scope. declare before try statement. complex[] complexarray = null;

node.js - SOLVED::: Https access by ip working but not by url -

i have server setup in node, seems fine in local in server not working well. server.listen server.secure_port, server.host, ()-> console.log("secure listening " + server.host + ":" + server.secure_port ) server.listen server.port, server.host, ()-> console.log("insecure listening " + server.host + ":" + server.port ) basically listening in port 80 works perfect , behaves expected, secure port works ip , not domain. i thought problem dns not sending requests or that, , in fact was, if you're using cloudflare must note ssl not supported in free plans. can either disable dns management domains or move paid plan. took me 5 hours until hit it. :( emphasized text

python - How to output parsed HTML into a file? -

(updated) after help, have following code. can output csv file can't seem csv have proper number of columns: soup = beautifulsoup(html_doc) import csv outfile=csv.writer(open('outputrows.csv','wb'),delimiter='\t') #def get_movie_info(imdb): tbl = soup.find('table') rows = tbl.findall('tr') list=[] row in rows: cols = row.find_all('td') col in cols: if col.has_attr('class') , col['class'][0] == 'title': spans = col.find_all('span') span in spans: if span.has_attr('class') , span['class'][0] == 'wlb_wrapper': id = span.get('data-tconst') list.append(id) elif col.has_attr('class') , col['class'][0] == 'number': rank = col.text list.append(rank) elif col.has_attr('class') , col['class'

list - Python - Random output has a structure -

Image
i writing small script tic tac toe game in python. store tic tac toe grid in list (example of empty grid): [[' ', ' ', ' ',], [' ', ' ', ' ',], [' ', ' ', ' ',]] . these following possible string list: ' ' no player has marked field 'x' player x 'o' player o i have written function creates empty grid ( create_grid ), function creates random grid ( create_random_grid ) (this used testing purposes later) , function prints grid in such manner read-able end user ( show_grid ). having trouble create_random_grid function, other 2 method work though. here how approached create_random_grid function: first create empty grid using create_grid iterate on grid line iterate on character in line change character item randomly selected form here. ['x', 'o', ' '] return grid note: not expect exact output expected output . actual output , not lines same.

swing - JavaFx import au Jpanel into Pane -

i started learn java , don't understand how convert jpanel pane. i use netbeans 1.4 , javafx scene builder 1.1. java scene builder generate pane , not jpanel. i tried use swing node don't understand @ all. thank in advance help. if want add swing component, yes, must code without using scene builder. you should take here it's api documentation swingnode , has nice example use.

java - Distinguish between Two USB Connected Keyboards using [Caps-Lock] -

i trying differentiate input between 2 keyboards connected computer. java program needs able distinguish between two. original solution have 1 keyboard caps-lock enabled while other not. this worked when testing on mac osx. when attempted run same program on ubuntu, notice turning caps-lock on enables connected keyboards. i can no longer distinguish between two. suggestions? from os perspective there "one keyboard". 1 keyboard receiving events number of actual keyboards. distinguish keyboards bypassing regular keyboard input , go directly registered usb devices. found this.... http://nanlee.wordpress.com/2013/06/12/manykeyboard-using-java-hid-api-to-handle-multiple-keyboard-input/

ios7 - Pausing a sprite kit scene -

@property (sk_nonatomic_iosonly, getter = ispaused) bool paused; i found line of code add project, how pause whole game? for example: -(void)touchesbegan:(nsset *)touches withevent:(uievent *)event{ (uitouch *touch in touches) { skspritenode *pause = (skspritenode*)[self childnodewithname:@"pause"]; cgpoint location = [touch locationinnode:self]; // nslog(@"** touch location ** \nx: %f / y: %f", location.x, location.y); if([pause containspoint:location]) { nslog(@"pause game here somehow"); } } } as can see, have button set up. when select it, how pause whole scene? , resume when hits resume button. ok got advice call self.scene.view.paused = yes; except here problem, in app delegate - (void)applicationwillresignactive:(uiapplication *)application{ skview *view = (skview *)self.window.rootviewcontroller.view; view.paused = yes;} and - (void)applicationdidbecomeactive:(uiapplication *)applicatio

Visual Studio - Watch Window - Weird values -

Image
a few of developers have watch windows following: what settings can change turn normal? if normal people, mean turn default c# settings? i'm not sure why looking way hard debug.

windows - Imagemagick -subimage-search command hanging -

compare.exe -metric rmse -subimage-search screenshot.png locator.png null this command hangs , runs cpu @ 13% until press ctrl + c other compare commands working fine! the option ' -subimage-search ' searches second image @ every possible location in first image. slow! very slow.. when have large images can take lot of minutes complete. option '-debug all' can see happening make process slower.

android - Searching ArrayList with user input -

right now, getting list of questions website , putting inside arraylist<string> . now, how take users input, converted string (ssearchvalue), , check arraylist see if matches? , if finds question contains users search, displays it? package com.malthorn.anyquestion; import java.io.ioexception; import java.util.arraylist; import java.util.list; import android.os.bundle; import android.app.activity; import android.view.menu; import android.view.view; import android.widget.edittext; import org.jsoup.jsoup; import org.jsoup.nodes.document; import org.jsoup.nodes.element; import org.jsoup.select.elements; import com.malthorn.gasculator.r; public class mainactivity extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); document doc; arraylist<string> urls = new arraylist<string>(); edittext isearchvalue = (edit

regex - Javascript regexp expression that matches two digits in a string with optional decimal places -

how modify following javascript regexp matches of proceeding patterns? /(\d\d).+?(\d\d)/ 2 of 5 2.5 of 5.6 2.3 of 10 100.4 of 1000 1000.4 of 10000.3 try this: /(\d+(?:\.\d+)?).+?(\d+(?:\.\d+)?)/ this match 1 or more decimals followed optional decimal point , 1 or more decimals, captured in group 1, followed 1 or more of character, non-greedily, followed 1 or more decimals followed optional decimal point , 1 or more decimals, captured in group 2. demonstration also, if want prevent other characters before or after matched string, may need add start ( ^ ) , end ( $ ) anchor: /^(\d+(?:\.\d+)?).+?(\d+(?:\.\d+)?)$/

ios - Adding action to MKMapView annotation -

i have mkmapview bunch of annotations can't add action them. creating mkpointannotation, couldn't add action that. whenever click annotation, nothing happens. here how setting annotations - cllocationcoordinate2d montevista; montevista.latitude = (double) 37.83029; montevista.longitude = (double) -121.98827; mkpointannotation *montevistapoint = [[mkpointannotation alloc] init]; montevistapoint.coordinate = montevista; montevistapoint.title = @"monte vista"; cllocationcoordinate2d sanramonvalley; sanramonvalley.latitude = (double) 37.82609; sanramonvalley.longitude = (double) -122.00603; mkpointannotation *sanramonvalleypoint = [[mkpointannotation alloc] init]; sanramonvalleypoint.coordinate = sanramonvalley; sanramonvalleypoint.title = @"san ramon valley"; cllocationcoordinate2d doughertyvalley; doughertyvalley.latitude = (double) 37.76845; doughertyvalley.longitude = (double) -121.90342; mkpointannotation *doughertyvalleypoint = [[mkpointannotati

c# - String Format Numbers Thousands 123K, Millions 123M, Billions 123B -

is there way using string formatter format thousands, millions, billions 123k, 123m, 123b without having change code divide value thousand, million or billion? string.format("{0:????}", largenumber) there different ways achieve this, me easiest , quickest use the "," custom specifier double value = 1234567890; // displays 1,234,567,890 console.writeline(value.tostring("#,#", cultureinfo.invariantculture)); // displays 1,234,568k console.writeline(value.tostring("#,##0,k", cultureinfo.invariantculture)); // displays 1,235m console.writeline(value.tostring("#,##0,,m", cultureinfo.invariantculture)); // displays 1b console.writeline(value.tostring("#,##0,,,b", cultureinfo.invariantculture));

Get C# Property Values for multiple objects -

i have couple of domain objects like: public class person() { public int age { get; set; } public string city{ get; set; } } public class company() { public string name{ get; set; } public string address{ get; set; } } i have class calls mymethod mentioned below. public class calltest() { person p= new person{age=10,city="dd"}; company c= new company{name="mynae",address="myaddress"}; mymethod(p); mymethod(c); } mi.name gives me property name. how property value? public class mymethod(object obj) { type t = obj.gettype(); propertyinfo prop = t.getproperty("items"); foreach (memberinfo mi in t.getmembers()) { if (mi.membertype == membertypes.property) { var x = mi.name; } } } you need cast memberinfo propertyinfo it's value : ..... if (mi.membertype == membertypes.propert

python - Feed string to the first Popen when several Popen are chained -

there answer how feed string popen using popen.communicate(intput=''). however, have problem of chaining several popen this: p1 = popen(['fstcompile', '--isymbols=ascii.syms', '--osymbols=ascii.syms'], stdin=pipe, stdout=pipe) p2 = popen(['fstprint', '--isymbols=ascii.syms', '--osymbols=ascii.syms'], stdin=p1.stdout, stdout=pipe) p1.stdout.close() i feed string stdin p1 , execute whole sequence. i tried following: p1.stdin.write('xxxx') p1.stdin.flush() print p2.communicate()[0] and didn't work. putting string p2.communicate()[0] makes no sense , didn't work anyway. so what's right thing in such case? thank in advance.

python - How's this for collision detection? -

i have write collide method inside rectangle class takes rectangle object parameter , returns true if collides rectangle performing method , false if doesn't. solution use for loop iterates through every value of x , y in 1 rectangle see if falls within other, suspect there might more efficient or elegant ways it. method (i think names pretty self explanatory, ask if isn't clear): def collide(self,target): result = false x in range(self.x,self.x+self.width): if x in range(target.get_x(),target.get_x()+target.get_width()): result = true y in range(self.y,self.y+self.height): if y in range(target.get_y(),target.get_y()+target.get_height()): result = true return result thanks in advance! the problem of collision detection well-known one, thought rather speculate might search working algorithm using well-known search engine. turns out literature on rectangle overlap less easy come might think. before mov

javascript - addEventListener load on ajax load WITHOUT jquery -

i have 4 html files , 4 javascript files. each javascript file loaded externally each html file index.html loads javascript.js 1.html loads javascript1.js 2.html loads javascript2.js 3.html loads javascript3.js the issue i'm having index.html uses ajax load 1 of 3 other pages when specific button pressed. supposed happen particular page load own corresponding javascript program @ end of program contains window.addeventlistener should run on "load" , run function "registerlisteners". registerlisteners registers event listener on button on page currentyl displays alert testing. what have figured out parameter "load" window.addeventlisener doesnt seem valid when page loaded dynamically ajax. i cant put of code in main javascript because contains getelementbyid calls call elements 1 of numbered pages that, if executed on main page load generate errors because specific id's dont exist yet. this homework , need pointed in right direction do

ios - UITextView top margin -

Image
i'm using textview , noticed ios 7 leaves top margin default. see image in following i read different posts in common solution use: [textviewtest setcontentinset:uiedgeinsetsmake(<#cgfloat top#>, <#cgfloat left#>, <#cgfloat bottom#>, <#cgfloat right#>)]; but insets custom solution particular device, textview, font size, , on. therefore, there no specific insets applicable solution... worst, have programmatically define different insets account ios devices , orientations. good news found whenever textview becomes first responder , keyboard shown on screen, top margin disappears after keyboard has gone. way, i'm resizing contentinset on uikeyboarddidshownotification , uikeyboardwillhidenotification. see image when keyboard did show: see image when keyboard has gone: is there way simulate keyboard show , hide? content inset disappears explain above. i have tried making textview become first responder , resign it, approach user ha

ios - How to make UITableview exact height and removing unwanted white space footer? -

Image
i have following issue having 1 button on main view if click on button add subview on main view tableview here code viewcontroller *settings = [[viewcontroller alloc]initwithnibname:@"viewcontroller" bundle:nil]; settings.delegate=self; [settings.view setframe:cgrectmake(0, 30, self.view.frame.size.width,250)]; [self.view addsubview:settings.view]; after click on button subview tableview rest of them having whitespace. then how remove remaining whitespace. at first sight, looks have set wrong height of viewcontroller's view i.e., 250 . make sure tableview inside view have same height assigning in setframe function here: viewcontroller *settings = [[viewcontroller alloc]initwithnibname:@"viewcontroller" bundle:nil]; settings.delegate=self; [settings.view setframe:cgrectmake(0, 30, self.view.frame.size.width, heightofyourtableview)]; [self.view addsubview:settings.view]; hope helps!

How to get a dictionary within a dictionary in python -

i have data in text file in format given below:- monday maths 100 95 65 32 23 45 77 54 78 88 45 67 89 tuesday science 45 53 76 78 54 78 34 99 55 100 45 56 78 wednesday english 43 45 56 76 98 34 65 34 45 67 76 34 98 i want write python code produce output this:- { 'monday': {'maths': [100 95 65 32 23 45 77 54 78 88 45 67 89}, 'tuesday': {'science':45 53 76 78 54 78 34 99 55 100 45 56 78}, 'wednesday': {'english': 43 45 56 76 98 34 65 34 45 67 76 34 98} } here snippet: fo = open('c:\\users\\aman\\documents\\dataval.txt','r') data = fo.readlines() mydict = {} li = [] in range(len(data)): row = data[i].split('\t') timekey = row[0] type = row[1] if mydict.has_key(timekey): li = mydict[timekey] li.append(type) mydict[timekey] = li else: li = [] li.append(type)

performance - Most efficient pointer arithmetic type in c -

i assume internal casting happens when write: arr[i] (which equivalent *(arr+i) ). because i can example short , int or long or unsigned variant of of these three. so question simple: type should i no internal conversion takes place? code can run efficiently? crude guess: size_t ? it's unlikely make significant difference performance. in case, should using type that's semantically correct, not trying make premature optimizations things aren't going matter. in case of indices, size_t smallest type that's a priori correct, may able away smaller types if know array you're working bounded. though should use size_t safe.

mysql - java.sql.sqlexception column not found -

Image
i trying find max no tr_id (primary key) in transaction table. here table , it's layout. here cord. try { resultset rs = db.getdata("select max(tr_id) transaction"); resultsetmetadata meta = rs.getmetadata(); (int index = 1; index <= meta.getcolumncount(); index++) { system.out.println("column " + index + " named " + meta.getcolumnname(index)); } if (rs.first()) { int tr_id = rs.getint("tr_id"); } i'm using jdbc connection. when i'm running cord i'm getting error. column 1 named max(tr_id) java.sql.sqlexception: column 'tr_id' not found. @ com.mysql.jdbc.sqlerror.createsqlexception(sqlerror.java:910) @ com.mysql.jdbc.resultset.findcolumn(resultset.java:955) @ com.mysql.jdbc.resultset.getint(resultset.java:2570) @ controle

page views and page like count by date wise for the particular page php mysql -

i want store views , counts particular page . im using page url unique key (index.php), in table have following columns common table id | page name | views | likes | timestamp 1 | index.php | 5 | 3 | 6-2-2014 2 | abount.php | 15 | 77 | 6-2-2014 for views table id | page name | date | ip 1 | index.php | 6-2-2014 | 127.0.0.1 2 | index.php | 6-2-2014 | 127.0.0.2 3 | index.php | 6-2-2014 | 127.0.0.3 4 | index.php | 6-2-2014 | 127.0.0.4 5 | index.php | 6-2-2014 | 127.0.0.5 for table id | page name | date | ip 1 | index.php | 6-2-2014 | 127.0.0.1 2 | index.php | 6-2-2014 | 127.0.0.2 3 | index.php | 6-2-2014 | 127.0.0.3 what im did here means , every time insert new record in count table increase count particular page in common table , 1) here allowed 1 time particular page 1 ip. 2) need know

java - Label refresh function does not work -

i'm trying setup function takes input user , prints onto label , updates per entry. updating occur through removing old label , adding label updated value. text center-aligned. while i'm able label print current value of "entry", without removing label old value. wondering how able correct issue? import acm.graphics.*; import acm.program.*; public class testcanvas extends consoleprogram { public void run() { gcanvas canvas = new gcanvas(); add(canvas); string entry =""; while(true) { entry += readline("give me word: "); if(entry=="") break; glabel label = new glabel(entry); label.setlocation(200-label.getwidth()/2, 60+label.getheight()); label.setfont("times new roman-24"); // remove old label , update // label current value "entry" canvas.re

excel - Automatically create and name an Object from a set list -

i'm trying auto name objects referenced list rather have object text stated in script. how script reference separate worksheet called process steps text value in cell c7 instead of entering statement in script step 1 activesheet.shapes.addshape(msoshaperectangle, 50, 50, 100, 50).select selection.formula = "" selection.shaperange.shapestyle = msoshapestylepreset40 selection.shaperange(1).textframe2.textrange.characters.text = "step1" peter has mentioned how pick value cell. taking bit ahead. please avoid use of .select/.activate interesting read is trying? sub sample() dim shp shape set shp = activesheet.shapes.addshape(msoshaperectangle, 50, 50, 100, 50) shp.oleformat.object .formula = "" .shaperange.shapestyle = msoshapestylepreset40 .shaperange(1).textframe2.textrange.characters.text = _ thisworkbook.sheets("process steps").range("c7").value end end sub

android - JSON parsing and AsyncTask error -

i trying register , login function there problem json , asynctask. here logcat error. 02-06 04:18:08.857: e/json(1160): <!doctype html public "-//w3c//dtd html 4.01//en""http://www.w3.org/tr/html4/strict.dtd">n<html><head><title>not found</title>n<meta http-equiv="content-type" content="text/html; charset=us-ascii"></head>n<body><h2>not found</h2>n<hr><p>http error 404. requested resource not found.</p>n</body></html>n 02-06 04:18:08.857: e/json parser(1160): error parsing data org.json.jsonexception: value <!doctype of type java.lang.string cannot converted jsonobject 02-06 04:18:08.887: w/dalvikvm(1160): threadid=11: thread exiting uncaught exception (group=0x41465700) 02-06 04:18:08.937: e/androidruntime(1160): fatal exception: asynctask #1 02-06 04:18:08.937: e/androidruntime(1160): java.lang.runtimeexception: error occured while executing doin

c# - Image won't replace while the program is running -

i'm trying make screen sharing program, program flows this: capture screen slice 9 compare new slice old slice replace different slice upload web (with new slice) but i've got problems replacing slices (in replace function). source have searched need convert bitmap image (the slice) string, can replace. there's no example converting bitmap double array strings. is there possibility replace image without convert strings? why need replace bitmap data using string intermediate? can use bitmap manipulation functions fine. also, i'm having trouble understanding algorithm. bitmap of whole screen. cut 9 parts (are corners, edges , center?), compare each of slices old versions 1 one, replace ones changed, , upload whole bitmap? don't want upload each of slices separately, uploading ones changed? otherwise doesn't make sense slicing @ all, or it? now, it's true converting data string lets use string comparison functions , other stuff that,

vb.net - Error "Unable To Find Table Mapping Or Data Table" when trying to update MSSQL table via datagridview -

hi using datagridview display data sql server, want when edited cell in datagridview database table updated too. code populating datagridview this: dim datest sqldataadapter = new sqldataadapter("select * tblpaymtc", strcon) dim cbtest sqlcommandbuilder = new sqlcommandbuilder(datest) dim dstest dataset = new dataset datest.fill(dstest) dg1.datasource = dstest.tables(0) when button clicked use code: datest.update(dstest) any appreciated. add line too... dg1.datamember = "tblpaymtc"

php - Show chat window when new message received -

i trying build chat system. problem when 1 user types message chat window won't display instantly message receiver. after receiver refreshes window works fine. here current code: profile.php setinterval(function(){ var username="<?php echo $username; ?>"; $.ajax({ url:"s/shower.php", type:"post", data:"shower=" + username, success:function(data){ if (data == 1){ $(".pchat").show(); } } }); },500); $(".chat_wind").click(function(){ var id=$(this).attr("id"); var newid=id.split("chat_wind"); var datid=newid[1]; $(".pchat").show(); }); $(".chatform").submit(function(){ var parent=$(this).attr("id"); var split=parent.split("chatform"); var newid=split[1]; var val=$("#chati").val(); if (val.length == 0

Spring Batch -@BeforeStep not getting invoked in Partitioner -

we trying implement batch job using spring batch partitioning.in in "step 2" partitioned step need data step 1 processing.i used stepexecutioncontext promoted job execution context @ step1 store data. i tried use @beforestep annotation in partitioner class stepexecutioncontext can extract data stored , put in executioncontext of partitioner .but method @beforestep annotation not getting invoked in partitioner. is there other way achieve this. partitioner implementation public class ntfnpartitioner implements partitioner { private int index = 0; string prev_job_time = null; string curr_job_time = null; private stepexecution stepexecution ; executioncontext executioncontext ; @override public map<string, executioncontext> partition(int gridsize) { system.out.println("entered partitioner"); list<integer> referencids = new arraylist<integer>(); (int = 0; < gridsize;i

java - Order ResultList of @ManyToMany connection -

i have @manytomany connection temporary table. table1 has 0..* table2 , table2 0..* table1. when ask elements of table1 , serialize it. array of table1 containing array of table2. array of table1 sorted primary key. array table2 in table 1 randomly sorted. how can sort array of table2 in table1 primary key? code: table1 @table(name = "person") @entity public class persondetail1 extends person implements serializable { private static final long serialversionuid = 1l; @manytomany(fetch = fetchtype.eager) @jointable(name = "person_item", joincolumns = {@joincolumn(name = "pers_fk", referencedcolumnname = "pers_pk")}, inversejoincolumns = {@joincolumn(name = "item_fk", referencedcolumnname = "item_pk")}) private set<item> items; } table2 @entity public class item implements serializable { private static final long serialversionuid = 1l; @id @column(name = "item_pk") @generatedv

java - Ensure that randomly generated int[] arrays aren't equal -

i'm long time surfer, first time asker. i started teaching myself java month ago no programming experience (other gui based programming lego mindstorms kits). i'm testing program involves integer arrays filled random numbers. have ensure none of arrays equal. so, went while loop won't end until comparison check arrays complete. here's test code i'm using: import java.util.arrays; public class testmain { public static void main (string[] args){ int[] testint1 = new int[2]; int[] testint2 = new int[2]; int[] testint3 = new int[2]; int[] testint4 = new int[2]; boolean donecheck = false; while (donecheck == false){ testint1[0] = (int) (math.random() * 4); testint1[1] = (int) (math.random() * 4); testint2[0] = (int) (math.random() * 4); testint2[1] = (int) (math.random() * 4); testint3[0] = (int) (math.random() * 4); testint3[1] = (int)

c# - Resolving namespace conflict with satellite assembly -

i have satellite assembly in project called localization . have mvc project contains following model: namespace mvcapp.models.localization { class model { public dictionary<string, string> getlocalization() { // want access localization assembly here... assembly localization = assembly.getassembly(typeof(localization.viewer)); // i'm getting conflict here i'm inside localization // namespace } } } is there nice way can access assembly localization in context, rather current namespace? i'm happy enough rename model namespace, wanted know if there better way. i'm not sure understood problem suggestion use namespace alias: on top import namespace alias below using first = firstnamespace; and access class want that: first.test test = new first.test();

graph - D3: Force Layout with fixed Y ranges - Reducing link overlap -

Image
i have created graph each node fits 1 of fixed y ranges. using force layout display graph don't know how ensure minimum of crossed links occurs - crossing inevitable. think combination of gravity, force, linkdistance etc. none of changes seem work the graph located at: http://plnkr.co/edit/wywjk37mkdcwcwpzvzxe?p=preview the ideal configuration but comes out mess: any thoughts appreciated take @ example . this example, little bit modified. basic idea forced layout in 2 passes: first allow little bit more relaxed way of layout: nodes allowed deviate "level"; allow spontaneous jumping 1 on achieve better link layout (less intersection) second "return" nodes respective level key portions of code: custom force: graph.nodes.foreach(function(o, i) { o.y += (y(o.level) - o.y) * k; }); layout definition: var force = d3.layout.force() .charge(-1000) .gravity(0.2) .linkdistance(30) .size([