Monday, 15 August 2011

login - Facebook OAuth "An Error Has Occurred" -



login - Facebook OAuth "An Error Has Occurred" -

i'm having issues getting users logged in oauth dialog. working before today, suspect might in conjunction february breaking changes. see in production @ womstreet.

sandbox mode disabled, url's set in basic setting section developer page in facebook.

i using devise ruby on rails, inspecting url hand seems good.

any ideas on begin debug?

update 1: seems there bug study open on facebook addressing issue: link here

looks facebook got dev community angry 1 time again rolling out changes effect basic login. don't see solution trying login dialog here: https://developers.facebook.com/docs/concepts/login/

bug link: https://developers.facebook.com/bugs/207955409343730

edit: solv need alter url params. change:

app_id to: client_id next to: redirect_uri

so url link should like:

https://www.facebook.com/dialog/oauth?client_id=something&redirect_uri=something

login oauth facebook-login facebook-oauth

ios - change UIBackgroundModes audio at runtime -



ios - change UIBackgroundModes audio at runtime -

i have app plays music, , want enable background modes. sound category set kaudiosessioncategory_mediaplayback , if add together audio string in uibackgroundmodes within info.plist file keeps playing audio. far good.

now want give alternative users, take if sound plays in background or not. tried getting file , deleting key far nil happens. did (in selector handled uibutton) :

-(void) disablebackgroundaudio:(uibutton*)button{ nsdictionary *plistdict = [[nsbundle mainbundle] infodictionary]; [plistdict setvalue:@"" forkey:@"uibackgroundmodes"]; }

if print value in console, before , after, can see had "audio" before, , after called, blank string. however, if force home button sound playing no matter if disabled audio.

my guess not way update (although i'm not sure if it's possible) info.plist file. possible @ all? after think giving users selection improve specific app, , i've seen other apps doing it.

any help appreciated.

the info.plist part of application's bundle. all files in bundle immutable.

keep audio value there , pause music when application enters background (in case user turned alternative off).

ios info.plist

direct3d - Passing colors through a pixel shader in HLSL -



direct3d - Passing colors through a pixel shader in HLSL -

i have have pixel shader should pass input color through, instead getting constant result. think syntax might problem. here shader:

struct pixelshaderinput { float3 color : color; }; struct pixelshaderoutput { float4 color : sv_target0; }; pixelshaderoutput main(pixelshaderinput input) { pixelshaderoutput output; output.color.rgba = float4(input.color, 1.0f); // input.color 0.5, 0.5, 0.5; output black // output.color.rgba = float4(0.5f, 0.5f, 0.5f, 1); // output grayness homecoming output; }

for testing, have vertex shader precedes in pipleline passing color parameter of 0.5, 0.5, 0.5. stepping through pixel shader in visualstudio, input.color has right values, , these beingness assinged output.color correctly. when rendered, vertices utilize shader black.

here vertex shader element description:

const d3d11_input_element_desc vertexdesc[] = { { "position", 0, dxgi_format_r32g32b32_float, 0, d3d11_append_aligned_element, d3d11_input_per_vertex_data, 0 }, { "color", 0, dxgi_format_r32g32b32_float, 0, d3d11_append_aligned_element, d3d11_input_per_vertex_data, 0 }, { "texcoord", 0, dxgi_format_r32g32_float, 0, d3d11_append_aligned_element, d3d11_input_per_vertex_data, 0 }, };

i'm not sure if it's of import vertex shader takes colors rgb outputs same, pixel shader outputs rgba. alpha layer working correctly @ least.

if comment out first assignment, 1 using input.color, , uncomment other assignment, explicit values, rendered pixels grayness (as expected).

any ideas on i'm doing wrong here?

i'm using shader model 4 level 9_1, optimizations disabled , debug info enabled.

output.color.rgba = float4(input.color, 1.0f);

your input.color float4 , passing float4, think should work

output.color.rgba = float4(input.color.rgb, 1.0f);

this need pass thru simply

homecoming input.color;

if want alter colour reddish like

input.color = float4(1.0f, 0.0f, 0.0f, 1.0f); homecoming input.color;

direct3d hlsl pixel-shader

database design - About SQL and complexity -



database design - About SQL and complexity -

i've created sql table field x , field date. compute sum of x date < d. i've 2 possibilities :

create new field, "sum of x", represents sum of x when date < date[field] compute sum of x "manually", sql request

is there method superior ? or, if not, assume depends on table size. approximate size equalizes 2 methods ?

thank much.

is there method superior ?

no. in general, stick simplest solution until find doesn't work more. simplest solution in case calculate derived field each time need it.

or, if not, assume depends on table size.

yes. , number of insertions vs. number of reads. , whether dates monotonically increasing or not. , space (memory/disk) vs. time (processing power) tradeoff of scheme , requirements. , number of other things too.

what approximate size equalizes 2 methods ?

how long piece of string? many other variables reply that.

to repeat: stick simple until forced otherwise. maintaining cached values introduces complexity , corner cases: transactional boundaries? happens if add together new row? presumably triggers subsequent transaction observe , update affected rows. happens if roll original transaction?

that's lot more logic. much more potential go wrong. stick yagni until find do.

hth.

sql database-design aggregate-functions data-modeling

java - Code difference between jfreechart XYLineAndShaperanderer, XYDotRenderer and XYSplineRenderer? -



java - Code difference between jfreechart XYLineAndShaperanderer, XYDotRenderer and XYSplineRenderer? -

i'm trying create simple xysplinerenderer, code work if write xydotrenderer = new xydotrenderer(); or xylineandshaperenderer = new xylineandshaperenderer(); can sameone tell wrong? i'm beginner in programming.

here code:

package kubas; import org.jfree.chart.*; import org.jfree.chart.axis.*; import org.jfree.chart.plot.*; import org.jfree.chart.renderer.xy.xysplinerenderer; import org.jfree.data.xy.*; import org.jfree.ui.applicationframe; public class spausdink { public static void main(string[] args) { xyseries series = new xyseries("xy grafikas"); series.add(1, 2); series.add(2, 4); series.add(3, 8); series.add(4, 16); series.add(5, 32); series.add(6, 64); series.add(7, 128); series.add(8, 256); series.add(9, 512); series.add(10, 1024); xyseriescollection dataset = new xyseriescollection(); dataset.addseries(series); applicationframe frame = new applicationframe("mano grafikas"); numberaxis xax = new numberaxis("x"); numberaxis yax = new numberaxis("y"); xysplinerenderer = new xysplinerenderer(); a.setprecision(10); xyplot xyplot = new xyplot(dataset, xax, yax, a); jfreechart chart = new jfreechart(xyplot); chartpanel chartpanel = new chartpanel(chart); frame.setcontentpane(chartpanel); frame.pack(); frame.setvisible(true); } }

edited message:

both codes work properly, created new project.

i'm not sure what's wrong, there's working illustration below. tend take little odd values precision; default 5. same code works xylineandshaperenderer or

xydotrenderer r = new xydotrenderer(); r.setdotwidth(5); r.setdotheight(5);

import java.awt.dimension; import java.awt.eventqueue; import javax.swing.jframe; import org.jfree.chart.*; import org.jfree.chart.axis.*; import org.jfree.chart.plot.*; import org.jfree.chart.renderer.xy.xysplinerenderer; import org.jfree.data.xy.*; public class test { public static final string title = "f(x) = 2^x"; public static void main(string[] args) { eventqueue.invokelater(new runnable() { @override public void run() { display(); } }); } private static void display() { xyseries series = new xyseries(title); (int = 0; <= 10; i++) { series.add(i, math.pow(2, i)); } xyseriescollection dataset = new xyseriescollection(); dataset.addseries(series); numberaxis domain = new numberaxis("x"); numberaxis range = new numberaxis("f(x)"); xysplinerenderer r = new xysplinerenderer(3); xyplot xyplot = new xyplot(dataset, domain, range, r); jfreechart chart = new jfreechart(xyplot); chartpanel chartpanel = new chartpanel(chart){ @override public dimension getpreferredsize() { homecoming new dimension(640, 480); } }; jframe frame = new jframe(title); frame.setdefaultcloseoperation(jframe.exit_on_close); frame.add(chartpanel); frame.pack(); frame.setlocationrelativeto(null); frame.setvisible(true); } }

java charts jfreechart

android - How to cancel AsyncTask or all AsyncTask including nested AsyncTasks from same Activity? -



android - How to cancel AsyncTask or all AsyncTask including nested AsyncTasks from same Activity? -

i have activity utilize asynctask open cursor spawns children asynctask render items read cursor.

activity executes on cursor asynctask not see children asynctask items.

how cancel running asynctask tasks (including nested) specified activity?

how cancel running children asynctask tasks specified asynctask (if possible @ all)?

i want stop tasks on new command interface not corrupt views.

there's no manager asynctask execute.

you'll have maintain track of new instances of asynctasks you've created , close them cancel(boolean mayinterruptifrunning) method. pay attending canceling task won't stop in middle. you'll have check in doinbackground - iscanceled()

android android-asynctask

javascript - Redirect a page for a specific time peroid -



javascript - Redirect a page for a specific time peroid -

i trying create 302 redirect waits 18 seconds after redirecting , goes parent page.

here have done,

<script type='text/javascript'> (function (){ if (document.cookie.indexof(welcomecookie) != -1 || document.cookie.indexof(dailywelcomecookie) != -1 ){ document.cookie="tourl"+ "=" +escape(document.url)+";path=/; domain=.forbes.com"; document.cookie="refurl"+ "=" +escape(document.referrer)+";path=/; domain=.forbes.com"; this.location="http://www.forbes.com/fdc/welcome_mjx.shtml"; })(); </script>

it sounds me need first redirect user, appear know how do. however, 1 time user redirected target page, target page need have javascript send user parent page. here's simple javascript code need based on code above:

<script type='text/javascript'> (function (){ if (document.cookie.indexof(welcomecookie) != -1 || document.cookie.indexof(dailywelcomecookie) != -1 ){ document.cookie="tourl"+ "=" +escape(document.url)+";path=/; domain=.forbes.com"; document.cookie="refurl"+ "=" +escape(document.referrer)+";path=/; domain=.forbes.com"; // wait 18 seconds go specified page. 18000 milliseconds == 18 seconds settimeout(function(){ this.location="http://www.forbes.com/fdc/welcome_mjx.shtml"; }, 18000); })(); </script>

javascript

android - Scaling large bitmap alternative approach -



android - Scaling large bitmap alternative approach -

firstly aware of recommended approach of using injustdecodebounds , insample size load bitmaps @ size close desired size. broad approach gets image approximate target.

i have though of utilising options.indensity , options.intargetdensity trick native loader scaling image more exactly desired target size. set options.indensity actual width of image , options.intargetdensity desired width , indeed image @ desired size (aspect ration happens remain same in case). set image.setdensity(density_none) on resulting image , appears work ok.

anyone know of wrong approach? thoughts on memory efficiency , image quality?

i have got improve image management opengl 2.0 , surface views.

android bitmap scaling

mysql - Query part of string or text -



mysql - Query part of string or text -

using rails , mysql. not sure if has been asked, couldn't find it.

i have next records:

1. love rails 2. love django 3. code using ruby on rails

====

(1) search: "i love"

results: "i love rails", "i love django"

====

(2) search: "love"

results: "i love rails", "i love django"

====

(3) search: "ails"

results: "i love rails", "i code using ruby on rails"

====

(4) search: "code ruby"

results: "i code using ruby on rails"

====

my code is:

term = "%#{params[:term]}%" shops = shop.where("name ?", term)

it works on search (1) , (2). how can code accomplish results when doing search (3) , (4) too?

many thanks.

i think need wildcards in there (in raw sql)

like '%ails'

or more generally:

like '%substring%'

mysql ruby-on-rails

Sort multidimensional array columns in C -



Sort multidimensional array columns in C -

i have piece of code in c:

#include <stdio.h> #include <stdlib.h> int multiply(int); int main() { file *fp; int i, j, n, m, matrix[99][99], sum = 0, columnsums[99] = {0}; fp = fopen("data.txt", "r"); if(fp != null) { fscanf(fp, "%d", &n); fscanf(fp, "%d", &m); for(i = 0; < n; i++) { for(j = 0; j < m; j++) { fscanf(fp, "%d", &matrix[i][j]); } } for(i = 0; < m; i++) { for(j = 0; j < n; j++) { sum += multiply(matrix[j][i]); } columnsums[i] = sum; sum = 0; } } else { puts("cannot read file!"); } puts(""); system("pause"); homecoming 0; } int multiply(int thisnum) { homecoming thisnum * thisnum *thisnum; }

my tasks wants me read multidimensional array text file, , sort each column add-on of each column fellow member multiplied 3 times. wasn't hard read array , find each columns add-on , store other array stores add-on of each column (hoped help), i'm stuck sorting out. tips, please? :)

you can utilize qsort(). don't forget include stdlib.h

#define arr_size(a) (sizeof(a) / sizeof(*(a))) int comp(const void* a, const void* b) { homecoming *(const int*)a - *(const int*)b; } ... (i = 0; < arr_size(matrix); i++) { qsort(matrix[i], arr_size(matrix[i]), sizeof matrix[i][0], comp); }

c arrays sorting multiple-columns

android - Why would my dynamically generated content not show up in tablelayout -



android - Why would my dynamically generated content not show up in tablelayout -

i trying load buttons table layout within fragment. why not show up. see changing background works (changed gray reddish in oncreateview(......)) when phone call loadallbuttons not show up.

public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { if(container == null) homecoming null; basedview = (tablelayout) inflater.inflate(r.layout.fragment_difficult_sound_syllable, container, false); currentsyllable = getarguments().getstring(staticvalues.difficult_sound_selector); basedview.setbackgroundcolor(color.red); homecoming basedview; }

below loadallbuttons, , before asks yes says loaded (e.g. buttons , rows added, checked via logcat after row.add() , basedview.add())

private void loadallbuttons() { databasehelper tmphelper = new databasehelper(getactivity().getapplicationcontext()); arraylist<buttoninfocontainer> tmparray = null; if(currentsyllable.contentequals(staticvalues.consonant)) { tmparray = tmphelper.returnallconsonants(); log.i(staticvalues.tag, "returned consonants"); } else { tmparray = tmphelper.returnallvowels(); log.i(staticvalues.tag, "returned vowels"); } if(tmparray != null) { tablerow row = null; infobutton tmpbutton = null; //layoutparams rowparams = new layoutparams(layoutparams.wrap_content, layoutparams.wrap_content); //tablerow.layoutparams equalparams = new tablerow.layoutparams(layoutparams.wrap_content, layoutparams.wrap_content, 0); linearlayout.layoutparams buttonlayout = new linearlayout.layoutparams(layoutparams.fill_parent, layoutparams.fill_parent); if(basedview != null) { for(int = 0; < tmparray.size(); i++) { //adds new row table if modulus 0 if(( % 2 ) == 0) { row = (tablerow) getlayoutinflater(getarguments()).inflate(r.layout.table_row, null); //row.setlayoutparams(rowparams); basedview.addview(row); } tmpbutton = (infobutton) getlayoutinflater(getarguments()).inflate(r.layout.info_button, null); tmpbutton.setbackgroundresource(r.drawable.button_bg); tmpbutton.setlayoutparams(buttonlayout); //set button text tmpbutton.settext(tmparray.get(i).buttontext); //obtain held info tmpbutton.setextrainfo(tmparray.get(i).infoheld); //tmpbutton.setwidth(buttonwidth); //tmpbutton.setheight(buttonheight); //tmpbutton.settextsize(typedvalue.complex_unit_dip, textsize); tmpbutton.settextcolor(getresources().getcolor(r.color.button_text_color)); tmpbutton.settypeface(typeface.default_bold); row.addview(tmpbutton); tmpbutton.setonclicklistener(listenerdynamicbutton); } } } }

for reason though logcat outputs show (buttons showing proper names right amount of buttons) table layout not populated.

figured out reply in regards own problem. after

tmpbutton = (infobutton) getlayoutinflter()...

to

row.addview(tmpbutton);

had deleted except

tmpbutton.settext();

and

tmpbutton.setextrainfo(..);

although not know why killed layout. if figures part out gladly take answer.

android dynamic android-tabhost fragment android-tablelayout

sql - Bulk load: An unexpected end of file was encountered in the data file -



sql - Bulk load: An unexpected end of file was encountered in the data file -

i using sql server express 2008

when i'm trying load info txt file in table

create table clients ( clientid int not null identity (9000,1), lastname varchar (30)not null, firsname varchar (30)not null, midinitial varchar (3), dob date not null, adress varchar (40) not null, adress2 varchar (10), city varchar (40) not null, zip int not null, phone varchar (30) , categcode varchar (2) not null, statusid int not null, hispanic binary default 0, ethncode varchar(3) , langid int, clientproxy varchar (200), parent varchar (40), hshldsize int default 1, annualhshldincome int, monthlyyearly varchar(7) , pfds int, wic binary default 0, medicaid binary default 0, atap binary default 0, foodstamps binary default 0, agencyid int not null, routid int , deliverynotes varchar (200), recertificationdate date not null, notes text, primary key (clientid) );

i utilize

set identity_insert clients2 on; mass insert clients2 'c:\sample_clients.txt' ( fieldterminator = ',', rowterminator = '\r\n' )

sql server express trows me errors

msg 545, level 16, state 1, line 2 explicit value must specified identity column in table 'clients' either when identity_insert set on or when replication user inserting not replication identity column.

file has 1 line (for sample data) check many times 1 line

data looks

13144,vasya,pupkin,,1944-10-20,p.o. box 52,,wrna,99909,(907) 111-1111,sr,4,0,w,1,,,3,1198,month,0,0,1,0,1,45,,,2011-04-27

any ideas how prepare problem?

you need parameter keepidentity in mass insert statement. required retain identity values in load.

bulk insert clients2 'c:\sample_clients.txt' ( keepidentity, fieldterminator = ',', rowterminator = '\r\n' )

i think have problem because have no info or placeholder notes column. comma added end of file should address this.

sql database sql-server-2008 sql-server-2008-express loaddata

Facebook comment box migrating to another domain -



Facebook comment box migrating to another domain -

how can alter site domain , keeping existing comments?

i'm using html5 info attributes, this: data-href="http://domain/somespecificid" , want alter data-href="http://new_domain/somespecificid".

if keeping old href, got error message: warning: url unreachable.

is there way this?

very short: can`t facebook social plugin comments after url change facebook comments synchronized url give. can alter dynamically. @ post how dynamically alter facebook comments plugin url based on javascript variable?

facebook comments facebook-comments

basex - XQuery to change attribute value and return previous one -



basex - XQuery to change attribute value and return previous one -

i'm trying update attribute value of node , homecoming previous value in 1 query , can't find way it. i'm using basex xml/xquery database.

for i've tried doing this:

/root/elem/properties/property[@id='17']/@format, replace value of node /root/elem/properties/property[@id='17']/@format 'url'

and this:

for $prop in /root/elem/properties/property[@id='17'] allow $format := $prop/@format homecoming (replace value of node $prop/@format 'url', $format)

and multiple other tests lead next error:

list expression: no updating look allowed.

is limitation of basex or not possible in xquery?

xquery update not allow returning results updating query. can utilize basex's proprietary db:output($seq) function that:

for $prop in /root/elem/properties/property[@id='17'] allow $format := $prop/@format homecoming (replace value of node $format 'url', db:output($format))

xquery basex

Reinstaling Formula One component (TF1Book) in Delphi 2007, License Information for TF1Book not found error -



Reinstaling Formula One component (TF1Book) in Delphi 2007, License Information for TF1Book not found error -

i'm moving old project developed delphi 2007 , bunch of 3rd party components old computer own instalation. except tf1book component (from vcf132.ocx library, version 4.1.1.2) works fine. i'm using exact same version of delphi in new computer , same patches. (the older computer belongs developer left company , it's unavailable , unreachable)

the error i'm getting in design time, , in design time is:

license info tf1book not found. cannot utilize command in design mode.

so, can still compile , can edit .dfm form in notepad , works fine, in runtime, can't work within delphi.

please, note have read first 30 entrys each google search related problem, several variations. , of them says should run regsvr32 register ocx within windows , solve problem. also, of posts or blogs i've found way older, , they're talking version 3.x of component. using 4.1.1.2 version. other developer had in computer.

i repeated supposed procedure of placing vcf132.ocx on \windows\system32 or windows\syswow64 (for x64 windows) , run appropriate regsvr32 version register component in 3 computers: win 7 x86, win 7 x64, win 8 , winxp sp3 , got same result in of them.

i'm starting think real licensing issue, not ocx windows registering issues. actually, if don't register de ocx in windows error in delphi different, class not found or similar.

nobody else in company (a little 3 guys company) knows or remember how component acquired , hence can't find proper installer components.

though, researching windows registry in computer found info sort of registration process, user, company , serial number. there no ".lic" files associated ocx in old computer.

but far, i'm unable find such installer in computer. happy acquire new license, product not beingness sold anymore.

so, question. vcf132.ocx, version 4.1.1.2, knows/remember if there re-create protection or registration mechanisms forbid me move component other computer?

i used utilize component way when. recall, registering ocx gives runtime support. working @ designtime need run, on dev machine, installation programme vendor supplied.

i distinctly remember there .lic file installed onto each developer machine. should find them on old machines, i'm not sure whether can transferred.

delphi delphi-2007

datasource - Grails how to call another database table? -



datasource - Grails how to call another database table? -

example : have 2 db : db1 , db2

and have 2 domain in app,

class domain1 { string test domain2 domain2 static mapping = { datasource 'db1' } } class domain2 { static mapping = { datasource 'db2' } }

when seek save class domain1, error "an unmapped class" how save domain1 class? thanks

you cannot have foreign key in 1 db referencing in db. that's why grails refuses map such relation.

replace field domain2 domain2 integer domain2id , command relation object in db2 database manually.

grails datasource multiple-databases

c# - Why My test Binaries are getting copied into TestResults\\out folder? -



c# - Why My test Binaries are getting copied into TestResults\<somepath>\out folder? -

i facing unusual behavior visual studio of sudden test binaries(mytestsolution.dll) , dependency binaries added in reference, getting copied testresults\\out folder bin folder , starts executing there?

this results in tests getting failed getexecutionassembly() giving path of out folder instead of bin folder of dependent binaries exist?

could 1 please help me how stop this?

visual studio 2010 creates folder testresults , deploys relevant files in subdirectories next schema: username_computername date time.

this normal behavior if don't have .testsettings file solution. .testsettings file situated in folder solution items.

if have .testsettings file, depends on setting of enable deployment in deployment section. if enable deployment checked, testresults folder created , filled.

in cases possible testresults folder created although enable deployment deactivated. in case folder used temporary files, not execution files of tests.

for more infos see:

msdn - test deployment overview

c# visual-studio-2010 unit-testing deployment msbuild

objective c - How to add 1 to Variable with Button Click? -



objective c - How to add 1 to Variable with Button Click? -

i want add together 1 variable each time button clicked, instead 10 digit number appears. doing wrong code below?

-(ibaction)recorddata:(id)sender { int randomnumber; randomnumber = randomnumber + 1; nsstring *myrandomnumber = [nsstring stringwithformat:@"%i", randomnumber]; nsstring *completedata = [[nsstring alloc] initwithformat:dataview.text]; completedata = [completedata stringbyappendingstring: @"\n"]; completedata = [completedata stringbyappendingstring:myrandomnumber]; dataview.text = completedata; }

make

int randomnumber

either static or declare instance variable.

what doing creating new varialbe each time when recorddata invoked. plus not initialize it. local variables not initialized. instance variables initialized 0/nil. result variable has random content (as name suggests anyway :). random value add together 1.

objective-c

Pass nested object in jquery ajax -



Pass nested object in jquery ajax -

i want pass next nested object in ajax using jquery:

{ "parent_param1" : [ { "sub_param1" : "sub_val1", "sub_param2" : "sub_val2" }, { "sub_param1" : "sub_val1", "sub_param2" : "sub_val2" }, { "sub_param1" : "sub_val1", "sub_param2" : "sub_val2" } ], "parent_param2" : "par_val2", "parent_param3" : "par_val3" }

i'm trying pass next example:

var url = encodedurl; var info = 'above object'; $.ajax({ type:'post', url:url, datatype:'json', data:data, success:function(res){ alert('success'); }, error:function(e){ alert('error'); } });

i'm getting runtime error response. want create sure right way pass nested object in ajax using jquery?

right passing object server, without key. need pass info json string.

console.log(typeof data); //object console.log(typeof json.stringify(data)); //string

in order read info serverside, need pass info object literal key , value. this:

data: { dto: json.stringify(data) },

on serverside, can access object in different ways, depending on language.

php:

$dto = $_post['dto'];

asp.net:

var dto = httpcontext.current.request.form['dto'];

ajax jquery object

Is there still a tutorial for OpenGL 1.2? -



Is there still a tutorial for OpenGL 1.2? -

i'm on old computer, supports opengl 1.2 (my drivers date). there still free online tutorial opengl 1.2 available? practically see when googling 3.x (just few 2.x). , of course of study many opengl es tutorials (but i'm on old macbook, not iphone).

edit: telling me when opengl 1.2 came out helpful too, google can filter based on date.

edit 2: march 1998. unfortunately, google doesn't allow me come in date. lets me specify period, varying 'all times' 'last 24 hours' 'last year'...

you take @ original "red book" - gives introduction legacy opengl.

http://www.glprogramming.com/red/

opengl

Overflowing a stack in theory.. and assembly -



Overflowing a stack in theory.. and assembly -

assuming x86 scheme no aslr i'd inquire following;

1) theory says when execute stack overflow attack, value pointed ebp register overwritten new homecoming address too.

now, since never go caller function don't need ebp's original value restore previous stack frame nevertheless, ebp register must point somewhere @ times. how ebp set after eip register starts pointing our new shellcode? more specifically, of 2 assembly instructions (leave-ret) induces farther microinstruction restores ebp value?

2) lastly not least, inquire how create sure in occasions our shellcode needs force couple of values on stack, these values won't overwrite part of shellcode? in other words, how can shellcode generated variables placed before start of shellcode , instance not somewhere in between?

thank in advance.

in reply part 2 of question: depending on syscall making, may have set value esp (as arg array). if that's end of shellcode fine. however, if there more shell code , happen push and esp happens point somewhere in rest of shellcode might in problem (because @ point writing on own instructions). simple prepare sub $0x99, %esp @ origin of shellcode.

edit (in response comments)

perhaps misunderstood question. when said 'stack overflow' assumed meant buffer overflow. if assumed correctly read on. assuming talking classic smashing-the-stack sort of exploit (which seems case based on image linked to), filling buffer nop sled, shellcode , overwriting homecoming pointer. shell code "position independent code". means series of instructions can executed regardless of current state of registers, flags etc.

normally, (this way link posted depicts it) fill buffer nops, followed shellcode, , homecoming address points somewhere in tho nop sled. when ret instruction executed, address in %esp poped %eip , %esp incremented 4 (in x86). problem if shellcode has several push instructions, has side effect of decrementing %esp. if have plenty of them and shellcode way @ end (i.e. adjacent homecoming address) may end overwriting shellcode push instructions.

so, reply question. no, there no 'mechanism' separate shellcode 'its stack'. because there no stack per-se shellcode. remember, position independent code. must able run regardless of machine state. stack management needs happen must performed shellcode itself. why suggested sub $0x99, %esp @ begning of shellcode if have many push statements in code. alternative create sure there sufficient space between homecoming address (which %esp-4 pointing at) , shellcode.

assembly stack-overflow buffer-overflow shellcode

Django Foreign key. Access in template -



Django Foreign key. Access in template -

i larn django orm. how can photo in template?

def index(request): animal = animal.objects.all() homecoming render_to_response('animal.html', {'animal':animal,}, context_instance=requestcontext(request))

template:

{{ animal.name }} {{ animal.photo.all }}

but not working.

models:

class animal(models.model): name = models.charfield(max_length=255) class photo(models.model): photo = models.imagefield(upload_to='media/images') animal = models.foreignkey(animal)

you need read documentation on following relationships see how access related items.

in case, each animal has photo_set way list of photo objects belonging animal.

in template, do:

{{ animal.name }} {% image in animal.photo_set.all %} <img src="{{ picture.photo.url }}" /> {% endfor %}

django

ios - libtool failed with exit code 1 in Xcode 4.2 -



ios - libtool failed with exit code 1 in Xcode 4.2 -

i compile project, shows error:

libtool /users/trinstanchen/library/developer/xcode/deriveddata/iossocial-dedmezxegpbuqnfkhmbfrvtphyas/build/products/debug-iphonesimulator/libiossocial.a normal i386 cd "/users/trinstanchen/downloads/iossocial-develop copy/iossocial" setenv iphoneos_deployment_target 5.0 setenv path "/applications/xcode.app/contents/developer/platforms/iphonesimulator.platform/developer/usr/bin:/applications/xcode.app/contents/developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/libtool -static -arch_only i386 -syslibroot /applications/xcode.app/contents/developer/platforms/iphonesimulator.platform/developer/sdks/iphonesimulator6.0.sdk -l/users/trinstanchen/library/developer/xcode/deriveddata/iossocial-dedmezxegpbuqnfkhmbfrvtphyas/build/products/debug-iphonesimulator -filelist /users/trinstanchen/library/developer/xcode/deriveddata/iossocial-dedmezxegpbuqnfkhmbfrvtphyas/build/intermediates/iossocial.build/debug-iphonesimulator/iossocial.build/objects-normal/i386/iossocial.linkfilelist -objc -fno-objc-arc -framework coregraphics -framework sentestingkit -framework uikit -framework foundation -o /users/trinstanchen/library/developer/xcode/deriveddata/iossocial-dedmezxegpbuqnfkhmbfrvtphyas/build/products/debug-iphonesimulator/libiossocial.a

/applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/libtool: unknown alternative character `f' in: -fno-objc-arc usage: /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/libtool -static [-] file [...] [-filelist listfile[,dirname]] [-arch_only arch] [-saclt] usage: /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/libtool -dynamic [-] file [...] [-filelist listfile[,dirname]] [-arch_only arch] [-o output] [-install_name name] [-compatibility_version #] [-current_version #] [-seg1addr 0x#] [-segs_read_only_addr 0x#] [-segs_read_write_addr 0x#] [-seg_addr_table ] [-seg_addr_table_filename ] [-all_load] [-noall_load] command /applications/xcode.app/contents/developer/toolchains/xcodedefault.xctoolchain/usr/bin/libtool failed exit code 1

can give me help?

ios xcode

javascript - using Rangy.js to paste plain text without HTML tags -



javascript - using Rangy.js to paste plain text without HTML tags -

i tied search , search around here , google, not found solution simple via using rangy.js or native js.

if have simple formatted text re-create like..

<div> <b>copy me (all) : soufflé chupa chups</b><br> <p style="color:#f00;"> cotton fiber candy caramels </p> </div>

how can re-create , paste plain text (without styled text) contenteditable element ?

i dont care older ies. current firefox or chrome need work.

demo : http://jsfiddle.net/72r6j/

unfortunately you'll need hacky solution. i've described here:

http://stackoverflow.com/a/3554615/96100

here's helpful in-depth reply similar question ckeditor developer:

paste plain text contenteditable div & textarea (word/excel...)

javascript jquery contenteditable paste rangy

python - Using multiprocessing.Manager() with multiple users yields permission denied -



python - Using multiprocessing.Manager() with multiple users yields permission denied -

i have process running root needs spin threads off run various users. part working fine, need way communicate between kid processes , parent process.

when seek using multiprocessing.manager() lists, dictionary, lock, queue, etc, has permission denied errors on process has lowered permissions.

is there way grant access user or pid prepare this?

basic code represents i'm running (run root):

#!/usr/bin/env python import multiprocessing, os manager = multiprocessing.manager() problematic_list = manager.list() os.setuid(43121) # or whatever user problematic_list.append('anything')

result:

root@liberator:/home/bscable# python asd.py traceback (most recent phone call last): file "asd.py", line 8, in <module> problematic_list.append('anything') file "<string>", line 2, in append file "/usr/lib/python2.7/multiprocessing/managers.py", line 755, in _callmethod self._connect() file "/usr/lib/python2.7/multiprocessing/managers.py", line 742, in _connect conn = self._client(self._token.address, authkey=self._authkey) file "/usr/lib/python2.7/multiprocessing/connection.py", line 169, in client c = socketclient(address) file "/usr/lib/python2.7/multiprocessing/connection.py", line 293, in socketclient s.connect(address) file "/usr/lib/python2.7/socket.py", line 224, in meth homecoming getattr(self._sock,name)(*args) socket.error: [errno 13] permission denied traceback (most recent phone call last): file "/usr/lib/python2.7/multiprocessing/util.py", line 261, in _run_finalizers finalizer() file "/usr/lib/python2.7/multiprocessing/util.py", line 200, in __call__ res = self._callback(*self._args, **self._kwargs) file "/usr/lib/python2.7/multiprocessing/managers.py", line 625, in _finalize_manager process.terminate() file "/usr/lib/python2.7/multiprocessing/process.py", line 137, in terminate self._popen.terminate() file "/usr/lib/python2.7/multiprocessing/forking.py", line 165, in terminate os.kill(self.pid, signal.sigterm) oserror: [errno 1] operation not permitted

the first exception appears 1 of import here.

python (at to the lowest degree 2.6) uses unix socket communicate appears so:

/tmp/pymp-egnu6a/listener-bthj0e

we can grab path , alter permissions on so:

#!/usr/bin/env python import multiprocessing, os, grp, pwd manager = multiprocessing.manager() problematic_list = manager.list() fullname = manager._address dirname = os.path.dirname(fullname) gid = grp.getgrnam('some_group').gr_gid uid = pwd.getpwnam('root').pw_uid # should 0, never know os.chown(dirname, uid, gid) os.chmod(dirname, 0770) os.chown(fullname, uid, gid) os.chmod(fullname, 0770) os.setgid(gid) os.setuid(43121) # or whatever user problematic_list.append('anything')

python multithreading unix multiprocessing

performance - Meteor users and backbone very slow -



performance - Meteor users and backbone very slow -

i created project easy content sharing. can @ project here: sharingproject

you can utilize user@example.com 123456 password test site verified user. of course of study site has bugs yet...

i used meteor user bundle , backbone bundle navigate through pages. on localhost, there no problem. testing uploaded project meteor server. while logged in , navigating through pages, every time navigate new page app 'checks' user on client side because of url change. annoying...

of course of study navigate through pages calling session.set('page_id', ..) goal able send people url specific page on server.

the code similar 1 in todos illustration meteor page:

meteor.subscribe('pages', function () { if (!session.get('page_id')) { var page = pages.findone({}, {sort: {owner: -1}}); if (page) router.setpage(page._id); } }); ... var pagesrouter = backbone.router.extend({ routes: { ":page_id": "main" }, main: function (page_id) { session.set("page_id", page_id); }, setpage: function (page_id) { this.navigate(page_id, true); } }); router = new pagesrouter; meteor.startup(function () { backbone.history.start({pushstate: true}); });

why asking here: searched web , can't find same problem. either nobody tried before or there simple solution this?

edit: how phone call pages

<template name="pages"> {{#each pages}} <p><a href="/{{_id}}">{{title}}</a> {{#if isauthor}} <a class="delpage" href="javascript:delpage('{{_id}}')">delete</a> {{/if}} </p> {{/each}} </template>

i don't know how rendering page links link :

http://pagesharingproject.meteor.com/a1fbacba-0ddf-4077-a653-294b428bbfb8

should read like:

http://pagesharingproject.meteor.com/#a1fbacba-0ddf-4077-a653-294b428bbfb8

performance backbone.js meteor

c++ - How to link static library (of SOIL) to a project in visual studio 2010? -



c++ - How to link static library (of SOIL) to a project in visual studio 2010? -

this question has reply here:

what undefined reference/unresolved external symbol error , how prepare it? 23 answers

i need utilize soil lib @ project.

i've included @ source files director soil.h , libsoil.a (renamed libsoil.lib).

i've added header file headers existing item , include header file in header file need it.

i've tried: project properties > linker > input > additional dependencies , @ dropdown menu clicked on "< edit.. >" , typed libsoil.lib.

but getting these errors:

look below (updated errors)

what should do?

edit #1:

this doing:

#include "gl/glut.h" #include "soil.h"

i have both files @ source directory.

without code written soil build succeeds.

with code:

/* load image file straight new opengl texture */ gluint grass_texture = soil_load_ogl_texture ( "original.bmp", soil_load_auto, soil_create_new_id, soil_flag_mipmaps | soil_flag_invert_y | soil_flag_ntsc_safe_rgb | soil_flag_compress_to_dxt ); /* check error during load process */ if( 0 == grass_texture ) { printf( "soil loading error: '%s'\n", soil_last_result() ); }

i getting error:

error 1 error lnk2019: unresolved external symbol __alloca referenced in function _stbi_zlib_decode_noheader_buffer working_dir\libsoil.lib(stb_image_aug.o) projectname

error 2 error lnk2019: unresolved external symbol _sqrtf referenced in function _rgbe_to_rgbdiva2 working_dir\libsoil.lib(image_helper.o) projectname

error 3 error lnk1120: 2 unresolved externals working_dir\debug\projectname.exe projectname

i met same problem. solution go projects/vcx folder , compile solution myself, copied generated .lib file project. when compile solution, create sure take right platform(x86/x64). create sure path containing .lib file can found project.

c++ visual-studio-2010 opengl static-libraries soil

svn - Erase a Subversion Branch -



svn - Erase a Subversion Branch -

i assigned merge few branches trunk in subversion. project setup following.

trunk branches brancha branchb branchc tags // bunch of tags (1 per release)

the goal integrate brancha , branchb trunk , have them "hidden" somehow.

i think know how actual merge. right click trunk in windows explorer , tortoisesvn > merge... reintegrate branch, take branch, merge.

question 1 - right method use?

i unsure repository after this. want create sure no future developers mistakenly work on old branches.

question 2 - branch unworkable after merge, or need else? can "delete" branch? if so, happen branch history? or need hacky apply locks branch?

thanks help.

question 1 - right method use?

yes, merge contents of branch working directory. nil happen repository until commit (newly merged) trunk. 1 time commit not trunk changes in repo, remember merged in branch.

question 2 - branch unworkable after merge, or need else?

at point can delete branch or can maintain making changes branch. if maintain making changes branch , later merge, new stuff (not stuff merged) merged trunk.

if want delete branch, easiest way i've found open repo browser, right-click on branch , select "delete". branch disappear latest version. still in repo history , can bring if necessary, doing fresh checkout not see it.

svn merge tortoisesvn branch

python - backslash in Yaml string -



python - backslash in Yaml string -

this question has reply here:

why backslashes appear twice? 1 reply

so i'm using yaml configuration files , py yaml parse it. 1 field have like:

host: hostname\server,5858

but when gets parsed here get:

{ "host": "hostname\\server,5858" }

with 2 backslashes. tried every combination of single quotes, double quotes, etc. what's best way parse correctly ? thanks

len("\\") == 1. see representation of string python string literal. backslash has special meaning in python literal e.g., "\n" single character (a newline). literal backslash in string, should escaped "\\".

python yaml

c# - When passing a managed byte[] array through PInvoke to be filled in by Win32, does it need to be pinned? -



c# - When passing a managed byte[] array through PInvoke to be filled in by Win32, does it need to be pinned? -

suppose you're calling win32 function fill in byte array. create array of size 32, empty. pass in win32 function filled int, , utilize later in managed code. there exist chance byte array might moved or overwritten in between time allocated , filled in win32 function?

short answer: no, pinning not necessary in case

longer answer:

the clr automatically pin references managed objects when cross pinvoke boundary. pinvoke function exits reference unpinned. in situations having native function fill byte[] no manually pinning necessary because object used native code during function call.

manually pinning of array becomes necessary if native code caches managed pointer. when happens must manually pin array until native code no longer needs pointer. in case presume pointer not cached hence it's not necessary pin

reference - http://msdn.microsoft.com/en-us/magazine/cc163910.aspx#s2

c# .net visual-studio clr pinvoke

postgresql - Do I have to create a surrogate key if I want to save space? -



postgresql - Do I have to create a surrogate key if I want to save space? -

let's have big table owners of cars so:

ownership owner | auto --------------- steven | audi bernahrd | vw dieter | vw eike | vw robert | audi ... 1 hundred 1000000 rows ...

if refactor this:

ownership owner | auto <-foreign key type.car_type --------------- steven | audi bernahrd | vw dieter | vw eike | vw robert | audi ... type car_type | --------------- audi vw

do win spacewise or speedwise or need create integer surrogate key on car_type that?

using 2 tables , string foreign key of course of study utilize more space using one. how much more depends on how many types of cars have.

you should utilize integer car_id:

using integer keys save space if important percentage of auto names repeat.

more if you'd need index car column, integer index much smaller string index.

also comparing integers faster comparing strings, searching auto should faster.

smaller table means bigger part if fit in cache, accessing should faster.

postgresql foreign-keys

Wordpress parse error unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING -



Wordpress parse error unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING -

mates, 2 days ago, webhosting of site i'm administrating went down. seems working, when seek acces wp-admin recieve next error message:

parse error: syntax error, unexpected t_encapsed_and_whitespace, expecting t_string or t_variable or t_num_string in /home/ohmycut/public_html/wp-settings.php on line 80

these lines 75 85:

// include wpdb class and, if present, db.php database drop-in. require_wp_db(); // set database table prefix , format specifiers database table columns. $globals['table_prefix'] = $table_prefix; wp_set_wpdb_vars(); // start wordpress object cache, or external object cache if drop-in present. wp_start_object_cache();

i, honestly, don't understand why getting error. ideas?

thanks!

try contacting web hosting service see if can revert state before service went down.

wordpress

database - What do scale and precision mean when specifying a decimal field type in Doctrine 2? -



database - What do scale and precision mean when specifying a decimal field type in Doctrine 2? -

i'm creating decimal field hold financial figure in doctrine2 symfony2 application.

currently, looks this:

/** * @orm\column(type="decimal") */ protected $rate;

when entered value , said value persisted database, rounded integer. i'm guessing need set precision , scale types field, need explain do?

the doctrine2 documentation says:

precision: precision decimal (exact numeric) column (applies decimal column)

scale: scale decimal (exact numeric) column (applies decimal column)

but doesn't tell me awful lot.

i'm guessing precision number of decimal places round to, assume should 2, scale? scale important figures?

should field declaration this? :-

/** * @orm\column(type="decimal", precision=2, scale=4) */ protected $rate;

doctrine uses types similar sql types. decimal happens fixed precision type (unlike floats).

taken mysql documentation:

in decimal column declaration, precision , scale can (and is) specified; example:

salary decimal(5,2)

in example, 5 precision , 2 scale. precision represents number of important digits stored values, , scale represents number of digits can stored next decimal point.

standard sql requires decimal(5,2) able store value 5 digits , 2 decimals, values can stored in salary column range -999.99 999.99.

database symfony2 orm types doctrine2

constructor - PHP: Can I pass $this in the _constructor? -



constructor - PHP: Can I pass $this in the _constructor? -

i pass php object in own constructor object this:

class foo { $parent_object; public function __construct($obj) { $this->parent_object = $obj; } } class bar { public function __construct() { $blub = new foo($this); } }

the question asking myself is: can pass $this in constructor of bar, because object has not been created... $this valid reference whole object?

sure can. maintain in mind $this points current object though. in:

$blub = new foo($this);

$this points instance of bar. $obj in constructor of foo instance of bar.

$this available @ origin of constructor. if bar calls functions on $obj might instance of bar not yet in right state (ie. $blub has not been assigned). lead reference issues, solution move reference exchange out of constructor.

php constructor this

asp.net mvc - Html.BeginForm inside of Html.BeginForm MVC3 -



asp.net mvc - Html.BeginForm inside of Html.BeginForm MVC3 -

i have main view renders 2 partial views. main view encompasses both of partial views within form. each of partial views contain forms. 3 views share same viewmodel. want encapsulate info views main view, , run specific controller action results partial views.

i want know if possible. when debugging see content posts httppost of main views form. have submit buttons each of forms accordingly. sorry code post, coming out split up.

main view:

@using (html.beginform("main", "registration", formmethod.post, new { @class="mainform" })) { <form> <fieldset> <div id ="option1" class="conglomerate"> @html.partial("_getbusiness") </div> <div id ="option2" class="dealership"> @html.partial("_getlocation") </div> <button type="submit" value="create" class="buttonblue" id=""> <span>create new dealer</span> </button> </fieldset> </form>

partial 1

@using (html.beginform("createbusiness", "business", formmethod.post, new { @class="buisinessform" })) { <form> <div class="editor-field"> @html.dropdownlistfor(m =>m.businessid, new selectlist(model.businesses, "businessid", "businessname"), "") </div> <label>your company not listed? register yours below:</label> <div class="editor-label"> @html.labelfor(model => model.businessname) </div> <div class="editor-field"> @html.editorfor(model => model.businessname) @html.validationmessagefor(model => model.businessname) </div> <button type="button" value="" class="buttonblue"id="testsubmit"> <span>add dealer</span> </button> <div class ="confirm"> <button type="submit" value="create" class="buttonblue" id=""> <span>click here confirm dealer addition</span> </button> </div> </form> }

as dave mentions, not valid html nest forms. it's not html5, version of html.

it might work in browsers, in circumstances, never valid. , can never depend on happen if seem work. best course of study of action utilize multiple non-nested forms on page.

can explain why think need nested forms?

html asp.net-mvc asp.net-mvc-3 razor

c# - SQLite reference warning processor mismatch -



c# - SQLite reference warning processor mismatch -

i changed sql server sqlite, went fine, working fine, thing bothers me warning mismatch sqlite reference, below warning message:

warning 1 there mismatch between processor architecture of project beingness built "msil" , processor architecture of reference "system.data.sqlite, version=1.0.84.0, culture=neutral, publickeytoken=db937bc2d44ff139, processorarchitecture=x86", "x86". mismatch may cause runtime failures. please consider changing targeted processor architecture of project through configuration manager align processor architectures between project , references, or take dependency on references processor architecture matches targeted processor architecture of project. livepigeonclient

did install wrong reference? or need set target of application x86? because not want, have suggestions do, rid of warning?

thanks time!

if wish utilize ado.net connector, have specify architecture program. because assembly mixed mode assembly - contains native code - , cannot run under other architectures. if not specify architecture executable, runtime utilize 64-bit instance on 64-bit machines , referenced assembly not loadable.

c# winforms sqlite

ios - newViewController always with two nibs (iPhone & iPad) -



ios - newViewController always with two nibs (iPhone & iPad) -

i want set xcode universal apps, when create new viewcontroller videovc, must create 2 nib files like,

videovc_iphone

videovc_ipad

can 1 help me out. no guidelines. steps. thanks

you see templates folder within "/applications/xcode.app/contents/developer/platforms/iphoneos.platform/developer/library/xcode" here see file , project templates can edit or create new 1 if want to.

specific question, navigate folder "/applications/xcode.app/contents/developer/platforms/iphoneos.platform/developer/library/xcode/templates/file templates"

here can accomplish trying adding blank nib ipad in template view controller nib. have upload sample did, it's still work in progress create 2 nibs need.

[my custom template] http://www.saplogix.net/xcode_custom_template/twonibtemplate.zip extract , re-create within folder "~/library/developer/xcode/templates/file templates" note: create directory if it's not there.

todo: add together code load specific nib based on device done need add together that. work uiviewcontroller super class.

- (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil { if ([[uidevice currentdevice] userinterfaceidiom] == uiuserinterfaceidiomphone) { self = [super initwithnibname:nibnameornil bundle:nibbundleornil]; } else if ([[uidevice currentdevice] userinterfaceidiom] == uiuserinterfaceidiompad) { nsstring *_nibbundleornil = (nsstring *)(nibbundleornil != nil ? [nibnameornil stringbyappendingstring:@"_ipad"] : [nsstringfromclass([self class]) stringbyappendingstring:@"_ipad"]); self = [super initwithnibname:_nibbundleornil bundle:nibbundleornil]; } if (self) { // custom initialization } homecoming self; }

my template produce next entry u can utilize create controller 2 nibs.

iphone ios objective-c xcode ipad

ruby on rails - Backbone application: storing user settings -



ruby on rails - Backbone application: storing user settings -

i have been working on rails/backbone application. until now, time user made specific changes application (e.g. chose 1 view on others, used filters, customized info presented in view), store his/her choices rails session variables. using info these session variables ensured user's changes persist when page refreshes or when new instances of application used on same computer. case until user signs out, leads loss of session variables' info , default settings next time user logs in.

the received feedback users want changes persist if log out or if utilize different computers (e.g. default settings should replaced changes, long same user logged in). how should implement feature?

thank you!

agreed mischa, should save datas in database.

this exemple how simple add together preferences user:

class user < activerecord::base serialize :preferences end u = user.new u.preferences = { :view => {:controller => :dasboard, :action => :index}, :filters => { :users => { :order => :email :page => 1 :quantity_per_page => 20 } } }

make sure field's type in database "text"

ruby-on-rails ruby-on-rails-3 backbone.js

Can't run html on text string in JQuery tmpl -



Can't run html on text string in JQuery tmpl -

in jquery template in project, trying write out variable html string without encoding html. when output variable so:

${description}

it results in raw html string beingness outputted tags , so:

<p>text <b>bold</b> <i>italic</i></p>

but when seek turn markup real tags @ same exact place in code:

{{html $description}}

doesn't output anything!

i tried zillion ways of passing in variable, think there's going on in html routine i'm not getting.

thanks.

update:

here's how it's beingness called:

this.$el.attr('data-id', tmpldata.id). data('id', tmpldata.id).html($.tmpl(this.template, tmpldata));

where this.template template file , tmpldata json includes $description , other variables needed.

another update:

{{html '<p>string</p>'}}

does behave expected.

{{html $another_variable}}

fails produce output when $another_variable doesn't have html in it.

another update:

i tried:

${$item.html(description)}

and changed phone call template

this.$el.attr('data-id', tmpldata.id). data('id', tmpldata.id). html($.tmpl(this.template, tmpldata, { truncate: _.truncatestrip, html: _.html, }));

and wrote custom html routine pass through string unchanged recommended:

html: function(str) { homecoming str; }

but still no dice.

the reply is:

{{html description}}

i tried on, because left stray spaces within curly brackets, did not interpret properly.

:-(

jquery jquery-templates

r - Multiple filled.contour plots in one graph using with par(mfrow=c()) -



r - Multiple filled.contour plots in one graph using with par(mfrow=c()) -

i trying build graph consisting of 2-3 filled.contour plots next each other. color scale same plots, , 1 z value key plot. having difficulties par(mfrow=c(1,3))

example code:

x <- 1:5 y <- 1:5 z <- matrix(outer(x,y,"+"),nrow=5) filled.contour(x,y,z) filled.contour(x,y,z,color.palette=rainbow) z2 <- z z2[5,5] <- inf filled.contour(x,y,z2,col=rainbow(200),nlevels=200)

is possible stack 2-3 of these plots next each other 1 z value color key? can in gimp wondering if natively in r possible.

no not think possible in filled.contour.

although extensions have been written already. to found here, here , here , legend code here.

using codes produced:

r layout graph plot contour

c++ - How can I call a template's private constructor from a different template instantiation -



c++ - How can I call a template's private constructor from a different template instantiation -

for example:

template<class t> class myclass { public: template<class u> myclass<u> dosomething() { homecoming myclass<u>(); } //can't access private constructor private: myclass() {} }

template-voodoo answers , acceptable. what's of import me class can create , homecoming instances of different template parameters, external code cannot phone call particular constructor using.

add next in myclass

template<typename q> friend class myclass;

myclass<int> , myclass<float> resolve exclusively different classes. know nil of eachother, , can't access eachother's privates more 2 totally seperate classes. so, solution have every instantiation of myclass friend every other instantiation can see eachother's privates if same class.

c++ templates c++11

java - Converting CSV to JSON without ANT or Maven -



java - Converting CSV to JSON without ANT or Maven -

i trying convert csv file json format, have no thought ant or maven. have used apache poi. trying apache poi. there other way that?

and trying do, getting next error --java.lang.classnotfoundexception: org.openxmlformats.schemas.spreadsheetml.x2006.main.ctsheet

// start constructing json.

jsonobject json = new jsonobject(); jsonarray rows=new jsonarray(); ( iterator<org.apache.poi.ss.usermodel.row> rowsit = sheet.rowiterator(); rowsit.hasnext(); ) { org.apache.poi.ss.usermodel.row row = rowsit.next(); jsonobject jrow = new jsonobject(); // iterate through cells. jsonarray cells = new jsonarray(); ( iterator<cell> cellsit = row.celliterator(); cellsit.hasnext(); ) { cell cell = cellsit.next(); cells.put( cell.getstringcellvalue() ); } jrow.put( "cell", cells ); rows.put( jrow ); }

simple csv can converted json simple java coding follows

first load file using

bufferedreader.readline()

then utilize

string.split(",") // value each line

and write each value output using

bufferedwriter // necessary json braces , quoting

java javascript json apache-poi

ios - performSegueWithIdentifier:sender not working on device -



ios - performSegueWithIdentifier:sender not working on device -

i have storyboard has viewcontroller defaultviewcontroller neither uitabbarcontroller nor 'uinavigationcontroller`. decides whether upcoming controller should registration screen or home screen.

i have 2 segues originating it, 1 pointing uinavigationcontroller' registration while other moves 'uitabbarcontroller default home screen.

the defaultviewcontroller calls next in viewdidappear: method

nsstring *thecontroller = nil; if ([appstate sharedappstate].currentuserstate == registered) { thecontroller = @"homesegue"; } else { thecontroller = @"regsegue"; } [self performseguewithidentifier:thecontroller sender:self];

the segue performed on ios simulator 5.1.1 6.0. however, nil happens when run code on iphone ios 5.1.1 or iphone ios 6.0. view stays defaultviewcontrollers view.

edit created whole new project , works fine there when copied old storyboard contents , classes, issue re-appears.. !!

** edit 2 ** removed rootviewcontroller associated uinavigationcontroller , added simple uiviewcontroller label on , works fine. if add together custom registrationcontroller root controller, segue not performed.

p.s. custom registrationcontroller adds controller childviewcontroller in it.

strange .. very strage.. how got work.

the registrationcontroller part of navigationcontroller, created instance of reginfocontroller added both it's subview kid controller.

i overrid awakefromnib method of childcontroller , started working.

to confirm scenario, removed method , stopped working..

ios objective-c storyboard segue

php - Table row delete using jquery -



php - Table row delete using jquery -

i have made code remove table row :

jquery('tr#rowattend1').remove();

html :

three rows same id . illustration :

<tr id="rowattend1" ><td>ssss</td></tr> <tr id="rowattend1" ><td>ddddd</td></tr> <tr id="rowattend1" ><td>ccccc</td></tr>

but want 3 removed works fine in browsers except ie7 ? can help me?

<tr id="rowattend1" ><td>ssss</td></tr> <tr id="rowattend2" ><td>ddddd</td></tr> <tr id="rowattend3" ><td>ccccc</td></tr> $('#rowattend1,#rowattend2,#rowattend3').remove();

change ids unique ids , can remove table row

class example

<tr class="rowattend1" ><td>ssss</td></tr> <tr class="rowattend1" ><td>ddddd</td></tr> <tr class="rowattend1" ><td>ccccc</td></tr> $('.rowattend1').remove();

this remove elements class rowattend

php jquery

ios - Search function in iphone? -



ios - Search function in iphone? -

my array

{ "samsung tab", "samsung note", "samsung galaxy", "samsung galaxy pro", "nokia lumia", "nokia 5130", "sony xperia" }

some thing that. have text box type galaxy , click button. want show samsung galaxy , samsung galaxy pro in next list view. can help me?.

take 2 nsmutablearray , add 1 array array in viewdidload method such like,

self.listoftemarray = [[nsmutablearray alloc] init]; // array no - 1 self.itemofmainarray = [[nsmutablearray alloc] initwithobjects:@"yorarraylist", nil]; // array no - 2 [self.listoftemarray addobjectsfromarray:self.itemofmainarray]; // add together 2array 1 array

and write next delegate method of uisearchbar

- (bool) textfielddidchange:(uitextfield *)textfield { nsstring *name = @""; nsstring *firstletter = @""; if (self.listoftemarray.count > 0) [self.listoftemarray removeallobjects]; if ([searchtext length] > 0) { (int = 0; < [self.itemofmainarray count] ; = i+1) { name = [self.itemofmainarray objectatindex:i]; if (name.length >= searchtext.length) { firstletter = [name substringwithrange:nsmakerange(0, [searchtext length])]; //nslog(@"%@",firstletter); if( [firstletter caseinsensitivecompare:searchtext] == nsorderedsame ) { // strings equal except perchance case [self.listoftemarray addobject: [self.itemofmainarray objectatindex:i]]; nslog(@"=========> %@",self.listoftemarray); } } } } else { [self.listoftemarray addobjectsfromarray:self.itemofmainarray ]; } [self.tblview reloaddata]; }

}

output show in consol.

this code might helpful you...thanks :)

iphone ios

hibernate - JPA merge() best practise -



hibernate - JPA merge() best practise -

i implemented service entity object , uses pure jpa, used spring, in spring xml config configured hibernate jpa impl. using spring info crud operations. in our scheme our entity object beingness pulled/updated many times , there high contention(concurrency) data. our code in many places many classes inject service bean , phone call getentity method entity, after alter entity(which detached understanding, in same thread em object should same per knowledge) takes while entity comes service updated, phone call save() method of service save entity. save() method nil calls merge() crud operation. transactional @transactional annotation. here problem arises, when pulls entity object , while changing else might pull , alter , save back, entity read dirty , if save it, override updated entity. problem here changing entity outside of service , calling save back. here spring info repository classes dao layer.

optimistic lock 1 solution did not reasons, not work us. thinking pessimistic lock. example, when entity update locking, alter somewhere else in different place , phone call back(the entity locked against update!) work? not sure if still entitymanager object there used pulling entity. if there takes quite long time pass 'smart' logics before gets updated , unlocks it.

here simple illustration code scenario:

class someentity { long id; string field1; string field2; string field3; string field4; string field5; string field6; string field7; //getters , setters, column annotations } class someentityserviceimple implemenet someentityservice{ @transactional save(someentity se){ //call spring data's merge() method } get(long id){ //call spring data's findone() } } //this class might spring bean, might not be. if not someentityservice bean shared appcontext class somecrazyclass{ @autowired someentityservice service; somemethod(){ someentity e = service.get(1l); //do tons of logic here, alter entity object, phone call methods , again, takes 3 seond service.save(e); //probably detached , updated object, overriding it. } } }

here cannot move tons of logic within service layer, quite specific , kind of different logics in 100s of places.

so there way come around , @ to the lowest degree apply pessimistic lock situation?

thanks reading , answering .

for pessimistic locking, can seek below code

locking while fetching entity

entitymanager.find(entity.class, pk, lockmodetype.pessimistic_write);

applying lock afterwards

entitymanager.lock(entity, lockmodetype.pessimistic_write);

setting lock mode in query

query.setlockmode(lockmodetype.pessimistic_write);

else, can seek adding synchronized method in someentityserviceimpl.

public synchronized void saveentity(e){ { object o = get(id); //-- fetch recent entity applychanges(o, e); //-- applying custom changes save(o); //-- persisting entity }

therefore, don't have move logic within service, delegate database operations. also, mutual place code alterations without affecting application logic.

hibernate jpa concurrency locking pessimistic-locking

android - Ajax loading progress with run time data -



android - Ajax loading progress with run time data -

i working on phonegap project. using ajax request calls , working fine. want display dynamic info on loading ajax requests.sample image shown below. thanks.

android ajax cordova jquery-mobile

github - Git workflow (commit/push/ & create pull request) -



github - Git workflow (commit/push/ & create pull request) -

i have created branch master, made changes , ready commit , force remote master.

do first need commit changes local branch

git commit -m "new changes, etc."

then

git force

to force remote?

is first part correct?

then how create pull request?

before anything, should aware perform pull request, have work in branch separate desired branch. branches super lightweight in git, , should utilize them time. create , switch on new branch, first git branch <new branch name>, , check out using git checkout <new branch name>. new branch created based on current branch (so if going create new 1 want based on master, create sure switch master first).

to commit, need first add together files you'd commit staging area. git add together <filename>. if you'd add together files see when calling git status, can git add together ..

next can commit. prefer not add together message on command-line big changes, because have 1 screen showing me that's getting committed , isn't. think default editor vi, if don't sense comfortable vi, can specify editor through git config --global core.editor <your favorite editor>.

you're ready force github! it! git push

now you're ready set pull request. head github , find repo. nail pull request button. have 2 of import drop downs now. box on left target branch. box on right source branch. set left master, , right new branch. add together comment, review everything, nail send pull request. ba-bam.

check out link on github more info , handy screen shots: https://help.github.com/articles/creating-a-pull-request

git github

java - JAXB attribute with Object type throwing null pointer exception? -



java - JAXB attribute with Object type throwing null pointer exception? -

i trying annotate java class create jaxb schema element has attribute of value. code below:

@xmlattribute(name="value") public object getsettingvalue() { homecoming this.settingvalue; } public void setsettingvalue( final object settingvalue ) { this.settingvalue = settingvalue; }

when seek generate schema (using eclipse's non-moxy implementation), null pointer exception:

exception in thread "main" java.lang.nullpointerexception @ com.sun.xml.internal.bind.v2.runtime.reflect.transducedaccessor.get(transducedaccessor.java:154) @ com.sun.xml.internal.bind.v2.runtime.property.attributeproperty.<init>(attributeproperty.java:56) @ com.sun.xml.internal.bind.v2.runtime.property.propertyfactory.create(propertyfactory.java:93) @ com.sun.xml.internal.bind.v2.runtime.classbeaninfoimpl.<init>(classbeaninfoimpl.java:145) @ com.sun.xml.internal.bind.v2.runtime.jaxbcontextimpl.getorcreate(jaxbcontextimpl.java:479) @ com.sun.xml.internal.bind.v2.runtime.jaxbcontextimpl.<init>(jaxbcontextimpl.java:305) @ com.sun.xml.internal.bind.v2.runtime.jaxbcontextimpl$jaxbcontextbuilder.build(jaxbcontextimpl.java:1100) @ com.sun.xml.internal.bind.v2.contextfactory.createcontext(contextfactory.java:143) @ com.sun.xml.internal.bind.v2.contextfactory.createcontext(contextfactory.java:110) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:39) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:25) @ java.lang.reflect.method.invoke(method.java:597) @ javax.xml.bind.contextfinder.newinstance(contextfinder.java:202) @ javax.xml.bind.contextfinder.find(contextfinder.java:376) @ javax.xml.bind.jaxbcontext.newinstance(jaxbcontext.java:574) @ javax.xml.bind.jaxbcontext.newinstance(jaxbcontext.java:522) @ org.eclipse.jpt.jaxb.core.schemagen.main.buildjaxbcontext(main.java:95) @ org.eclipse.jpt.jaxb.core.schemagen.main.generate(main.java:76) @ org.eclipse.jpt.jaxb.core.schemagen.main.execute(main.java:62) @ org.eclipse.jpt.jaxb.core.schemagen.main.main(main.java:47)

when made @xmlelement instead of attribute, schema generated no issues, must have that. ideas?

the nullpointerexception seeing appears due bug in jaxb reference implementation. can come in bug using next link.

http://java.net/jira/browse/jaxb/

a similar exception not occur when using eclipselink jaxb (moxy) jaxb provider.

workaround

you alter property of type string instead. property of type object not round trip anyways unlike elements, attributes not have mechanisms include typing information.

when made @xmlelement instead of attribute, schema generated no issues, must have that.

java model (root)

object valid property type when mapped xml element.

import javax.xml.bind.annotation.xmlrootelement; @xmlrootelement public class root { private object settingvalue; public object getsettingvalue() { homecoming settingvalue; } public void setsettingvalue(final object settingvalue) { this.settingvalue = settingvalue; } }

this because xml element can contain typing info in form of xsi:type attribute.

class="lang-xml prettyprint-override"><?xml version="1.0" encoding="utf-8" standalone="yes"?> <root> <settingvalue xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xs="http://www.w3.org/2001/xmlschema" xsi:type="xs:int">123</settingvalue> </root>

java jaxb

php - Dynamic Facebook Like button -



php - Dynamic Facebook Like button -

i have various pages so:

www.mysite/directory/title?title=$title

so can see each page dynamic. has been asked many times before want have facebook buttons generated dynamic url. have notied there changes button @ end of lastly year , have been trying find recent posts this.

the problem have either facebook error states requires absolute url or refers button setup facebook, in case login page.

i have tried following:

// load sdk's source asynchronously // note debug version beingness actively developed , might // contain type checks overly strict. // please study such bugs using bugs tool. (function(d, debug){ var js, id = 'facebook-jssdk', ref = d.getelementsbytagname('script')[0]; if (d.getelementbyid(id)) {return;} js = d.createelement('script'); js.id = id; js.async = true; js.src = "//connect.facebook.net/en_us/all" + (debug ? "/debug" : "") + ".js"; ref.parentnode.insertbefore(js, ref); }(document, /*debug*/ false)); </script> <script type="text/javascript"> var surl = "http://www.mysite.com/"; document.getelementbyid('fb').setattribute('href', surl); </script> <div class="fb-like" id="fb" data-send="true" data-layout="button_count" data-width="60" data-show-faces="true"></div>

and:

<?php $url = basename($_server['request_uri']);?> <div class="fb-like" data-send="false" data-layout="button_count" data-width="450" data-show-faces="true"></div>

along with:

<div id="fb-root"></div><script src="http://connect.facebook.net/en_us/all.js#appid=186609524720286&amp;xfbml=1"></script> <div id="fblikeblock"></div> <script> var url = 'http://apps.facebook.com/inflatableicons/image_preview.html?y=120'; jquery("#fblikeblock").html('<fb:like id="fblike" href="'+url+'" send="true" width="450" show_faces="true" font=""></fb:like>'); fb.xfbml.parse(document.getelementbyid('fblikeblock')); console.log(document.getelementbyid('fblikeblock')); </script>

and not forgetting:

<fb:like></fb:like>

after invoking fb.xfbml.parse.

i having no success, can see have tried many methods , quite stuck. ideas?

thanks!

edited:

the url encoded, today tried next - still same result. everywhere have looked on stack states of these ways should working, getting nowhere:

<div class="fb-like" id="fb" data-href="<?php urlencode($url);?>" data-send="true" data-width="450" data-show-faces="true"></div>

any ideas?

use data-href url. https://developers.facebook.com/docs/reference/plugins/like/

php javascript facebook facebook-like

Delphi - Detect pressing 3 keys at the same time -



Delphi - Detect pressing 3 keys at the same time -

i want observe pressing 3 keys in form illustration ctrl+c+n...the typed form need observe begin ctrl , next come 2 letters.

how ?

on arrival of 1 of keys, can if other key has been down. e.g.:

procedure tform1.formkeydown(sender: tobject; var key: word; shift: tshiftstate); begin if shift = [ssctrl] begin case key of ord('c'): if (getkeystate(ord('n')) , $80) = $80 showmessage('combo'); ord('n'): if (getkeystate(ord('c')) , $80) = $80 showmessage('combo'); end; end; end;

however observe instance n+ctrl+c, sequence not begin ctrl key. if doesn't qualify valid key combination, can maintain bit of key history help of flag. next should observe sequences begins ctrl:

type tform1 = class(tform) procedure formkeydown(sender: tobject; var key: word; shift: tshiftstate); procedure formkeyup(sender: tobject; var key: word; shift: tshiftstate); private fvalidkeycombo: boolean; end; ... procedure tform1.formkeydown(sender: tobject; var key: word; shift: tshiftstate); begin if fvalidkeycombo , (shift = [ssctrl]) case key of ord('c'): if (getkeystate(ord('n')) , $80) = $80 showmessage('combo'); ord('n'): if (getkeystate(ord('c')) , $80) = $80 showmessage('combo'); end; fvalidkeycombo := (shift = [ssctrl]) , (key in [ord('c'), ord('n')]); end; procedure tform1.formkeyup(sender: tobject; var key: word; shift: tshiftstate); begin fvalidkeycombo := false; end;

delphi

javascript - jQuery code to ommit the top and bottom parts of iframe source -



javascript - jQuery code to ommit the top and bottom parts of iframe source -

basically have website retailer of bigger brands.

they want include brand's own catalog on brands website.

problem is, brand selling product on website, too.

is there way actively hide top parts (first 500px of height , lastly 300px of height) of webpage within iframe?

i've tried many methods either failed or got "unsafe" method errors such this:

unsafe javascript effort access frame url http://www.siteaddress.com/ frame url http://www.othersiteaddress.com/. domains, protocols , ports must match.

i don't want alter on website, want hide top , bottom parts. makes harder pages within iframe have different heights, way ommit first 500 px , lastly 300px of height. how, lastly few hours didn't help me find out.

is possible? help appreciated.

no. there fancy things try, easier scrape , interact brand's website on server side.

so no. no.

javascript jquery html iframe frame

version control - Changes in stable need to be in default -



version control - Changes in stable need to be in default -

i created stable accidentally changed file while working stable branch. committed , default (which development) doesn't have it. tried hg pull -r <changset> changeset latest commit.

what should do?

hg merge stable

this merge 2 together.

visit http://mercurial.selenic.com/guide/ , go merge named branch.

you don't have close it.

version-control mercurial

html - Cannot identify strange space between links in horizontal menu -



html - Cannot identify strange space between links in horizontal menu -

i'm creating simple horizontal menu. when hover item changes background color, lefts unusual 3px space on left side of link, , cannot identify why shows up, , how remove it.

menu here: http://pokerzysta.site44.com/ (linki, posty, forum, dodaj) thought what's wrong it?

thats because you're displaying list in horizontal manner display: inline-block;. rendered there white spaces html markup (most line-breaks after li-tags).

if set li-tags in html without white-space , line-breaks won't happen:

<ul id="main-menu" class="horizontal-list fleft"> <li><a href="#">linki</a></li><li><a href="#">posty</a></li><li><a href="#">forum</a></li><li><a href="#">dodaj</a><li> </ul>

@cimmanon pointed great article chris coyier displaying list navigations horizontally: http://css-tricks.com/fighting-the-space-between-inline-block-elements/

html css

Android - trying to save ArrayList into SharedPreferences as a JSON String using GSON - But filthy NullPointerException appears -



Android - trying to save ArrayList <String> into SharedPreferences as a JSON String using GSON - But filthy NullPointerException appears -

been @ while, can't seem see problem is.

i getting nullpointerexception when attempting save arraylist json, means skip ahead bottom marked.

i have used gson save object , json before, whole objects not arraylists..

relevant code:

private static final string shared_preferences = "shared_preferences"; // shared preferences containing json object of saved usernames sharedpreferences sharedpreferences; // saved usernames arraylist <string> savedusernames;

oncreate()...

// sharedpreferences sharedpreferences = this.getsharedpreferences(shared_preferences, context.mode_private);

attempting either way ensure savedusernames initialized something.

// if usernames saved, initialize savedusernames them or else initiliaze blank ready if (sharedpreferences.contains(saved_names)) { getsavedusernames(); } else { savedusernames = new arraylist<string>(); }

button listener saves current displayed username savedusernames arraylist

case r.id.bsaveusername: // add together textview text arraylist savedusernames.add(tvcurrentusername.gettext().tostring()); // addition, add together alter deletion changehasbeenmade = true; // toast feedback toast.maketext(mainscreen.this, "added list", toast.length_short).show(); break;

i have boolean goes true when each alter made. onpause()

// if there save, save if (changehasbeenmade) { toast.maketext(this, "success", toast.length_short).show(); saveusernames(); }

calling saveusernames() problem (line highlighted below)

// on pause, saveusernames private void saveusernames() { if (d) log.i(tag, "savedusernames() start"); /**** problem line ****/ string savingnamesjson = gson.tojson(savedusernames); /**** problem line ****/ // create editor, save json string , commits editor editor = sharedpreferences.edit(); editor.putstring(saved_names, savingnamesjson).commit(); if (d) log.i(tag, "savedusernames() end"); }

thanks lot time! appreciate it

android json arraylist sharedpreferences gson

Batch file: Open cmd, run VS Command Prompt, execute Makecert -



Batch file: Open cmd, run VS Command Prompt, execute Makecert -

i need in batch file:

open cmd run vs command prompt via cmd execute command "makecert -sv signroot.pvk -cy authorization -r sha1 -a -n \"cn=certificate\" -ss -sr localmachine certificate.cer"

so far, i've done 1 , 2, problem getting #3.

here's have far.

start cmd.exe /k "%comspec% /c "c:\program files (x86)\microsoft visual studio 10.0\vc\vcvarsall.bat" x86"

this i've done open qt 5.0.2 command prompt vs2012 setup , own batch file run:

c:\windows\system32\cmd.exe /a /q /k c:\qt\qt5.0.2\5.0.2\msvc2012_64\bin\qtenv2.bat & phone call "c:\program files (x86)\microsoft visual studio 11.0\vc\vcvarsall.bat" x64 & cd c:\tkbt\launch2.0.0 & phone call setupenvvars.bat

drops me in right spot environment variables set up.

so reply question append next phone call after "&"

batch-file cmd makecert

ruby on rails - Updating attributes through a different object -



ruby on rails - Updating attributes through a different object -

i having ridiculously hard time trying figure out how this. have been @ literally day.

i have business relationship class , transaction class. accounts created balance , want transaction amount, depending on type, either add together or subtract balance.

i want able update business relationship balance every time transaction created. personal finance application. of when create new transaction, nil happens business relationship balance.

accounts_controller.rb class accountscontroller < applicationcontroller def index @accounts = account.all end def show @account = account.find(params[:id]) end def new @account = account.new end def edit @account = account.find(params[:id]) end def create @account = account.new(params[:account]) respond_to |format| if @account.save format.html { redirect_to @account, notice: 'account created.' } format.json { render json: @account, status: :created, location: @account } else format.html { render action: "new" } format.json { render json: @account.errors, status: :unprocessable_entity } end end end def update @account = account.find(params[:id]) respond_to |format| if @account.update_attributes(params[:account]) format.html { redirect_to @account, notice: 'account updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @account.errors, status: :unprocessable_entity } end end end # delete /accounts/1 # delete /accounts/1.json def destroy @account = account.find(params[:id]) @account.destroy respond_to |format| format.html { redirect_to accounts_url } format.json { head :no_content } end end def update_balance @a = account.find(params[:id]) @a.transactions.each |t| @update_balance = t.t_type + @a.balance @a.update_attributes(:balance => @update_balance) end end end transactions_controller.rb class transactionscontroller < applicationcontroller def create @account = account.find(params[:account_id]) @transaction = @account.transactions.create(params[:transaction]) redirect_to account_path(@account) end end transaction.rb class transaction < activerecord::base belongs_to :account attr_accessible :amount, :category, :t_type end account.rb class business relationship < activerecord::base attr_accessible :balance, :name has_many :transactions end

if has thought i'm doing wrong or can point me in direction of thorough explanation, great. lost @ point.

try this.

class business relationship < activerecord::base attr_accessible :balance, :name has_many :transactions def update_with_transaction(transaction) homecoming unless self.transactions.include? transaction if transaction.t_type.eql? some_type self.balance += transaction.ammount else self.balance -= transaction.ammount end save end end class transactionscontroller < applicationcontroller def create business relationship = account.find(params[:account_id]) @transaction = account.transactions.create(params[:transaction]) account.update_with_transaction(@transaction) redirect_to account_path(account) end end

ruby-on-rails

CONCAT is not working in mysql stored procedure -



CONCAT is not working in mysql stored procedure -

drop procedure if exists cursor_test;# mysql returned empty result set (i.e. 0 rows). delimiter $$ create procedure cursor_test() begin declare project_number_val varchar( 255 ); declare project_list_val varchar(255); declare no_more_rows boolean; declare loop_cntr int default 0; declare num_rows int default 0; declare projects_cur cursor select project_id project_details; declare go on handler not found set no_more_rows = true; open projects_cur; select found_rows() num_rows; the_loop: loop fetch projects_cur project_number_val; if no_more_rows close projects_cur; leave the_loop; end if; set project_list_val=concat(`project_number_val`,'_list')

-

> ---> **please check doing concat right here?** insert test (panel_id) select panel_id project_list_val project_number_val='9'; > --->**is taking 9_list table name?** set loop_cntr = loop_cntr + 1; end loop the_loop; select num_rows, loop_cntr; end $$# mysql returned empty result set (i.e. 0 rows). delimiter

any suggestions? hi all,

i have variable in stored procedure named project_number , of varchar type.

my requirement "for each project number query table project_number_list results list , insert other table"

lets say, project_number might 22,21,34,43,434 corresponding tables need query 22_list, 21_list,34_list .....

i'm using cursor loop through project_number problem how mix project_number , _list i.e., 22_list query table 22_list

try :

set project_list_val=concat(project_number_val,'_list')

mysql stored-procedures

vba - How to select some selected Pivot table area? -



vba - How to select some selected Pivot table area? -

i trying select , re-create selected area of pivot table. able determine amount of area want , able display range in message box not objective. want re-create selected range. code looks this. want re-create values in range (toprow1,leftcoloumn:lastrow,rightcoloumn). fyi message box code don't need tell range no.

sub pivottablerangeareas() activesheet.pivottables(1) dim toprow1 long, toprow2 long, lastrow long dim leftcolumn long, rightcolumn long toprow2 = .tablerange2.row .tablerange1 toprow1 = .row lastrow = .rows.count + .row - 1 leftcolumn = .column rightcolumn = .columns.count + .column - 1 end msgbox "the pivot table named " & .name & vbcrlf & _ "occupies these range elements:" & vbcrlf & vbcrlf & _ "with study (page) field: " & vbcrlf & _ .tablerange2.address(0, 0) & vbcrlf & _ "without study (page) field: " & vbcrlf & _ .tablerange1.address(0, 0) & vbcrlf & vbcrlf & _ "first row, study (page) field: " & toprow2 & vbcrlf & _ "first row, without study (page) field: " & toprow1 & vbcrlf & _ "last row: " & lastrow & vbcrlf & _ "left column: " & leftcolumn & vbcrlf & _ "right column: " & rightcolumn, , "pivot table location." end end sub

i'm guessing it's values want copy? if so, seek starting - it'll set values sheet2 starting @ range a1. i'm not sure range pivot table want re-create - you'll have alter of suit:

sub copyrange() dim varray() variant 'copies values between (toprow1, leftcolumn) , (lastrow, rightcolumn) array varray = activesheet.range(cells(toprow1, leftcolumn), cells(lastrow, rightcolumn)).value 'pastes values array sheet2, starting @ a1 sheet2.range("a1").resize(ubound(varray, 1), ubound(varray, 2)).value = varray end sub

vba excel-vba