Posts

Showing posts from July, 2013

Cannot allocate memory for a 2 dimentional array of pointers c++ -

so i'm trying create 2 dimensional array of pointers object of type piece. problem when try assign pointer piece array segmentation fault. realized needed initialize array sometime before can start allocating can't right. here header file of map contains 2-d array of pointers. #ifndef map_h #define map_h #include <iostream> #include <vector> #include <fstream> #include <stdio.h> #include <stdlib.h> #include <sstream> #include <string> #include <cstring> #include "player.h" #include "sprite.h" #include "piece.h" #include "messages.h" #include "piecetype.h" using namespace std; class map { private: piece*** pieces; int startingx; int startingy; int width; int height; string mapname; public: map(string); ~map(); void printmap() const; piece* piecetype(char); vo

c++ cannot convert from 'int **' to 'const int **' -

this question has answer here: why isn't legal convert “pointer pointer non-const” “pointer pointer const” 5 answers consider following code: int** a; const int** b; b = a; this code gives error: error c2440: '=' : cannot convert 'int **' 'const int **' conversion loses qualifiers why not able perform cast? when operating simple pointers works ok. int* a; const int* b; b = a; suppose able perform cast. consider: const int n = 42; const int* cp = &n; int* p; int** = &p; const int** b; b = a; // hypothetical, doesn't compile *b = cp; // equivalent p = cp; *p = 84; // equivalent n = 84: oops therefore, allowing implicit cast int** const int** allow program violate const correctness.

Not able to set icons in Android 4.2.2 option menu -

i wondered why unable add icons in option menu. developing app in android 4.2 , want add custom menu options. i'm doing below: in menu folder -> home_activity.xml <menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/about_us" android:title="@string/homeactivity_aboutus_item" android:orderincategory="100" android:icon="@drawable/apply_img" /> <item android:id="@+id/help" android:title="@string/homeactivity_help_item" android:icon="@drawable/browsefile" android:orderincategory="102" /> in home_activity.java @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.home_activity, menu); return true; } @override public boolean onoptionsitemselected(menuitem item) { resources resources = getr

objective c - Rotation of UIImageView does not conserve center -

just setting rotation transform uiimageview not keep center still. image translate around de center, i'm puzzled. idea? cgaffinetransform transform = cgaffinetransformidentity; transform = cgaffinetransformrotate(transform, self.filter.angle); self.sourceimageview.transform = transform; note: angle coupled uislider user changes value -90 90 . i found setting transformation layer fixes issue. self.sourceimageview.layer.transform = catransform3drotate(catransform3dmakescale(scale, scale, 1.), angle, 0, 0, -1);

mysql - Selecting the difference of sum of a column from one table and sum of a column from another table -

i have 2 tables income , expenses. have calculate sum of expenses , incomes , calculate difference of both sums. i using select (sum(a.amount)-(select sum(i.amount) incomes group i.userid)) expense, a.userid amount group a.userid at present there on userid in income table, when execute query, taking sum of userid's income , subtracting everyone's expenses. i need individual difference. you can use subselect select (q.amount - q.expense) `diff` ( (select (sum(a.amount) amount group a.userid) `amount`, (select sum(i.amount) incomes group i.userid) expense, ) q or join select (q.amount - q.expense) `diff` ( select sum(a.amount) `amount` ,sum(i.amount) `expense` amount join incomes on ( a.userid=i.userid) group i.userid ) q or can try full outer join don't exist still can same using union select (q.amount - q.expense) `diff` ( (select (sum(a.amount) `amount` , null `expense` amount group a.userid) union (select null `amount`, sum(i.amount

c - Why is clang optimizing out my array even when using -O0 flag? -

i trying debug following c program using gdb: // program generate user specified number of // fibonacci numbers using variable length arrays // chapter 7 program 8 2013-07-14 #include <stdio.h> int main(void) { int i, numfibs; printf("how many fibonacci numbers want (between 1 , 75)?\n"); scanf("%i", &numfibs); if (numfibs < 1 || numfibs > 75) { printf("between 1 , 75 remember?\n"); return 1; } unsigned long long int fibonacci[numfibs]; fibonacci[0] = 0; // definition fibonacci[1] = 1; // definition for(i = 2; < numfibs; i++) fibonacci[i] = fibonacci[i-2] + fibonacci[i-1]; for(i = 0; < numfibs; i++) printf("%llu ", fibonacci[i]); printf("\n"); return 0; } the issue having when trying compile code using: clang -ggdb3 -o0 -wall -werror 7_8_fibonaccivarlengtharrays.c when try run gdb on a.out file created ,

python - How can I make sure the greater number is placed first? -

i have program works on logfile narrow down 2 items. program works great except gets 2 numbers backwards. example, 2 numbers ends should [1700, 1650], not [1650, 1700]. how can make sure higher value number listed first [0] , lower number listed second [1]? import pylab pylab import * numpy import * collections import counter list_of_files=[('logfile.txt', 'temp')] datalist = [( pylab.loadtxt(filename), label ) filename, label in list_of_files] data, label in datalist: pylab.plot( data[:,0], data[:,1], label=label ) print data [:,1] temps = [k k,v in counter(data[:,1]).items() if v>1 , 1500<=k<2200] print temps print ("test="), 0.555*(temps[0]-32)+.651*(temps[1]-32) you can reverse sort list this: temps = [k k,v in counter(data[:,1]).items() if v>1 , 1500<=k<2200] temps = sorted(temps, reverse=true)

c# - Mono will not load mvc project -

i have build , installed mono 3.0 on server , can run asp.net sites on server framework 4.0. not able run mvc applications. wanted achieve. whenever upload mvc project runtime error. when restart apache, following error in log: [sun oct 06 18:19:51 2013] [notice] apache/2.2.22 (debian) mod_mono/2.11 configured -- resuming normal operations stacktrace: @ <unknown> <0xffffffff> @ mono.webserver.apache.server.gethash (system.collections.generic.ienumerable`1<string>) <0x000af> @ mono.webserver.apache.server.realmain (string[],bool,mono.webserver.iapplicationhost,bool) <0x0015f> @ (wrapper remoting-invoke-with-check) mono.webserver.apache.server.realmain (string[],bool,mono.webserver.iapplicationhost,bool) <0xffffffff> @ mono.webserver.apache.server.main (string[]) <0x000f3> @ (wrapper runtime-invoke) <module>.runtime_invoke_int_object (object,intptr,intptr,intptr) <0xffffffff> native stacktrace: /usr/bin/mono

constraints - Toolbar disappears on iOS 7 -

well, don't know happening here, i'll try explain best of ability. this looks like: http://youtu.be/_zbrnyvs6ya so constructed webview , toolbar forum view, , set constraints. double checked layering, , yeah, toolbar in front. i came conclusion it's constraints, i'll need help. have little knowledge of auto layout , of it's goodness. how can make work? it because using 3.5 inch iphone simulator. if use 4 inch should work. make work on 3.5 select view controller , on top select editor -> resolve auto-layout issues -> clear constraints in view controller. next remove toolbar , re-add it.

safari - CSS changes on refresh -

the contacts page of website functional, when refresh page css property display:inline; navigation list becomes void. problem exists in safari. the same css stylesheet used 2 other pages , fine, i'm confused! http://www.katieburchett.co.uk/contacts.html for starters, html markup invalid. long that's case, i'd expect behavior undefined , browser-specific. have this: <ul> <a href="index.html"> <li>home</li> </a> <!-- , on --> </ul> according spec , li elements permitted immediate children of ul elements. markup should this: <ul> <li> <a href="index.html">home</a> </li> <!-- , on --> </ul> after making change, of course, may need adjust css selectors/rules account new markup. any time you're seeing strange markup/style behavior, especially when it's browser-specific, first thing should valida

c# - How to place and access an object of type class within a queue -

so have job class public class job { private string id; private int numbytes; private int requiredtime; } within main receive values , create job var ajob = new job(); queue jobqueue = new queue(); i want able take job info out of queue job again job test = new job(); test = (job)jobqueue.peek(); however when print out recieve "job" console.writeline(test); i've recieved compiler error when use: test = jobqueue.peek(); error 1 cannot implicitly convert type 'object' 'job'. explicit conversion exists (are missing cast?) basically goal here store jobs in queue , access job's individual properties. much thanks! first, you'll want use queue<job> . non-generic version old versions of .net framework shouldn't use new code more. second, can't print properties (they not called attributes) of custom class calling console.writeline() . you'll need print

Using Sticky Kit jQuery plugin, but can't figure out how to use the 'offset_top' option? -

has had experience using excellent sticky kit jquery plugin? http://leafo.net/sticky-kit/ i can't figure out how use 'offset_top' option? documentation options bit vague, example shown below: $("#sticky_item").stick_in_parent(options) i guess have write this: $("#sticky_item").stick_in_parent(offset_top) but how specify number of pixels want offset #sticky_item by? any appreciated! ah, figured out. to add 20 pixel offset #sticky_item this: $("#primary").stick_in_parent({offset_top: 20});

Rails: how to select_rows with fields names (mysql) -

i looking way result set mysql query similar output of activerecord::base.connection.select_rows includes result's columns names first element. for example: activerecord::base.connection.select_rows_with_fields("select id,name users") => [["id", "name"], ["1","amy"],["2","bob"],["3","cam"]] select_rows_with_fields: module activerecord module connectionadapters class mysql2adapter def select_rows_with_fields(sql) result = execute(sql) rows = result.to_a rows.unshift(result.fields) end end end end

c# - Test a wcf webservice from another PC on the same network -

i have created simple wcf webservice on visual studio 2010. i run on asp.net development server. i try call simple service local on browser using local url: http://localhost:15021/myservice.svc/getdata/test that works , correct json result. tried on fiddler , working. i call computer connected on same network. i got local ipv4 cmd , tried replace localhost on other pc http://10.0.0.14:15021/myservice.svc/getdata/test however getting error 502: connection failed how can call services run on asp.net development server pc/mobile on same network? thanks same thing happened me. problem iis express, doesnt allow website accessible other machine on same network. visual studio deault uses iis express. wont able access , when using iis express. do? install latest iis or try enabling installed iis using control panel> programs > turn windows features on or off > internet information services after installing/enabling can start iis typing inetmgr in c

Keep a running C++ program console on top? -

let's using cin in program allow user input console. simple enough if typing into, let's say, web browser , wanted them input console @ same time? when click away c++ program console window , have else on top, input not go console. how can make console running on top when input web browser, go console? in order capture keyboard input when application not focused, need use windows hook, see: http://msdn.microsoft.com/en-us/library/ms644959%28v=vs.85%29.aspx#wh_keyboardhook example code can found here: http://www.codeguru.com/cpp/w-p/system/keyboard/article.php/c5699/hooking-the-keyboard.htm

.eof() is not working in turbo c++ -

myfile.eof() not working in turbo c++ . here fragment: while(viofile >> vio.studnumb >> vio.firstname >> vio.lastname >> vio.code >> vio.remarks >> vio.date >> '/`enter code here`' >> vio.month >> '/'>>vio.year >> "noted by:" >> vio.filler >> vio.position >> vio.user) { if(vio.studnumb==studno) { cout << endl << studno << ' ' << vio.firstname << ' ' << vio.lastname << ' '<< endl; cout << "violation :" << vio.code << ' ' << vio.remarks << ' ' << vio.date << '/' << vio.month<< '/' << vio.year <<endl; cout << " noted by: " << vio.positio`enter code here`n << ' '; cout <<vio.user; b

vba - MS ACCESS Passing Database Property on creating new database? -

i`m trying create deploying databases distribution. create small databases main database , after attached mail , send guys. why have long story have it. i can create databases transfer tables queries not know how send properties, below. , if has way of doing thats fine too. have distributes in 10 different places. need there in locked mode , pop form automatically. public function fnc_createaccesschicago() dim acapp access.application set acapp = new access.application acapp.application.newcurrentdatabase ("c:\testtest\chicagpdatabase") ------ acapp.properties("startupform") = "frmassetchicago" ---- acapp.quit end function public function fnc_transfers() docmd.transferdatabase acexport, "microsoft access", "c:\testtest\chicagodatabase.accdb", actable, "tblallasset", "tblallasset" docmd.transferdatabase acexport, "microsoft access", "c:\testtest\chicagodatabas

c - Segmentation fault after swapcontext in alarm handler -

basically trying simulate multithreading on single thread context switching. set alarm every 10 microseconds, , switch context 1 thread. problem 1 in 5 runs ends seg fault right after alarm finishes swapcontext, @ least traced gdb. here source files main.c #include "umt.h" void f() { int x = 10; printf("starting thread\n"); while(x) { printf("thread %d\n", x); sleep(1); x--; } } int main() { int x = 0, y, z; umt_init(); y = umt_thread_create(f); printf("starting main\n"); if(y == 0) { printf("problems creating thread\n"); return; } x = 10; z = 1; while(x) { printf("main\n"); x--; } umt_thread_join(y); printf("done waiting\n"); return 0; } umt.h #include <sys/time.h> #include <stdio.h> #include <signal.h> #include <ucontext.h> #include &l

joomla3.0 - joomla gantry template css arrow indicator -

Image
in fusion menu gantry-framework have item sub-menu. naturally there submenu-indicator, down-arrow suggesting there more menu item. managed increase size of menu button (it requirement) using gantry-custom.css file: .gf-menu.l1 > li > .item{ font-size:15px; line-height:64px; padding-top:7px; padding-bottom:7px; position:relative; } now, problem indicator (the down-arrow) low beneath menu title, in picture: i need have arrow placed on same line menu-title. how can that? thank you on menu css file add following, or change respective class declaration parameter fit needs. positioning "top" defines arrow position relative container element. .gf-menu li.parent > .item:after { top: 20%; /* parameter defines arrow positioning */ }

Android: Multiple timers in a ListView with handler and runnable. 2 Problems -

i'm creating app contains listview 2 columns. on first column countdown should displayed , on second column additional text, explains countdown for. below see code works ... more or less. have listview multiple rows timers ticking. 1 problem is: set.text() in runnable seems override rows. e.g. runnable row 1 sets text row 2 , 3, runnable row 2 sets text 1 , 3 , on. has effect first column blinks (with correct values , values of other rows). how can set text specific row in listview? next problem: runnable running on , on if remove callbacks handler. when activity in background or closed timer ticking not needed , don't want waste system resources. my activity: public class timeractivity extends listactivity { mytimeradapter mytimeradapter = null; arraylist<long> timerlist = new arraylist<long>(); arraylist<string> textlist = new arraylist<string>(); @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancest

ruby on rails - Is it possible to send javascript request using wiselinks? -

by default rails (i using rails 4) sends data-remote requests following header: accept:*/*;q=0.5, text/javascript, application/javascript, application/ecmascript, application/x-ecmascript later in rails code respond using format.js. i want migrate wiselinks, data-push requests try render html. possible have default rails behaviour wiselinks? i think don't unserstand correctly how wiselinks work. if use :data => { :remote => true } , don't need :data => { :push => true } . pushing should used if need update url (follow link).

css - DIVs inside DIV height issue -

problem i'm trying make similar image below, black body id="library", grey div id="body" (is not visible due lack of margins inner divs), light blue div id="sidebar", red div id="content", blue div id="navbar" , green div id="contentwindow". image: http://i.imgur.com/wplyfqj.png?1 i'm having trouble containing green div inside red div (the greens parent). configure greens margins respect red div , not have set height explicitly. implementation: http://jsfiddle.net/efntl/ i divs adjust screen width , height visible @ times (down small browser windows). i've looked @ following links haven't provided useful: resizable div inside div 100% height margin around not working well! please? how push div inside div structure? parent div expand children div the code can seen in fiddle above i've included here: html <body class="library"> <div id=body> <div id=&q

c# - Google Calendar: Query Custom Parameter with Special Chars -

i building extension syncs local calendar google calendar. this, setting field on each google event corresponding client-side id. this id can have characters besides 0-9 a-z, e.g. tcu];!k!,9795897484326 . seems ] character messing query, since using extq=[customid:tcu];!k!,9795897484326] . i tried use httputility.urlencode("tcu];!k!,9795897484326") replaced ] %5d , request still failed. what missing here?

python - How do you plot a vertical line on a time series plot in Pandas? -

how plot vertical line (vlines) in pandas series plot? using pandas plot rolling means, etc , mark important positions vertical line. possible use vlines or similar accomplish this? if so, please provide example? in case, x axis date-time. plt.axvline(x_position) it takes standard plot formatting options ( linestlye , color , ect) (doc) if have reference axes object: ax.axvline(x, color='k', linestyle='--')

ios - How can you create a glow around a sprite via SKEffectNode -

i have skspritenode i'd have blue glow around it's edges highlighting purposes. guessing need make sprite child of skeffectnode , create/apply filter of sort. update : have investigated quite chosen answer's approach, , discovered skeffectnode has sizeable hit on performance if have set shouldrasterize , 'no filter' defined. conclusion if game requires more 10 moving objects @ 1 time, can't involve skeffectnode if rasterized. my solution involve pre-rendered glow images/animations, skeffectnode not going cut requirements. if has insight missing, i'd appreciate hearing whatever know! i accepting answer because achieve asked for, wanted add these notes looking go route, can aware of of issues using skeffectnode . @rickster's answer great. since have low rep, i'm apparently not allowed add code comment his. hope doesn't break stackoverflow rules of propriety. i'm not trying userp rep in way. here's code he's

objective c - Defining a method that returns an error -

how define method returns error value? for instance, when call managedobjectcontext save method, method returns boolean, along error: if(![context save:&error]) { nslog(@"%@", error); } would able give me straight-forward example of method definition behind this? edit/update: in same regard, how possible pass multiple errors. i'm doing wrong below (i don't understand concept yet), doesn't work: nsarray *errors = nil; [self throwmultipleerrors:&errors]; for(id error in errors) { nslog(@"muliple error: %@", error); }... -(bool)throwmultipleerrors:(nsmutablearray **) errors { [*errors addobject:@"first error"]; [*errors addobject:@"second error"]; [*errors addobject:@"third error"]; return yes; } in example, method signature is: - (bool)save:(nserror **)error; this allows caller pass in nserror address rather pointer (pointer pointer, ** , & ), method can assign

algorithm - Compute running time function -

i have method , want compute running time: print() { node* p1 = sentinel_->next_; while(p1 != sentinel_) cout << p1->data_ << “ “; p1 = p1->next_; } cout << endl; } if assumed while loop can executed n-1 times. so: t(n) = 1 + (n-1) + (n-1) + (n-1) + 1 = 3n - 1. correct value use “input size,” n? gonna based on t(n) 3n - 1 >= 0 n >= 1/3 or n greater or equal 1 since while loop can @ least executed 1 time. the algorithmic complexity calculated in terms of asymptotic notation. means how algorithm behaves size of input varies. for example, "n" anything. if n == 2, while loop run once, if n == 3, while loop runs twice...in general, mentioned while loop runs "n-1" number of times given value of "n". means value of "n" increases, while loop take longer run. thus, complexity of algorithm directly determined number of times loop run. , number of times loop run determined value of "n"

javascript - Cannot insert html after placing less-than signs in it -

i have site need generate form fieldset template , save inside hidden element. when user needs add more fieldsets form, template read , inserted bottom of existing form. make sure template doesn't interfere jquery selectors i've replaced less-than signs , quotes %lt!% , %qot!% respectively, , idea was replace these proper signs again when template being inserted, reason isn't working. to show situation in code: html: <div id="test"> %lt!%span id=%qot!%testing%qot!%>hello%lt!%/span> </div> <span id="target"></span> js: htmlstring = $("#test").html(); htmlstring = htmlstring.replace(/%lt!%/g, '<'); htmlstring = htmlstring.replace(/%qot!%/g, '"'); $("#target").before(htmlstring); it won't work long second line has less-than sign. placing other character there instead works fine, absolutely nothing gets added page. what's going on here? jsfiddle example

SQL table display error -

i encountering display issue sql code , hoping me figure out whats going on. when create customer table insert line of values works successfully... however, when type select * customer; displays horrible output none of data lined in columns properly. can please take @ code , tell me can fix this. i have multiple tables in database , none of other tables have issue , display properly. window configured using these 2 lines of code: set linesize 132 set pagesize 50 my table creation code: create table customer ( customerid number(5) not null constraint pk_customer_customerid primary key, billingid number(5) not null, customerfname varchar2(40) not null, customerlname varchar2(40) not null, customerphone varchar2(10) not null, customerstreet varchar2(30)not null, customercity varchar2(30) not null, customerstate char(2) not null, customerzip varchar2(9) not null, customeremail varchar2(75) not null, signup_date date default sysdate not null, customerstatus char(1) not

c# - datetime picker asp.net within formview -

i want add time picker in ajax asp:calendarextender. want bind pick in db column datetime type asp code : <asp:formview id="formview1" runat="server" allowpaging="true" onprerender="myformview_prerender" backcolor="white" bordercolor="#336666" borderstyle="double" borderwidth="3px" cellpadding="4" datakeynames="id" datasourceid="sqldatasource1" gridlines="horizontal"> <edititemtemplate> date_time: <asp:textbox id="textboxdatetime" runat="server" text='<%# bind("date_time") %>' ></asp:textbox> <asp:calendarextender id="calendarextender1" runat="server" targetcontrolid="textboxdatetime" ></asp:calendarextender> c# code: protected void myformview_prerender(object sender, eventargs e) { if (formview1.currentmode == f

python - How to *not* display 'NaN' in ipython notebook (html table of pandas dataframe)? -

i have small csv file of real-world data tests performed on different days, etc. not of same parameters tested in each session, there bunch of blank cells sprinkled around original spreadsheet. tuner location,200,210,220,230,240,250,260,270,280 07/17 #1,,,0.319,0.319,0.233,,0.215,,0.3355 07/21 #1,,0.539,0.482,0.034,0.343,0.478,0.285,0.01,0.538 07/21 #2,,,0.107,0.407,0.559,,0.185,0.439,0.36 07/21 #3,,,0.127,,,,,, 07/22 #1,0.316,0.201,0.646,,,,,, 07/22 #2,,0.098,0.138,0.134,0.194,,,, 07/22 #3,,0.216,0.187,,,,,, 07/27 #1,,0.118,0.065,0.013,1.013,,,, 08/05 #1,,,,,,,0.032,, 08/05 #2,,,,,,,0.128,, 08/05 #3,,,,,,0.235,0.159,0.324, 08/05 #4,,,,,,,0.398,, 08/05 #5,,,,,,0.214,0.121,0.121, i'm trying learn manipulate , display data in ipython notebook in regular spreadsheet program. when run following lines inside notebook: import pandas pd # set print option dataframe represented html instead of plain text pd.core.format.set_printoptions(notebook_repr_html=true) # read in csv f

android - Admob is not able to load any ads -

Image
admob not able load ads app. have been waiting while, , still there no ad. <com.google.ads.adview android:id="@+id/adview" android:layout_width="wrap_content" android:layout_height="wrap_content" ads:adunitid="pub-||||||||||||||||" \\ blanked out. ads:adsize="banner" ads:testdevices="test_emulator, 20080411413fc082" ads:loadadoncreate="true"/> my manifest <activity android:name="com.google.ads.adactivity" android:configchanges="keyboard|keyboardhidden|orientation |screenlayout|uimode|screensize|smallestscreensize"/> logcat 10-06 20:43:28.187: w/ads(11465): invalid unknown request error: cannot determine request type. ad unit id correct? 10-06 20:38:52.937: e/activitythread(11465): failed find provider info com.google.plus.platf

Trying to add PHP to Joomla website crashed forum -

i've never done php coding before, i'm using forum extension chronoforums , i'm trying add php forums if user logged in display welcome: $user , if not display link login/register. here code tried, crashed forum page. <?php $user = jfactory::getuser(); $status = $user->guest; if($status == 1) { $url = "/forum/login"; echo "<a href=\"$url\">login/register</a>"; } else { echo "<p>welcome: {$user->username}</p>"; } ?> error: ( ! ) fatal error: class '\gcore\extensions\chronoforums\helpers\elements' not found in d:\wamp\www\administrator\components\com_chronoforums\libs\view.php on line 36 call stack # time memory function location 1 0.0012 687992 {main}( ) ..\index.php:0 2 0.1202 9310792 jsite->dispatch( ) ..\index.php:52 3 0.1241 9381648 jcomponenthelper::rendercomponent( ) ..\application.php:220 4 0.1306 9427712 jcom

string - Textbox for price/cash/currency on C# -

i have problem haunting me while. tried solutions didn't worked. i have textbox cash input ($999,99 example). need automatically input "," , "." display value correctly. i tried 2 solutions. 1 of them this: private void tx_valorunidade_textchanged(object sender, eventargs e) { string value = tx_valorunidade.text.replace(",", "").replace("r$", ""); decimal ul; //check indeed handling number if (decimal.tryparse(value, out ul)) { //unsub event don't enter loop tx_valorunidade.textchanged -= tx_valorunidade_textchanged; //format text currency tx_valorunidade.text = string.format(system.globalization.cultureinfo.createspecificculture("pt-br"), "{0:c2}", ul); tx_valorunidade.textchanged += tx_valorunidade_textchanged; } } the result, however, weird. words may fail on one, rec

java - Arrays, algorithms and elements -

i trying make poker game through java. first thing wanted distribute 5 cards using arrays. have done distribution part, how can prevent same cards being distributed twice. in other words, how can check if array contains element. want able detect if element exists in array, , if does, want able change card has been given out twice, appreciated. codes down below, import java.util.random; import java.util.scanner; import java.util.arrays; public class poker { public final static string[] numbers = {"❤","♠","♦","♣"}; public final static string[] sign = {"1","2","3","4","5","6","7","8","10","j","q","k","a"}; private string[] hand = {"","","","",""}; private boolean found; private random random;

json - Looping through GeoJSON items from GeoRSS with jQuery -

i have georss feed, trying parse jquery create geojson array can add mapbox map leaflet. i think have managed turn georss geojson ok, can;t seem work out how loop through each item can add map. if take out loop part single point plotted onto map - recent entry rss feed. any pointers appreciated! here's code i'm running: $(document).ready(function(){ $.get('http://shifting-sands.com/feed/', function(rssdata) { var $xml = $(rssdata); $xml.find("title").each(function() { var $this = $(this), item = { title: $this.find("title").text(), link: $this.find("link").text(), description: $this.find("description").text(), pubdate: $this.find("pubdate").text(), latitude: $this.find("lat").text(), longitude: $this.find("long").text() } function displayposts(rssdata){ $.each(rssdata.rss.chann

mysql - How to make this query more efficient? -

a comment my previous question said "i suggest looking @ answers here well: stackoverflow.com/questions/1313120/… . answer accepted thought technically correct, in practice might turn out inefficient, since mysql not correlated subqueries". the sql of answer accepted at sql fiddle . referenced question compares left join , inner join. sql fddle uses join< understand default inner join. so, how can rewrite query use lft join? i'm not of performance on mysql, can left join rows disqualify position, , use select records left join didn't match. select v.id , v.description , v.type , p.time_stamp , p.latitude , p.longitude positions p join vehicles v on v.id = p.id left join positions l on l.id = p.id , l.time_stamp > p.time_stamp l.id null or, in sqlfiddle: http://sqlfiddle.com/#!2/2e994/31/0

html - Under the input box form labels -

i looking help. cannot find out how code allow form labels appear under form input see example of picture demonstrating looking for: example . like first, last, mm, dd, yyyy, ### example. can find on input box labels or off side labels. can provide code me duplicate under input box code. thanks in advance. here's need. html: <div class="input_cont"> <input type="text" class="inp" id="first" name="first"> <label for="first" class="lbl">i'm first</label> </div><div class="input_cont"> <input type="text" class="inp" id="second" name="second"> <label for="second" class="lbl">i'm second</label></div> css: input,label{margin:0;} .inp{display:block;} .lbl{font-size:9pt; color:#999} .input_cont{display:inline-block; zoom:1; *display:inline; margin-right:10p

oop - How do you represent domain object behaviors using methods when a domain object is acted upon and not the actor? -

in domain driven design, there emphasis of placing behaviors correctly belong. i'm not sure constitutes "correct," though. consider scenario: "the client withdraws amount of money bank account." grammatically, have that: 'client' subject 'withdraw' verb 'amount' direct object 'account' affected prepositional object classically, client execute this: account.withdraw(amount) . this read as: "the client commands bank account withdraw amount of money." however, not grammatically correspond original scenario, since 'bank account' direct object , infinitive removes 'withdraw' , 'amount' main clause primary idea conveyed 'client commands account'. to adhere ddd, should regard code precisely describing original scenario. implies 'withdraw' method not model behavior performed by account (the account not subject ), rather models behavior indirectly affects (the acc

Geolocation without HTML5 API -

all! i need determine current user city. html5 it's not problem. need support old browsers (leke ie 7,8). first of thought find location using ip address. not easy implement (i need actual database location). free web services not provide me needed info. many of these can determine country (but not city). i tried use http://www.geoplugin.net/ , service return country (as , free). tried use csv database ips (but in internet can find old version). do know free ways determine user city? thanks! some older browsers have support getting user location in form. in ie7/8 days few different browsers handled geolocation in different ways. pain developers. can't life of me remember how in ie7/8 remember writing wrapper library @ point. days people use wrapper libraries handle different browser implementations them. bing maps v7 javascript wraps old , new functionalities common geolocationprovider class in api might option if need map in site: http://msdn.microsoft.com/

Javascript not trigering and alert function is working -

i have asp.net web application given client ui layer , speaking webservices. creating asp.net web application copy pasted html,css , images other files. error : i have master page , child page. in child pages have lot of javascript validating text box. javascript like: $(document).ready rules , messages) they getting form tag master binding. but when click submit button, it's not validation control , have placed alert box inside javascript , working. kindly here... alert box working..and validation not work in same javascript. how check javascript correctly bound form tag? same problem appears in set of master , child page. corrected form tag. master page form tag should in child page. it's validating properly. alert outside $(document).ready check weather coming inside script can post code futhe

java - DEBUG logs are not printing -

i developing web application, in using log4j. running application in jboss-4.2.2ga server. problem trying display debug logs in console , file not printing debug logs. this jboss-log4j.xml file <?xml version="1.0" encoding="utf-8"?> <!doctype log4j:configuration system "log4j.dtd"> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false"> <appender name="file" class="org.jboss.logging.appender.dailyrollingfileappender"> <errorhandler class="org.jboss.logging.util.onlyonceerrorhandler"/> <param name="file" value="/temp_logs/server.log"/> <param name="append" value="false"/> <param name="datepattern" value="'.'yyyy-mm-dd"/> <layout class="org.apache.log4j.patternlayout"> <param name="conversionpatt

groovy - grrovyTest$_run_closure1_closure3_closure4_closure5@4d1abd getting displayed under div while generating html -

i value when try generate html using groovy, here code , output below code: import groovy.xml.markupbuilder println("let try html page..\n") def mkp= new markupbuilder() mkp.html{head{ title "bijoy's groovy" body{ div{style:"color:red"} {p "this cool"} }}} and output has grrovytest$_run_closure1_closure3_closure4_closure5@4d1abd extra.. how remove it? <html> <head> <title>bijoy's groovy</title> <body> <div>grrovytest$_run_closure1_closure3_closure4_closure5@4d1abd <p>this cool</p> </div> </body> </head> </html> attributes dom element mentioned in () map representation shown below <div> . import groovy.xml.markupbuilder println("let try html page..\n") def writer = new stringwriter() def mkp = new markupbuilder(writer) mkp.html{ head{ title "bijo

mvvm - WPF Command Parameter for button inside ItemsControl -

i developing wpf application using mvvm design pattern. in application have itemscontrol display several buttons (number of buttons not constant, according logic flow of application). itemscontrol binded linkedlist in viewmodel. able define command buttons , able command handler within viewmodel if command has no parameters... need able know button has been clicked , therefore have command parameter. how need define view ? syntax commandparameter , parameter can used button content ? command signature in viewmodel ? please note using relaycommand mvvm light. relvant code of view here. in advance <usercontrol x:class="museum.controls.categoriesview" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft

How to display child menu item under their parent item in php? -

i need display child menu items under corresponding parent items in php. have created mysql query unable child items under parent items.here code: for ($i = 0; $i < count($menu); $i++) { echo'<li><a href="' . $url . $menu[$i]['id'] . '" title="' . $menu[$i]["menu_name"] . '">' . $menu[$i]["menu_name"] . '</a>'; if ($menu[$i]['parent_id'] != "0" && $menu[$i]['parent_id'] != null) { echo'<ul>'; echo'<li><a href="#" title="' . $menu[$i]["submenu_name"] . '">' . $menu[$i]["submenu_name"] . '</a></li></ul></li>'; } } mysql query: select m.id, m.menu_name, sm.parent_id,sm.submenu_name,sm.id menu m left join submenu sm on (m.id=sm.parent_id) home | courses | courses | | course-1| course 2

ruby on rails - Failure/Error: before { visit signup_path } NameError: undefined local variable or method `signup_path' for #<RSpec::Core::ExampleGroup -

i'm working through chapter 7 of rails tutorial , seem stuck @ figure 7.22. in brief, i'm unable tests pass. when run . . . bundle exec rspec spec/requests/user_pages_spec.rb . . . see bunch of failed tests read: failures: 1) user pages signup page failure/error: before { visit signup_path } nameerror: undefined local variable or method `signup_path' # <rspec::core::examplegroup::nested_1::nested_1:0x007fb2be028410> # ./user_pages_spec.rb:9:in `block (3 levels) in <top (required)>' 2) user pages signup page failure/error: before { visit signup_path } nameerror: undefined local variable or method `signup_path' #<rspec::core::examplegroup::nested_1::nested_1:0x007fb2be048ad0> # ./user_pages_spec.rb:9:in `block (3 levels) in <top (required)>' 3) user pages signup page invalid information should not create user failure/error: before { visit signup_path } nameerror: undefined local variable or me