Posts

Showing posts from May, 2011

javascript - jQuery.when - Callback for when ALL Deferreds are no longer 'unresolved' (either resolved or rejected)? -

when multiple deferred objects passed jquery.when , method returns promise new "master" deferred object tracks aggregate state of deferreds has been passed. the method either resolve master deferred deferreds resolve, or reject master deferred 1 of deferreds rejected. if master deferred resolved (ie. deferreds resolve), passed resolved values of deferreds passed jquery.when. example, when deferreds jquery.ajax() requests, arguments jqxhr objects requests, in order given in argument list: $.when( $.getjson('foo'), $.getjson('bar') ).done(function(foo, bar) { // foo & bar jqxhr objects requests }); in multiple deferreds case 1 of deferreds rejected, jquery.when fires fail callbacks master deferred, if of deferreds may still unresolved @ point: $.when( $.getjson('foo'), $.getjson('bar') ).fail(function(req) { // req jqxhr object 1 of failed requests }); i need fire callback when deferreds passed jquery.when no ...

Closures javascript vs java -

i learning javascript , came across following code snippet: var outervalue = true; function outerfn(){ assert( outerfn && outervalue, "these come closure." ); } insofar understand closures in above context, allow outerfn see outervalue variable. my question is: how different other programming language - such java instance? expected outervalue's scope allow outerfn see it. added later on: var outervalue = true; function outerfn() { console.log(outervalue); } function anotherfunction(arg){ console.log("anotherfunction"); arg.call(this); } anotherfunction(outerfn); is better example of closure? your example not illustrate difference, not define scope of outervalue. in javascript, may nest functions arbitrarily within 1 another, , closures make sure inner functions can see outer functions when invoked after outer functions no longer in scope. in java, nesting functions not (yet)...

java - StaleObjectStateException on high frequency updates -

we're using hibernate 3.6.3.final , mysql 5.5.8 web application. backend running on jboss 6.0.0 final server. of time things work we're getting staleobjectstateexception. after while of experimenting figured out can reproduced sending requests backend high frequency (ie. clicking button triggers request fast possible). as far know exception means domain object got fetched database , when hibernate tried persist again noticed transaction changed in meantime. however far understand databases conflicting transactions should isolated extent prevents behavior. explicitly changed isolation level serializable guarantees repeatable reads , disabled hibernate caching. should prevent situation 1 transaction sees different versions of same domain object. the full stack trace is: 2011-04-28 20:46:17,865 warn [com.arjuna.ats.arjuna] (workerthread#2[127.0.0.1:57772]) arjuna-12125 twophasecoordinator.beforecompletion - failed synchronizationimple< 0:ffff7f000001:126a:4db9c...

.net assembly - I have trouble using mcc compiler in MATLAB (Error using ==> mcc The output directory does not exist) -

i'm trying build .net assembly file executing code in matlab2010b workdir = 'c:\users\h\documents\source code\matlabfiles'; outdir = fullfile(workdir, 'output'); dnetdir = fullfile(workdir, 'dotnet'); %% determine file names mfile = fullfile(workdir, 'perform.m'); dnetdll = fullfile(dnetdir, 'dotnet.dll'); %% create directories if needed if (exist(outdir, 'dir') ~= 7) mkdir(outdir); end if (exist(dnetdir, 'dir') ~= 7) mkdir(dnetdir); end %% build .net assembly eval(['mcc -n -d ' dnetdir ' -w ''dotnet:dotnet,' ... 'dotnetclass,0.0,private'' -t link:lib ' mfile]); i'm getting error. ??? error using ==> mcc output directory, 'c:\users\h\documents\project\thesis\source' not exist. i'm pretty sure it's because of space in directory path "...\source code\...". because if use path no spaces works fine. is there way make work? ...

android - How to show current Ringtone title for Alarm, Notification, VoiceCall, -

i use code, find more or less on here, return same answer: "default ringtone gleam", not. i show users sounds set for: alarm, system notification, voicecall, calendar notification, sms notification (did forgot some?) i tried use code: sharedpreferences prefsringtones = preferencemanager.getdefaultsharedpreferences(getbasecontext()); uri ringtoneuri = uri.parse(prefsringtones.getstring("ringtonepref","default_ringtone_uri")); ringtone ringtone = ringtonemanager.getringtone(this, ringtoneuri); string ringtonename = ringtone.gettitle(this); or intead default_ringtone_uri use default_alarm_alert_uri, default_notification_uri thank you, working. other working code: uri ringtoneuri = ringtonemanager.getdefaulturi(ringtonemanager.type_notification); ringtone ringtone = ringtonemanager.getringtone(this, ringtoneuri); string ringtonename = ringtone.gettitle(this);

c++ - Understanding code used to draw quads in OpenGL 3.3+ core using triangles -

i'm trying draw quad background (2d) using opengl 3.x+. quads deprecated, goal use 2 triangles make rectangle fills screen. it's working, i'm not 100% clear on here. setup gluint positionbufferobject; glfloat vertexpositions[] = { -1.0f, -1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f, }; glgenbuffers(1, &positionbufferobject); glbindbuffer(gl_array_buffer, positionbufferobject); glbufferdata(gl_array_buffer, sizeof(vertexpositions), vertexpositions, gl_static_draw); i understand vertexpositions , it's array of vertices. glgenbuffers() saying, want 1 buffer , assign id &positionbufferobject ? glbufferdata() uploads vertexpositions gpu's memory; how know upload since didn't give id? draw glenablevertexattribarray(0); glvertexattribpointer(0, 4, gl_float, gl_false, 0, 0); gldrawarrays(gl_triangle_strip, 0, 5); gldisablevertexattribarray(0)...

date - Looking for calendar data to import into SQL Server -

i want create calendar date table in sql server 2002 2011, minimally contain of dates each year, along whether each date week day or week-end day. any ideas on can find such data online? (or elsewhere)? how can import or generate such table? set datefirst 1 ;with cal ( select cast('20020101' datetime) dt union select dt+1 cal dt < cast('20111231' datetime) ) select dt [date], case datepart(dw, dt) when 6 1 when 7 1 else 0 end weekend cal option (maxrecursion 0)

.htaccess - How can we make use of query string in rewrite url using htaccess? -

actually have url abcd.html getting rewritten abcd.php using .htaccess=. now passing query string abcd.html?id=100 , rewrite abcd.php?id=100. how can that? rewriterule abcd.html\?id=(\d+) abcd.php?id=$1

java - Commons Daemon procrun stdout initialized -

i using tomcat 6, working fine, , getting “commons daemon procrun stdout initialized” on log, how can fix ?? it's not error. it's status log entry standard output logging of tool procrun daemon (that runs tomcat windows service) initialized.

Qt: How to display Ctrl+W instead of Ctrl+F4 in the default system menu of a subwindow? -

some quick needed, missing trick situation in qt (i use latest qt 4). within qmdiarea, create few subwindows. subwindows have default system menu attached (minimize, maximize, stay on top, close, ... - that's seen when right-clicking on subwindow icon). to consistent have defined in main menu of application (ctrl+w visible closing windows), i cannot accept displayed shortcut related close ctrl + f4 in subwindows' system menu. it has ctrl + w . have tried different things, including setting shortcut global application (with setshortcutcontext)... no luck. close has default 2 shortcuts: ctrl + w , ctrl + f4 . want both keep working, it's ctrl + w should displayed. for now, solution see replace system menu (a qmenu)... seem lot of code such simple task! you can try setting way: ui->mdiarea->subwindowlist().at(index)->systemmenu()->actions().last()->setshortcut(qkeysequence(qt::ctrl + qt::key_w)); please replace "index" suit...

javascript - How to show loading gif while iframe is loading up a website? -

i have inc/content.php file contains iframe src= domain. on index.php page have button <button id="nextbutton" onclick="viewnext();return false;">new</button> when clicked calls following javascript function: <script type="text/javascript"> function viewnext() { $('#content').load('inc/content.php'); } </script> function loads iframe inc/content.php file index.php page <div id="content"></div> how can show loading.gif image while inc/content.php file gets loaded index file? you can display loading image before loading page, , hide when done (use second parameter adding callback called when request has completed): $("#loading").show(); $("#content").load("inc/content.php", function () { $("#loading").hide(); }); obviously, need element in document id loading , like: <img id="loading" src="loading.gif...

System.OutOfMemoryException and a few exceptions happen during application run, Visual Studio 2010 WPF C# -

Image
i discovered problem today, , had no idea caused problem. project had been developed few months. i have project(solution), several projects in there, works if write , debug, pressing f5. the problem occur when press ctrl+f5 (to skip debug mode), or run directly double click exe, crashed. errors dialogs pop every times different, outofmemoryexception frequent one. i had checked make sure projects .net 3.5 i put messagebox.show("something") @ beginning of main project constructor, never reach. i use registry cleaner clean/fix registry, scan viruses. i had try read meaning of each error , exception, still no clue why happen. these series of screenshots if press ctrl + f5. (futuregenerator random name gave project.) series of screenshot if run app debug folder, futuregenerator.exe i suspect caused framework crashed during windows update, removed update performed recently, still same. exe file works on other non development pc, don't want r...

android - Retrieve checked radio button data and send to the another activity when button is pressed -

i have question: have 2 radio buttons imagebutton , 1 button. when click on imagebutton 1 want read value , send other activity, when press button how can ? please provide piece of code if possible package com.httpconnection; import java.io.bufferedinputstream; import java.io.inputstream; import java.net.url; import java.net.urlconnection; import org.apache.http.util.bytearraybuffer; import android.app.activity; import android.app.progressdialog; import android.content.intent; import android.os.asynctask; import android.os.bundle; import android.view.viewgroup.layoutparams; import android.widget.compoundbutton; import android.widget.compoundbutton.oncheckedchangelistener; import android.widget.linearlayout; import android.widget.radiobutton; import android.widget.textview; import android.widget.toast; public class httpconnectionactivity extends activity implements oncheckedchangelistener { /** called when activity first created. */ @override public voi...

How to print 2D Array from .txt file in Java -

import java.io.bufferedreader; import java.io.file; import java.io.filereader; import java.io.ioexception; import java.util.stringtokenizer; public class csvimport5 { public static void main(string[] args) throws ioexception { double [][] data = new double [87][2]; file file = new file("buydata.txt"); int row = 0; int col = 0; bufferedreader bufrdr = new bufferedreader(new filereader(file)); string line = null; //read each line of text file while((line = bufrdr.readline()) != null && row < data.length) { stringtokenizer st = new stringtokenizer(line,","); while (st.hasmoretokens()) { //get next token , store in array data[row][col] = double.parsedouble(st.nexttoken()); col++; } col = 0; row++; } system.out.println(" "+data[87][2]); } } ...

c# - EF4.1 - Attribute Evaluating to null at runtime -

i'm using ef4.1 code first create simple database app sql ce 4 backend. have product class , callitem class defined so: class callitem { public int id { get; set; } public float discount { get; set; } public virtual product product { get; set; } } class product { public int id { get; set; } public decimal basecost { get; set; } public int unitsize { get; set; } public bool iswasteoil { get; set; } public string code { get; set; } public string name { get; set; } public string description { get; set; } public string ingredients { get; set; } } edit - when creating collection of callitems using linq query, cannot access attributes of product attached each callitem, eg var callitems = ci in context.callitems select ci; foreach(callitem callitem in callitems) { runsheet nrs = new runsheet(); nrs.prodcode = callitem.product.code; } interrogating datab...

html - Is it possible to use javascript to detect if a screen reader is running on a users machine? -

i want detect whether screen reader running on user's machine avoid sound clashing audio tag in html. if so, please provide details on how done. you should not try special if detect screenreader running. if right 1 group of screenreader users, may wrong group. it's best concentrate on writing clean html5 in first place. note not screenreader users use text-to-speech; many use braille output. additionally, other types of accessibility tools - such content highlighters , voice input apps - use same techniques , apis (eg. dom, msaa) screenreaders do, technique "detects screenreader" detect these - cannot assume means user blind , using speech. as things stand, audio tag not universally accessible, different browsers have different levels of accessibility support - see html5 accessibility , scroll down audio more details of current support. i've seen pages add html5-based controls plus javascript after audio tag can provide own ui ensure keyboard or ...

symfony1 - Symfony doctrine , unique records -

i use symfony 1.4.11 doctrine.this 1 of tables: subscriptions: connection: doctrine tablename: subscriptions columns: user_id: { type: integer(4), primary: true } category_id: { type: integer(4), primary: true } relations: sfguarduser: { ondelete: cascade, local: user_id, foreign: id } categories: { ondelete: cascade, local: category_id, foreign: category_id } i need user_id table. i make : public function getsubscriptionsuser() { $q = $this->createquery('a') ->select ('a.user_id'); return $q-> execute(); } but if user subscribed several categories, id repeated several times. possible extract unique id of user? if user have id = 1 , , repeated 10 times,in result have "1" , no "1 1 1 1 1 1 1 1 1 1" :-) thank you! this should work out you: $q = $this->createquery('a') ->select ('distinct(a.user_id) user_id');

xml - Return Statement in Xquery -

i want change current return statement in xquery, : return <p>xml file stored successfully</p> i want make return statement capable of handling situation if there error, return error code user, if there no error, return message above user. i think if-else construct should placed under return purpose. have no idea condition should there if, experts little? in advance. the xquery 3.0 working draft introduces try-catch expressions, might looking for: declare namespace err = "http://www.w3.org/2005/xqt-errors"; let $x := "string" return try { $x cast xs:integer } catch * { $err:code (: variable contains error code :) }

Best collection for data in C# .NET -

i have store data: "al" => 1997 "ak" => 1977 ... "wy" => 1997 what's best way store in .net? shall use arrays, or arraylist, or collection? try system.collections.generic.dictionary<tkey, tvalue> . you use this: var values = new dictionary<string, int> { { "al", 1997 }, { "ak", 1977 }, ... { "wy", 1997 }, }; console.writeline(values["ak"]); // writes 1977

iphone - How to put settings into groups -

Image
i having issues settings bundle on iphone. want create groups shown in image below (measurement, data entry..etc.), can't work out how this. i have found 'item' type 'group' , know how create individual settings, can't figure out how put them group. you should have specify item0 (title = measurement, type = group) subsequent entries after (item1, item2, etc) added under group. can entered in plist editor of xcode. one thing note items add appear under group until specify new group. refer image attached.

c# - Decimal parse of exponential 0 value (0+E3) -

our middle tier sends serialized objects , 0, due math operations in java on server, come through 0e+3. when deserializing object xmlexception --> system.overflowexception because value large or small decimal. why can't decimal.parse handle conversion? is there way protect our client these numbers coming in way? you try: decimal.parse(numbertext, system.globalization.numberstyles.any) edit: this doesn't work 0e+3 unfortunately works: console.writeline(decimal.parse("0", system.globalization.numberstyles.any)); console.writeline(decimal.parse("123.45", system.globalization.numberstyles.any)); console.writeline(decimal.parse("1.35e+6", system.globalization.numberstyles.any)); console.writeline(decimal.parse("1.54e-5", system.globalization.numberstyles.any)); doesn't work: console.writeline(decimal.parse("0e+3", system.globalization.numberstyles.any)); is problem number 0e+3? if so, write h...

database - Open Graph traversal -

any ideas how solve query problem “give me names of foo:group objects friends have foo:join action on”? ( foo:group , foo:join open graph object , action, respectively.) might possible simple traversal get fb./me/friends/foo:join/groups?fields=name ? i noticing fql wouldn't recognize open graph actions, right i'm not coming other option query each friend separately — or in batches of 20 — makes job practically unfeasible. store actions on end whenever user joins group , join yourself. alternatively, can /me/friends , query every friend's /<id>/foo:join/groups . can use batch api speed up.

html5 - animating a shape created w/javascript/canvas -

i sort of new here , new javascript. trying learn how work javascript/html5/canvas. have been working way through several tutorials. have gone trough ones animating shape can not find 1 yet drawn shape reacts user input. mouse going on rectangle resulting in color change. or better this. http://dan.forys.co.uk/experiments/mesmerizer/ can 1 point me tutorial achieve that? thank daniela first clarify 1 thing, canvas doesn't know what's on it. can tell color pixel can't tell rectangle here or circle there. our purposed, consider canvas write-only. functionality exists in svg if want consider application, caveat canvas more universally supported. knowing what's under mouse relates application is. in example posted, developer took x , y position mouse event (using jquery) , did quick math calculate row , column in. apply saying, "cell (x, y) moused over, when next redraw consider that." canvas applications work following way: create...

javascript - Using an id to lin -

i have... html: <a href="#" class="link" id="1">link 1</a> <a href="#" class="link" id="2">link 2</a> <div id="page1" class="page">1</div> <div id="page2" class="page">2</div> javascript (jquery): $("a[class='link']").click(function() { var num = $("a[id]"); $('#page' + num).fadein(); }); what trying have specific div fade in when link clicked. if click link 1 id of "1" want div id #page1 fadein. $("a.link").click(function() { var num = $(this).attr("id"); $('#page' + num).fadein(); }); fyi: html ids start number technically not valid.

sql - How to use PIVOT clause over blank values -

sample data: data table1: prodid type location(there more columns, ignoring them example) p001 t1 l1 p002 t1 l2 p003 t3 l1 p004 t2 p005 t1 l1 need summary type blank [l1] [l2] t1 0 2 1 t2 1 0 0 t3 0 1 0 the problem facing blank values in location field. donno how represent blank location values in pivot query. pivot query: 1: select type, [] blank, [l1], [l2], blank + [l1] + [l2] total 2: (select type, location table1) 3: pivot 4: (count(location) location in ([],[l1],[l2]) t2 error on line 1 & 4 object or column name missing or empty. select statements, verify each column has name. other statements, empty alias names. aliases defined "" or [] not allowed. add name or single space alias name. how swapping out null/blank locations dummy value. change select type, location table1 to select type, case when l...

objective c - App stops receiving data from socket when UI scroll -

i have ipad app receives data using udp sockets. , has uiwebview browse webpages. while doing scroll in uiwebview, freezes , no data received. i've been searching , has runloops , threads. if uiwebview can't run in thread other main one, how can receive data while doing scroll? critical keep receiving data. the project uses asyncudpsocket class cocoa asyncsocket works quite well. , singleton class matt gallagher . running in main thread, udp reception , ui. thanks in advance! when scroll, runloop enters different mode ( uitrackingrunloopmode ) , stops responding network activity on main thread. done performance reasons. you should able schedule updates on proper runloop mode ( uitrackingrunloopmode believe). though, wouldn't recommend this. instead, try setting udp networking code on thread (or queue, yay gcd!) , schedule callbacks on main thread update ui. guarantee networking thread has proper runloop mode when getting data on socket.

python - Dbus/GLib Main Loop, Background Thread -

i'm starting out dbus , event driven programming in general. service i'm trying create consists of 3 parts 2 "server" things. 1) actual dbus server talks remote website on https, manages sessions, , conveys info clients. 2) other part of service calls keep alive page every 2 minutes keep session active on external website 3) clients make calls service retrieve info service. i found simple example programs. i'm trying adapt them prototype #1 , #2. rather building separate programs both. thought i can run them in single, 2 threaded process. the problem i'm seeing call time.sleep(x) in keep alive thread. thread goes sleep, won't ever wake up. think gil isn't released glib main loop. here's thread code: class keepalive(threading.thread): def __init__(self, interval=60): super(keepalive, self).__init__() self.interval = interval bus = dbus.sessionbus() self.remote = bus.get_object("com.example.sampleservice"...

image processing - OpenCV - Find skewed rectangle -

Image
i want draw "bounding box" around skewed rectangle. thought use cvminarearect2() function handles rotation, see image: is there function solve this? if not, ideas how implement it? compute both minarearect , convexhull. then, each of 4 points found minarearect, find corresponding nearest point in convex hull.

c# - .Net and Bitmap not automatically disposed by GC when there is no memory left -

i'm wondering how allocation , disposal of memory allocated bitmaps work in .net. when lot of bitmap creations in loops in function , call in succession work until @ point bitmap wont able allocate memory giving exception "invalid parameter" size specified. if call garbage collector while while works. with following code able repoduce error: class bitmapobject { public bool visible { { return enb; } set { enb = value; } } private bool enb; private bitmap bmp; public bitmapobject(int i, bool en) { enb = en; bmp = new bitmap(i, i); } } class pool<t> t : bitmapobject { list<t> preallocatedbitmaps = new list<t>(); public void fill() { random r = new random(); (int = 0; < 500; i++) { bitmapobject item = new bitmapobject(500, r.nextdouble() > 0.5); preallocatedbitmaps.add(item t); } } public ienumerable<t> objects { { foreach (t component in t...

c# - Does not contain definition or extension method -

i getting next error when try build: does not contain definition or extension method i have class this: [serializable] public class jobfile { private fileinfo mfileinfo; private string mjobnumber = string.empty; private string mbasejobnumber = string.empty; private guid mdocumenttytpeid = guid.empty; public string documenttypedescription { { string description; documenttype doctype; doctype = documenttype.getdoctype(documenttypecode); if (doctype.code == null) description = "unknown"; else description = doctype.description; return description; } } public guid documenttypeid { { documenttype doctype; doctype = documenttype.getdoctype(documenttypecode); if (doctyp...

select - Query within results from a previous query in MySQL -

how query within results have come previous mysql query? i want avoid nested selects if can, out of personal preference. store result of first query in temporary table , query that, drop temp table.

Powerflex Database File extentions -

i trying understand different file extensions pfxplus powerflex database. please telling me briefly each file for? .k1 .k2 .k3 ... .k13 .k14 .k15 .fd .def .hdr .prc .pc3 data files: ok, .dat data file. .k1 -> .k15 index files. these critical data files runtime. (combined filelist.cfg or pffiles.tab similar define files available overall). .fd file definition, needed compiling programs .tag (which did not mention) needed if need access field names @ run time (such using generic report tool) .def file definition in human readable form, , not needed process produced programmer or user can understand file structure. run time: the .ptc files compiled threads interpreted powerflex runtime. the .prc file resource file used @ runtime in conjunction .ptc file - defines how character based program in gui environment in "g-mode". cheap way upgrade character based programs when windows first started getting popular usage. .hdr , .pc3 escap...

Bind Menu To a List in ASP.NET -

how bind list asp.net menu control? try . this example how bind data menu control using asp.net.. can bind list same way this.... start ihierarcydata class store each string stringcollection... public class mymenuitem : ihierarchydata { public mymenuitem(string s) { item = s; } public override string tostring() { return item.tostring(); } #region ihierarchydata members public ihierarchicalenumerable getchildren() { return null; } public ihierarchydata getparent() { return null; } public bool haschildren { { return false; } } public object item { get; set; } public string path { { return string.empty; } } public string type { { return string.empty; } } #endregion } build class collection... public class mymenu : stringcollection, ihierarchicalenumerable { list<ihierarchydata> _lis...

bitmapdata - Some questions regarding Image manipulation in Flex -

here's want do. image loaded default when app run. there way load image user wants specifying url. when user defined image loaded, default image still in background , there method used apply filters on image whole (i mean resultant image both default , user loaded image blended) , want save final image jpg or png. now, still beginner @ flex, , getting confused canvas, image control, bitmapdata etc. want what's best way implement want? should load default image image url/embed or should load bitmapdata, how load second user defined image? whats best way blend 2 images? you can leave default image embedded one, , retrieve bitmapdata work further. when user-defined image loaded, retrieve bitmapdata , , draw embedded image on user-defined one: /** * embedded image's class (your default image) */ [embed(source="/assets/logo.png")] public static var logo:class; /** * @param bitmapdata: user-defined bitmapdata want modify * @param matrix: transof...

java - NO_MODIFICATION_ALLOWED_ERR: An attempt is made to modify an object where modifications are not allowed -

hello getting no modification allowed when trying add new node xml file , not sure why because using same code file , works fine, here code: public void addstockitem(string itemstr, int qty){ string path = system.getproperty("user.dir") + "/src/stock.xml"; try { documentbuilderfactory docfactory = documentbuilderfactory.newinstance(); docfactory.setignoringelementcontentwhitespace(true); documentbuilder docbuilder; docbuilder = docfactory.newdocumentbuilder(); document doc = docbuilder.parse(path); node root = doc.getfirstchild(); node item = doc.createelement("item"); item.settextcontent(itemstr); namednodemap itemattr = item.getattributes(); attr qtyattr = doc.createattribute("quantity"); qtyattr.settextcontent(qty+""); itemattr.setnameditem(qtyattr); root.appendchild(item); transformer transformer ...

RVM doesn't set correct gem path -

on clean os x snow leopard install, have problem rvm: sets ruby path correctly doesn't set gem path. when start rails server, mixes versions doesn't work. to illustrate: $ rvm system $ ruby /usr/bin/ruby $ rails /usr/bin/rails $ rvm use 1.9.2-head using /users/m/.rvm/gems/ruby-1.9.2-head $ rvm gem list local gems [...] rails (3.0.7) [...] $ ruby /users/m/.rvm/rubies/ruby-1.9.2-head/bin/ruby $ rails /usr/bin/rails any ideas might wrong? some additional info: $ echo $gem_path /users/m/.rvm/gems/ruby-1.9.2-p180:/users/m/.rvm/gems/ruby-1.9.2-p180@global $ echo $path /users/m/.rvm/gems/ruby-1.9.2-p180/bin:/users/m/.rvm/gems/ruby-1.9.2p180@global/bin:/users/m/.rvm/rubies/ruby-1.9.2p180/bin:/users/m/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/x11/bin so after 1 1/2 days of torture, reading through @ least 50 post, , installing rvm / ruby / rails @ least 15 different times...

php - session username match to -

so when logged on user posts comment on webpage, automatically posts username next comment. using <? echo $rows['a_name']; ?> i want create edit link appear on posts logged in user has created. in other words want match <? echo $rows['a_name']; ?> $_session=['username'] username , if match - display edit link -... if not, hide edit link. any help, examples, ideas? <?php if($rows['a_name']===$_session['username']) { ?> <!-- edit link here --> <?php } ?>

is it possible to enable the public to upload photos to a gallery on facebook? -

im sorry if sounds silly question cant seem find relevant information anywhere! my question is, possible through use of app or setting within facebook, allow public or fans of fanpage upload photos specific gallery within fanpage? thank in advance yes, possible. follow these instructions: goto facebook page's admin panel > edit page > manage persmisisons > posting ability > checkbox "everyone can add photos , videos [your page's] timeline. there options directly above , below one, allowing users tagging ability , posting visibility. as far uploaded directly particular album, not possible without assigning admin roles.

android send sms, why this will fail? -

to send sms wrote below code: package com.sendsms; import android.app.activity; import android.app.pendingintent; import android.content.intent; import android.os.bundle; import android.telephony.smsmanager; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; public class sendsmsactivity extends activity { /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); button new_btn = (button)findviewbyid(r.id.send_btn); new_btn.setonclicklistener(new onclicklistener(){ @override public void onclick(view v) { smsmanager sms = smsmanager.getdefault(); sms.sendtextmessage("+8615959762862", null, "i love you", null, null); } }); } } the stack: isms$stub$proxy.sendtext(string, strin...

xml - Substituting text in a file with Ruby -

i need read in file in xml format crammed single line, , need parse line find specific property , replace value have specified. the file might contain: <?xml version="1.0" encoding="utf-8" standalone="no"?><verificationpoint type="screenshot" version="2"><description/><verification object=":qp1b11_qlabel" type="png"> i need search through line, find property "verification object=" , replace :qp1b11 own string. please not don't want replace _qlabel" type="png"> part of string if possible. i can't use sub don't value of property anything, , believe should able regular expressions have never had use them before , examples i've seen make me more confused earlier. if can present me elegant answer (and explanation if using regexp) huge help! thanks you have xml use xml parser. nokogiri make short work of that: doc = nokogiri::...

Where can I find the 'official' libmcrypt.dll and php_mcrypt.dll for PHP 5.3 on Windows? -

background: running windows 7 iis express configured use php 5.3 , need load mcrypt module. can't find files need. i installed php 5.2. iis express , includes both mcrypt files, not compatible php 5.3, since switched vc6 vc9 between 5.2 , 5.3. there packaged distributions of php including apache etc. wrapped in installers, , need these 2 files. where can find files? from documentation , states that: php 5.3 windows binaries uses static version of mcrypt library, no dll needed. you should able verify running phpinfo , tell if mcrypt loaded. make sure mcrypt commented out if copied older php.ini file.

html - How does CSS Media Query work exactly? -

let's have 2 different css files (desktop.css , ipad.css) being applied same html page. i have pseudo div defined follows ( in desktop.css ) div.someclass{float:left;overflow:hidden;height:100px} now @ lower screen size (user resizes browser ipad size) , ipad.css gets applied. question is, effect of properties defined in desktop.css still remain or wiped out , ipad.css properties applied.. like in ipad.css, if want have overflow:visible (i.e. default overflow value), need explicityly specify or if define follows in ipad.css div.someclass{float:left;height:100px} it automatically apply default overflow:visible value div ? @testndtv; have write overflow:visible in ipad.css because media query detect screen resolution & active css according screen resolution . that's why can override our ipad.css property activate one. so, ipad.css write this: div.someclass{float:left;overflow:visible;height:100px}

php - Capture newline from a textarea input -

i have textarea form in html. if user hits enter between 2 sentences data should carried on php. currently if user enters: apple google ms and php code is: $str = $_post["field"]; echo $str; i apple google ms as output. want output this apple google ms what should do? try nl2br() instead: echo nl2br($str);

strange problems with C++ exceptions with mingw -

i have encountered strange problems exceptions using mingw , managed cut down following example: #include <iostream> #include <fstream> #include <cstdlib> using namespace std; void test(int a) { if (a < 0) { throw std::ios_base::failure("a < 0"); } } void test_file(std::string const & fname) { std::ifstream inf(fname.c_str(), std::fstream::in); if (!inf) { cout << "file error -> throwing exception" << endl; throw ios_base::failure("could not open input file '" + fname + "'"); } } int main() { try { test(-5); } catch(std::exception& e) { cerr << "exception caught: " << e.what() << " .. continue anyway" <<endl; } try { test_file("file-that-does-not-exist"); } catch(std::exception& e) { cerr << "exception caught: " << e.what() ...

Android listview adapter issue -

i have little problem listview adapter. i'm using lazy loading list view application, populate database. problem have data 2 different tables. here little code i'm using : string sqlquery = "select categoryid, collectionid, objectid, title cards collectionid="+collid; cursor cursor = userdbhelper.executesqlquery(sqlquery); string sqlquery2 = "select objectid, title categories"; cursor cursorcat = userdbhelper.executesqlquery(sqlquery2); cursorcat.movetofirst(); if(cursor.getcount()==0 && cursorcat.getcount()==0){ log.i("no thumbnails","there no cards or thumbnails."); cursor.close(); cursorcat.close(); } else if(cursor.getcount()>0 && cursorcat.getcount()>0){ for(cursor.move(0); cursor.movetonext(); cursor.isafterlast()){ title = cursor.getstring(cursor.getcolumnindex("title")); log.v("title","title : ...

windows - When to use \\.\c: and when to use c:? -

if symbolic link created device1 \\??\device (kernel),when accessing it,should \\.\device (user space),why? the symbolic c: should \\.\c: ,why \\. can omitted? windows supports 2 forms of file names. there files names follow windows naming convention (:\) , don't (\device\harddisk0\partition5...). "\\.\" prefix applied files don't fit within windows naming convention. internally windows supports object namespace names originate @ same root object. win32 api convert between windows naming convention , internal naming convention when can. however if need access file name not meet internal naming convention, can use "\\.\" prefix bypass name conversion logic. note drive letters not match windows naming convention (they don't have \ after drive letter) need use \\.\ form open drive. there's bunch of scaffolding make work, can see of winobj tool. in particular notice global??\ namespace - note global??\c: symbolic link maps ...

coding style - The most Pythonic way of checking if a value in a dictionary is defined/has zero length -

say have dictionary, , want check if key mapped nonempty value. 1 way of doing len function: mydict = {"key" : "value", "emptykey" : ""} print "true" if len(mydict["key"]) > 0 else "false" # prints true print "true" if len(mydict["emptykey"]) > 0 else "false" # prints false however, 1 can rely on semantics of python , how if object defined evaluates true , leave out len call: mydict = {"key" : "value", "emptykey" : ""} print "true" if mydict["key"] else "false" # prints true print "true" if mydict["emptykey"] else "false" # prints false however, i'm not sure more pythonic. first feels "explicit better implicit", second feels "simple better complex". i wonder if leaving out len call bite me dict i'm working doesn't contain strings, c...

sql server 2008 - Grouping stored procedure's result -

hi have next store procedure `use [bd_ssegua] go / * object: storedprocedure [dbo].[spagendadesolicitudes] script date: 10/14/2011 16:43:00 * / set ansi_nulls on go set quoted_identifier on go -- ============================================= -- author: roque ramírez nájera -- create date: 23/03/2011 -- description: genera tabla de solicitudes -- por estatus y año -- spagendadesolicitudes '2010' -- ============================================= alter procedure [dbo].[spagendadesolicitudes] @anio varchar(5) declare @contr int, @contra int, @contrz int, @contb int, @contc int, @total int declare @agenda table ( periodo datetime, r int, int, rz int, b int, c int, total int) begin set nocount on; select @contr = count (fiidsolicitud) solicitud fiedosolicitud = 1 , fianiosolicitud = @anio select @contra = count (fiidsolicitud) solicitud fiedoso...

Generating millions of non-repeating random numbers in Java -

i have question, algorithm can use generate set of 2^21 random unique numbers in java? there library in java generates random numbers aside math.random? thanks in advance! take @ apache commons math api's random pacakge http://commons.apache.org/math/userguide/random.html

python - append two data frame with pandas -

when try merge 2 dataframes rows doing: bigdata = data1.append(data2) i following error: exception: index cannot contain duplicate values! the index of first data frame starts 0 38 , second 1 0 48. didn't understand have modify index of 1 of data frame before merging, don't know how to. thank you. these 2 dataframes: data1 : meta particle ratio area type 0 2 part10 1.348 0.8365 touching 1 2 part18 1.558 0.8244 single 2 2 part2 1.893 0.894 single 3 2 part37 0.6695 1.005 single ....clip... 36 2 part23 1.051 0.8781 single 37 2 part3 80.54 0.9714 nuclei 38 2 part34 1.071 0.9337 single data2 : meta particle ratio area type 0 3 part10 0.4756 1.025 single 1 3 part18 0.04387 1.232 dusts 2 3 part2 1.132 0.8927 single ...clip... 46 3 part46 13.71 1.001 nuclei 47 3 part3 ...

android - Memory retained by Fragment -

when call popbackstack like: manager.popbackstack("mybackstack", fragmentmanager.pop_back_stack_inclusive); will memory retained fragments belongs "mybackstack" freed? i have fragmentactivity manages listfragment . every time click on item, fragmentactivity instantiates new fragment shows information item clicked , shows dialogfragment bitmap (that recycle when dialog dismissed). put android:configchanges="orientation" in manifest , override onconfigurationchanged necessary. yes, memory retained fragments freed. documentation, public static final int pop_back_stack_inclusive flag popbackstack(string, int) , popbackstack(int, int) : if set, , name or id of stack entry has been supplied, matching entries consumed until 1 doesn't match found or bottom of stack reached. otherwise, entries not including entry removed. and, public abstract void popbackstack (string name, int flags) pop last fragm...

SWT, TypedEvent: how to make use of the time variable -

the typedevent class has member variable time . want use discard old events. unfortunately, of type int system.currenttimemillis() returns long , both different, when masking them 0xffffffffl javadoc of time telling me. how should time interpreted? note: haven't mentioned operating system therefore safely assuming windows (because have got). answer if closely @ org.eclipse.swt.widgets.widget class find typedevent.time initialized follows: event.time = display.getlasteventtime (); which in return calls: os.getmessagetime (); now, swt directly works os widgets therefore on windows machine call os.getmessagetime (); directly translates windows getmessagetime api. check getmessagetime on msdn . per page: retrieves message time last message retrieved getmessage function. time long integer specifies elapsed time, in milliseconds, time system started time message created (that is, placed in thread's message queue). pay speci...

javascript - Append Django template tag with Jquery -

i want build menu can set 1 link highlighted using {% block %} tag. have in javascript: <loop> $('#a-div').append('{% block ' + variable + ' %} <a href...</a> {% endblock %}') <endloop> in source, displayed "{% block home %}" how can make jquery not append string template tag? you can't. @ least not without making ajax request django template. in case, slow , make unnecessary requests. it's not worth it. can insert snippets django templates via jquery using, example, jquery load function. can't replace specific {% block %} tag, because time jquery runs, template has been processed (and references block tags removed). not situation should doing in case. why don't rather highlight menu css class? here usual solution problem: create file called base_extras.py in 1 of templatetags folders. if don't have one, create 1 in appropriate folder. inside base_extras.py , paste code: from djang...

java - I have 9 JButtons in the ArrayList . But I am not able to change the Lable of the Buttons in any event,,, -

import java.awt.dimension; import java.awt.flowlayout; import java.awt.panel; import java.awt.event.actionevent; import java.awt.event.actionlistener; import java.util.arraylist; import javax.swing.jbutton; import javax.swing.jframe; import javax.swing.joptionpane; class 1 implements actionlistener { jframe frame = new jframe(); arraylist<jbutton> myb = new arraylist<jbutton>(); panel p = new panel(); dimension d = new dimension(20, 20); string s = "", s1 = ""; jbutton b = new jbutton(), b1 = new jbutton(); public void addbuttons() { for(int = 0; < 9; i++) { myb.add(new jbutton()); //imp } } public void display() { frame.getcontentpane().add(p); for(jbutton btn : myb) { btn.setpreferredsize(d); p.add(btn); //imp } p.setlayout(new flowlayout(flowlayout.center, 20, 5)); frame.setde...