Posts

Showing posts from April, 2012

Rails Devise: Don't check password salt when authenticating -

i'm migrating php site on rails using devise authentication method. old site uses md5(salt + password) authenticate users wrote custom devise encryptor such: module devise module encryptors class md5 < base def self.digest(password, stretches, pepper) digest::md5.hexdigest(password + 'the_salt_value') end end end end when create new user on new site password "password", hashed password matches user on old site password "password", good. however, values in password_salt column, purpose i'm unclear on, different , user on old site can't login "password" when migrate database over. what's best way deal problem? there way make devise compare values in encrypted_password column when authenticating?

internet explorer - jboss binding address -

i using mac , test java application on latest ie version, need remote login 1 of our windows server. so starting jboss locally binding address machine name like.. run.sh -b mymachine-00621323 after login remote server , ping machine name, getting proper reply. ping mymachine-00621323.corp.company.com pinging mymachine-00621323.corp.company.com [10.138.1.116] 32 bytes of data: reply 10.138.2.116: bytes=32 time=34ms ttl=61 reply 10.138.2.116: bytes=32 time=2ms ttl=61 reply 10.138.2.116: bytes=32 time=2ms ttl=61 reply 10.138.2.116: bytes=32 time=104ms ttl=61 ping statistics 10.238.6.116: packets: sent = 4, received = 4, lost = 0 (0% loss), approximate round trip times in milli-seconds: minimum = 2ms, maximum = 104ms, average = 35ms however, if hit below url ie same remote desktop server, not display page. http://mymachine-00621323.corp.company.com:8080/abc/login.xhtml in ie under tools--internet options--securitytab, tried adding list of trusted sites , ensured...

.net - Creating a generic list of a generic type -

i trying create list of generic type in vb.net 2.0 framework. generic type definition: ---------- public class genericparammap(of t) public sub new(byval pparamname string, byval ppropvalue t) mparamname = pparamname mpropvalue = ppropvalue end sub public property paramname() string return mparamname end set(byval value string) mparamname = value end set end property private mparamname string public property propvalue() t return mpropvalue end set(byval value t) mpropvalue = value end set end property private mpropvalue t end class ---------- and here method use list of genericparammap passed in parameter: public sub populateparammap(byval pmap list(of genericparammap(of t)) pmap.add(new genericparammap(of integer)("@region_id", regionid)) pmap.add(new genericparammap(of string)("@bus_addr1", busaddress1)) pma...

How to avoid echoing character 65279 in php? (This question also relates to Javascript xmlhttp.responseText (ajax)) -

i have encountered similar problem described here (and in other places) - on ajax callback xmlhttp.responsetext seems ok (when alert - shows right text) - when using 'if' statement compare string - returns false. (i 1 wrote server-side code returning string) - after studying string - i've discovered string had "invisible character" first character. character not shown. if copied notepad - deleted first character - won't delete until pressing delete again. i did charcodeat(0) returned string in xmlhttp.responsetext. , returned 65279 . googling reveals sort of utf-8 control character supposed set "big-endian" or "small-endian" encoding. so, know cause of problem - but... why character being echoed? in source php use echo 'the string'... and apparently somehow outputs [chr(65279)]the string... why? , how can avoid it? to conclude, , specify solution: windows notepad adds bom character (the 3 bytes: ef bb ...

How do you convert C++ _tcscpy, _tcscat to Delphi? -

i'm converting this code c++ delphi don't following part of code. can explain me following code means; what's happening szbuff buffer ? i'm pretty sure it's such kind of formatting (replacement), don't know expected result , can't find sensible documentation of used functions (maybe i'm lame :) can me translation of code delphi (or direct me proper documentation) ? i don't how convert kind of questions myself, mentioned @ least function names in question title might searchable else in future. function tsecinfo.buildsecurityattributes(var secattrs: tsecurityattributes): boolean; var pszsiduser: pchar; szbuff: array [0..1024] of char; begin // pszsiduser @ time contains user sid // s-1-5-21-1454471165-1004336348-1606980848-5555 // tchar szbuff[1024]; // i'm not sure array [0..1024] of char; _tcscpy(szbuff, _t("d:")); _tcscat(szbuff, _t("(a;;ga;;;")); _tcscat(szbuff, pszsiduser); _tcscat(szbuff, _t(...

68000 - Help with 68k assembly - jump tables? -

i'm working on reverse engineering large amiga program in ida, , i've made ton of progress. however, there stuff can't quite figure out. namely, have found several subroutines use believe "jump tables" - can't quite figure out how work. have advice? moveq #0,d0 move.b d7,d0 ; set d0 byte ctrl subq.w #1,d0 ; subtract 1 blt.w finish_29aba ; if d0 less 1, branch cmpi.w #$16,d0 bge.w finish_29aba ; if d0 greater or equal 16, branch add.w d0,d0 ; otherwise, double d0 move.w dword_29918(pc,d0.w),d0 jmp dword_29918+2(pc,d0.w) ; --------------------------------------------------------------------------- dword_29918: dc.l $400036 ; code xref: serialctrlcmd+e0j dc.l $360036 dc.l $3601a0 dc.l $3601a0 dc.l $1a001a0 dc.l $360040 dc.l $2a01a0 dc.l $400036 dc.l $3601a0 dc.l $1a00036...

sql server - SQL INSERT @tableVar SELECT ... is only insert -

i need fill dataset values several tables. i've created stored procedure executes several select statements. each select has common parts. i decided cache results of these common parts. now need select construct capable of outputting results table variable. insert @tablevar select ... inserts data not select it. my intention select * output selected.* @tablevar ... is possible perform such operation? insert @tablevar output inserted.* select * [...]

javascript - How do i have a Dojo checkbox run a command? -

i setting checkboxes enable/disable layers have on google earth project using dojo. understand how create checkboxes, , select , deselect them. how use these values, pass particular function. instance, have function can run in script, turn on borders on google earth, if marked true. have set if box checked, on, otherwise, uncheck turn off borders. here command turn them on: ge.getlayerroot().enablelayerbyid(ge.layer_borders, true) here code using showing checkbox in body of page: <input id="bordercheck" name="bordercheck" dojotype="dijit.form.checkbox" value="on" checked /><label for="borders">turn borders on/off"</label> here's quick , dirty suggestion, try: <input id="bordercheck" name="bordercheck" dojotype="dijit.form.checkbox" value="on" checked onchange="ge.getlayerroot().enablelayerbyid(ge.layer_bor...

uitabbarcontroller - Objective C: How to reload a view controller's table view when tab is selected -

i need reload data in view controller when it's tabbar clicked. i using uitabbarcontrollerdelegate method below: - (void)tabbarcontroller:(uitabbarcontroller *)tabbarcontroller didselectviewcontroller:(uiviewcontroller *)viewcontroller { if (tabbarcontroller.selectedindex == 3) { [(someviewcontroller *)viewcontroller getdata]; } } where 'getdata' instance method in someviewcontroller class. when run app, following error 2011-07-01 02:12:11.193 onethingaday[19169:207] *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[uinavigationcontroller getdata]: unrecognized selector sent instance 0x600d500' can advise me how can overcome issue? need trigger 'getdata' method when tabbarcontroller.selected index ==3 it seems me error message get, use uinavigationcontroller in tab controller; in case, cannot send directly getdata message it; should first find out view controller under ui...

Struts2 Action,Jquery AJAX call works fine and renders UI correctly in Local Dev Env but not on Production Server -

i try precise possible in explaining situation facing. developing struts 2 based web application , in 1 of page, use jquery 1.4.4 make ajax calls(post) struts2 action classes , xml iterate through , build select box , render on ui. this piece of code works fine on local 6.1 development environment. not quite on production server(same version). the select box built in local env not in production. the ajax code below : $.ajax({ url: 'displaysplitcriteriavaluesaction', type:'post', datatype: "xml", data:{ splitcriteriatype: $.trim($(this).text()) }, success: function( xmlresponse ) { buildselectboxnodropdown(xmlresponse, "serviceactivitiesvalue", "#serviceactivitiesvalueselectiondiv"); $('#serviceactivitiesvalue').bind({ change: function(){ if($(this).val() != '-1'){ makedefault(this,'defvaluef...

javascript - HTML 5 -- Vertical Scrolling -- BEN THE BODYGUARD -

this first post on here try clear , concise possible. i looking re-create effect on www.benthebodyguard.com. basically, want know how code when press down key makes backgrounds scroll guy standing in center stays same? best of ability think going on in benthebodyguard site... i going artist/illustrator make cool little world want character walk down on sidewalk , throughout want 4 or 5 videos pop up, once user has watched them can scroll more until completes journey. it's little, web-based software training, videos show user how make new event, , functions, etc... does make sense anyone? appreciated!!! it uses boilerplate template. http://www.youtube.com/watch?v=qym37xkkmkq&feature=player_detailpage#t=323s some of related javascript here: how works in benthebodyguard.com can see here: http://benthebodyguard.com/js/speechbubbles.js?v=1.09 however, best place helps learn programming www.w3schools.com. have lot of tutorials. can start learning how put thin...

mysql - How to get only one of the rows that are different? -

i'm making newsletter php module has queue list (so cron file can send specific number of emails minute), , wan't show in backoffice if newsletter has emails on queue , how many, save processing time, don't wan't each newsletter , go field field if has emails send. so, imagine structure in newsletter_queue table: newsletter_id email 1 test1@hotmail.com 1 test2@hotmail.com 1 test3@hotmail.com 1 test4@hotmail.com 2 test2@hotmail.com 2 test3@hotmail.com 2 test4@hotmail.com 3 test4@hotmail.com i wan't values: newsletter_id count(email) 1 4 2 3 3 1 so, query newsletter newsletter , check if sends pending , count, wan't save processing time. select newsletter_id, count(email) newsletter_queue group newsletter_id

iphone - What exactly is GCD and where should it be used? -

i think gcd todo asynchronous events, specifically, not sure type of events/where gcd comes in useful, apart obvious web requests. could explain gcd , should/shouldn't used? i suggest read chapter called "dispatch queues" in apple's concurrency programming guide. excellent document , depicts differences standard multi-thread programming. reading (will not take more 10 minutes read, quite more digest of course!) quite better other word can put here! link apple developer site

java - Calling a Drawable-Resource by a String -

so, let me explain default situation @ first: user can choose picture - , picture saved string (e.g. "picture1") in properties-file. wan't display picture loading string off properties-file , getting image out of drawables-resources r.drawable.mypicture. this worked out: string iconsstring[] = {"default", "icon"}; int iconsresource[] = {r.drawable.default, r.drawable.icon}; int iconresourceposition; int iconsstringlength = iconsstring.length; (int = 0; < iconsstringlength; i++) { if (iconsstring[i] == mproperties.getproperty("icon")) { iconresourceposition = i; } else { iconresourceposition = 0; } } btn_profileicon.setbackgrounddrawable(iconsresource[iconresourceposition]); but doesn't work, since ".setbackgrounddrawable" not accept int-values. well, , that's i'm stuck. make "iconsresource[]" beeing "drawable" in...

c# - Registering assembly for Interop assembly with COM visible interfaces only gives warning MSB3214 -

i have project single interface marked comvisible(true). if build project, warning msb3214: "" not contain types can registered com interop. if, however, create empty class, give default constructor , mark comvisible(true), not warning msb3214. see registered class not see interface in registry. what missing? this design, in spite of jays link. regasm.exe writes registry keys concrete classes implement interface. progid , clsid keys. com have registration interfaces (hkcr\interfaces) proxies registered there. .net has no mechanism create proxies. an assembly only interface declarations useful create type library, allowing other projects implement them. creating type library not problem, use tlbexp.exe

mvvm - NavigationPage is incremented for each HyperlinkButton click (Silverlight) -

this 1 of questions answer should obvious miss. still, can't seem figure out why "play&learn" application behaves way does. on mainpage.xaml have stackpanel containing several hyperlinkbuttons navigates set of navigationpages . there navigationframe urimapper hold "pages". <stackpanel background="black" orientation="horizontal" grid.row="0"> <hyperlinkbutton name="home" targetname="mainpageframe" navigateuri="/home" foreground="white" fontweight="bold" content="home" /> <hyperlinkbutton name="users" targetname="mainpageframe" navigateuri="/users" foreground="white" fontweight="bold" content="users" /> <hyperlinkbutton name="store" foreground="white" fontweight=...

image background on page -

i have image a, has it's own background (white). want put image on page has big image b on it. wonder if there way make background of image image b. can achieve css? or have change properties of image in order make happen? you image has "white background", computer's standpoint, has no background. if want lay image on , have second image show through in places, you'll need top image have true transparency.

arrays - Time Complexity for Java ArrayList -

i found other entries question dealt specific methods, nothing comprehensive. i'd verify own understanding of used methods of data structure: o(1) - constant time: isempty() add(x) add(x, i) set(x, i) size() get(i) remove(i) o(n) - linear time: indexof(x) clear() remove(x) remove(i) is correct? help. the best resource straight official api : the size, isempty, get, set, iterator, , listiterator operations run in constant time. add operation runs in amortized constant time, is, adding n elements requires o(n) time. of other operations run in linear time (roughly speaking). constant factor low compared linkedlist implementation.

JQuery single element validation not respecting rules -

i cannot crack 1 - have simple form textbox , button (not submit). want users enter email address , when press button, added list of addresses displayed on page. need validate user entry see if valid email address. html: <form id="invitefriendsform"> email address: <input type="text" id="cemail" name="someemail" value="" /> <input type="button" id="addemail" value="add email" /> </form> jquery: $("#addemail").click(function() { var isvalid = $("#invitefriendsform").validate({ rules: { cemail: { required: true, email: true } } } ).element("#cemail"); if(isvalid) { alert($("#cemail").val()); } else { alert('wrong email'); } }); the problem have isvalid variable true. please note alerts there not because use indicate error user, code wise need know whether should co...

java - Skipped installing application listeners due to previous error(s)-Tomcat -

i trying deploy jax-ws on tomcat server , following console output: `skipped installing application listeners due previous error(s) - error listenerstart - context startup failed due previous errors` i believe has how context configuration file has been set up: <?xml version="1.0" encoding="utf-8" ?> <context docbase="c:\documents , settings\tomcat" workdir="c:\documents , settings\tomcat\work" path="/tomcat" reloadable="true" /> or web.xml file: <?xml version="1.0" encoding="utf-8"?> <!doctype web-app public "-//sun microsystems, inc.//dtd web application 2.3//en" "http://java.sun.com/j2ee/dtds/web-app_2_3.dtd"> <web-app> <listener> <listener-class> com.sun.xml.ws.transport.http.servlet.wsservletcontextistener </listener-class> </listener> <servlet> <servlet-nam...

php - Kohana Database column aliasing, just one or two leaving the rest -

is there way alias column or 2 , leave rest intact using database module. # taking example $result = db::select(array('longcolumnname1', 'col1'), array('longcolumnname2', 'aliascol2'))->from('table_name')->execute()->current(); # , turning this... '*' $result = db::select(array('longcolumnname1', 'col1'), array('longcolumnname2', '*'))->from('table_name')->execute()->current(); my main reason i'm doing left join returns empty, id being overwritten in results , i'd hate have break down every column needed fix result id issue... there easy way... or being lazy... edit: $result = db::select('*', array('original_column', 'alias'))->from('table_name')->execute()->current();

visual studio 2010 - VS2010 installer - how to set [manufacturer] and other such properties -

Image
i'm working on vs2010 installer windows service project. want set [manufacturer] property project, can't see located in 2010. when try install currently, converts [manufacturer] 'microsoft'. i can tell response @mrchief's answer you're looking in wrong place. assembly info source file sets properties installed component. want change name on setup program. in properties window setup project, set author , manufacturer properties.

Awk Iterate through several Arrays in a for loop -

i have created awk program go through columns of file , count each distinct word , output totals separate files awk -f"$delim" {field_arr1[$1]++; field_arr2[$2]++; field_arr3[$3]++; field_arr4[$4]++}; end{\ # output fields out_field1="top_field1" out_field2="top_field2" out_field3="top_field3" out_field4="top_field4" for( i=1; <= nf; i++) { (element in field_arr$i) { print element"\t"field_arr$i[element] >>out_field$i; } } }' inputfile but don't know appropriate syntax, loop iterate through field_arr1, field_arr2, field_arr3, field_arr4? i have tried using: i, $i, ${i}, {i}, "$i", , "i". am trying wrong approach or there way change field_arr$i field_arr1..4? thanks advice. awk variables don't work way; you'll have them individually name, or use fake multidimensional arrays , parse out co...

java - Question about static member variables -

in following code, assumption member variable mbar instantiated upon first construction of foo object... , mbar instantiation shared future foo objects, bar() constructor not called again. accurate? public class foo { private static bar mbar = new bar(); public foo() { } the object might constructed way before creation of first foo.. executed when classloader loads foo.class in memory , can happen pretty @ time.... when load other classes use foo class, or when call static method of class....

web crawler - Why does simple email obfuscation work so well? -

for example replacing @ at . @ least 1 study demonstrated effectiveness: to our surprise, none of crawlers visited our departmental research , course , research web pages led spam on email addresses containing at . another experiment demonstrated same thing, showing using at , dot reduced spam 2 orders of magnitude. the first study speculated spammers obtain enough plain-text email addresses ignore obfuscated ones. parsing at in addition @ should trivial. why don't spammers account such simple obfuscation? i no expert...but intuitively makes sense @ symbol less commonly used in non-email-related speech. @ sign set email address apart other text. if use at, blends in normal english. at pretty common word after :p i'm sure still possible parse out "at" version of email, more difficult of regex.

php - 1 Image URL saved on database (but different versions available on the main server): how to replace a letter on the fly to avoid image scaling? -

this situation: have supplier gives me 1 url image catalogue...for example large version is: http://www.domain.com/dev/1/1/08973911/l_08973911.jpg image url on database saved field: supplier_reference ... can call img src with: <img src="{$product.supplier_reference|escape:'htmlall':'utf-8'}" width="150" height="133" /> and ok 'cause scales... don't want scale. sometimes, in case, don't need large version kind of small 150x133... correct url need be: http://www.domain.com/dev/1/1/08973911/s_08973911.jpg s version. how can replace letter url taken db? thank much. it seems using smarty . if so, can use smarty's replace variable modifier: <img src="{$product.supplier_reference|replace:'/l_':'/s_'|escape:'htmlall':'utf-8'}" width="150" height="133" />

css - Why is the height of a 'div>a>img' larger than the size of the wrapped img? -

if set img's size 100*100, containing div 100*106. where '6px' come from? how behavior fit standard? @clyde; yes natural behavior of image because img inline element user agents leave space descender characters. you can remove css: img { display:block; } or img { vertical-align:bottom; } for more check these https://developer.mozilla.org/en/images,_tables,_and_mysterious_gaps unwanted padding-bottom of div

compare - Comparing Sub-Folders and Copying Files with PowerShell -

in continuation previous post here: comparing folders , content powershell ...i'm attempting compare 2 directories contain sub-folders (at least 4 levels deep). second folder (folder2) contains new , updated files want copy third folder (folder3). far script isn't quite working expected. first problem, sub-folders in folder2 need created in folder3. best way this? also, not files (new or updated) getting copied folder3 folder2. anyway, here script: $folder1 = "d:\folder1" $folder2 = "d:\folder2" $folder3 = "d:\folder3" function get-directories ($path) { $pathlength = $path.length gci $path -rec | % { add-member -inputobject $_ -membertype noteproperty -name relativepath -value $_.fullname.substring($pathlength+1) $_ } } compare-object (get-directories $folder1) (get-directories $folder2) -prop relativepath, name, length | sort relativepath, name, length -desc | % { if ($file -ne $_.relativepath) { $_ } $file...

iphone - Show a view over the keyboard -

i looking way on iphone, due custom 'loading' subview, have subview cover keyboard without dismissing keyboard. right when subview loads, keyboard still topmost. ideas? add loading view subview on window. cover keyboard too. here stackoverflow post same iphone - show wait indicator update my code #pragma mark - #pragma mark waiting view - (void)showwaitingview { cgrect frame = cgrectmake(90, 190, 32, 32); uiactivityindicatorview* progressind = [[uiactivityindicatorview alloc] initwithframe:frame]; [progressind startanimating]; progressind.activityindicatorviewstyle = uiactivityindicatorviewstylewhitelarge; frame = cgrectmake(130, 193, 140, 30); uilabel *waitinglable = [[uilabel alloc] initwithframe:frame]; waitinglable.text = @"processing..."; waitinglable.textcolor = [uicolor whitecolor]; waitinglable.font = [uifont systemfontofsize:20];; waitinglable.backgroundcolor = [uicolor clearcolor]; frame = [[...

asp.net - jQuery click event not working in a jQuery tab page -

i'm using jquery tab in mvc3 solution. problem when insert link in 1 of these tabs, i'm not able control link jquery?! here code: the main tab subdivision page: <div id="tabcontainer"> <ul> <li>@html.actionlink("tab 1", "detailfootertab1", "mycontroller")</li> <li>@html.actionlink("tab 2", "detailfootertab2", "mycontroller")</li> <li>@html.actionlink("tab 3", "detailfootertab3", "mycontroller")</li> </ul> with script: $("#tabcontainer").tabs(); in tab3 page have code: <a href="#" id="buttontest">test</a> <script type="text/jscript"> $("#buttontest").click(function () { alert('i link in tab 3 page'); }); </script> these jquery tabs works. mean can click on 1 of these , system showing corresponding tab (and ...

Working with Sqlite database in android -

if have databse file in .sql format, how can load in our android app & use data? i giving complete code,plz reply if success public class databasehelper extends sqliteopenhelper{ private context mycontext; private string db_path = "/data/data/gr.peos/databases/"; //private string db_path = mycontext.getapplicationcontext().getpackagename()+"/databases/"; private static string db_name = "blib.sqlite";//the extension may .sqlite or .db public sqlitedatabase mydatabase; /*private string db_path = "/data/data/" + mycontext.getapplicationcontext().getpackagename() + "/databases/";*/ public databasehelper(context context) throws ioexception { super(context,db_name,null,1); this.mycontext=context; boolean dbexist = checkdatabase(); if(dbexist) { //system.out.println("database exists"); opendatabase(); } else { system.out.println("database doesn...

Moving a file to another directory in Perl? -

rename $argv[0], $argv[1] or warn "rename fails: $!\n"; when run ./programe file.txt dir/ fails. what's wrong here? from perldoc rename: behavior of function varies wildly depending on system implementation. example, not work across file system boundaries, though system mv command compensates this. other restrictions include whether works on directories, open files, or pre- existing files. check perlport , either rename(2) manpage or equivalent system documentation details. for platform independent "move" function @ file::copy module. so use file::copy::move instead.

java - Updating Multiple Rows - Hibernate -

in addresses table, have field named isprimary. each address assigned user, user can have 1 address primary. i have method below trying fix. if new address created , has attribute isprimary set true, need update of users existing addresses , set isprimary false. when method called , existing record has attribute set true. return null. is possible this? use trigger, mysql not support triggers acting on table inserting/updating on. this save method @override public useraddress save(useraddress obj) throws userexception { if(obj.getisprimary()) { list<useraddress> addresslist = template.find("from useraddress userid = ?", obj.getuseraccount().getuserid()); for(iterator<useraddress> = addresslist.iterator(); i.hasnext();) { i.next().setisprimary(false); template.update(i.next()); } } template.saveorupdate(obj); return obj; } the issue in code calling next...

c# - Problem in setting breakpoint in vs2010 asp.net -

i'm new in asp.net . i'm having 1 web page in asp.net developed in vs2010 & design i'm using devxpress control. i've designed 1 page & code behind file "cs" file . i've used page load event. & set break point page load event. not showing me in debug mode. , code i've written in page load code not executing. don't know why happened web page. i've used master page designing web page. how resolve problem? thanks. take @ page aspx on first line there @page directive. check if there attribute codebehind on line : <%@ page title="" language="c#" masterpagefile="~/site.master" autoeventwireup="true" codebehind="*yourfile*.aspx.cs" inherits="*namespace.yourfile*" %>

iphone - How to Use Local Image with WebService Data -

i using soap ws getting data. got 4 parameters in response - topic_name, topic_id, topic_imagepath , topic_details. have images of topic locally same name got web service particular topic_id. my question want use local image instead using topic_imagepath 's image data must come web service. i dont want use if ..else condition because have more 1000 topics, 1 can explain how path of local image , display data comes web service.. thanx in advance. if have stored images same name locally. can substring of name of image imagepath getting server , show in uiimageview local images.

Back Ground Sound in Android -

for playing different sounds have made class soundmanager using soundpool can play wanted sound on button click activities.but want ground sound play through out whole game ,from 1 activity other.so how can using soundpool , have write code play in activities. new android if there other better way playing background sounds through out activities please tell me here soundmanger class code. package com.tutorial.sound; import java.util.hashmap; import android.content.context; import android.media.audiomanager; import android.media.soundpool; public class soundmanager { static private soundmanager _instance; private static soundpool msoundpool; private static hashmap<integer, integer> msoundpoolmap; private static audiomanager maudiomanager; private static context mcontext; private soundmanager() { } static synchronized public soundmanager getinstance() { if (_instance == null) _instance = new soundman...

jquery - Parent() isn't Working... Don't Know How to Select That Element! -

there lot of div.post . need select 1 of them... 1 have $(.comment_this').attr('rel') . , add new tag in <!-- here! --> place. idea? firebug says parent() isn't function... jquery 1.6.1. <div class="post"> <div class="post_head"><div>&nbsp;</div></div> <div class="post_body"> <!-- ... --> <div class="options"> <a class="gray_button comment_this" href="#" rel="123">comments</a> <span class="gray_txt">0 comments</span> </div> <!-- here! --> </div> <div class="post_bottom"><div>&nbsp;</div></div> </div> this have... $('.post .comment_this').attr('rel').parent().html('foo'); to select element has attribute, use has-attribute selec...

c++ - problem in rendering triangles in Opengl-es 2.0 -

possible duplicate: problem when going opengl 1.1 opengl-es 2.0 i trying render isosurface drawing triangles takes data text file , render using opengl-es 2.0 . able in opengl 1.1 because in opengl-es 2.0 functions not present getting difficulty in buffer or may other problem not able understand . pasting both draw triangle code opengl , opengl-es 2.0 . can tell me why not able same result . doing coding in ubuntu 10.10 use of pvrsdk. opengl-es 2.0 code : (surfnum=0;surfnum<surftotal;surfnum++) { glclearcolor(0.6f, 0.8f, 1.0f, 1.0f); (i=0;i<trinum[surfnum];i++) { glfloat *vertices[] = { triarray[surfnum][i].pt1, triarray[surfnum][i].pt2, triarray[surfnum][i].pt3 }; glgenbuffers(1, &ui32vbo); glbindbuffer(gl_array_buffer, ui32vbo); unsigned int uisize = 3 * (sizeo...

javascript - Escaping & for display in mail client (mailto link) -

i have javascript function so: var strbody = encodeuri(window.location.href); var strsubject = encodeuri(document.title); var mailto_link = "mailto:?subject=" + encodeuri(strsubject) + "&body=" + strbody; this code executed on hyperlink's onclick event, , opens mail client (mailto://). however, title of page has several & symbols, title picked until first &. url picked up. what correct javassript escape & , display in mail client's subject line? var encoded_body = encodeuricomponent(window.location.href); var encoded_subject = encodeuricomponent(document.title); var mailto_link = "mailto:?subject=" + encoded_subject + "&body=" + encoded_body; should ( encodeuricomponent instead of encodeuri ). in original code incorrectly double encoding subject (once on line 2, , again on line 3). i took liberty of renaming variables make clearer contain encoded subject , body , opposed original text. ...

c++ - CMake dependency on defined (preprocessor) header file -

i have configuration file setup defines correct header files include components. later include file via preprocessor token. unfortunately cmake's dependency scanner ignores header file. essentially comes down this: #define header_file "somefile.h" #include header_file cmake not add "somefile.h" list of dependencies source file! how can cmake recognize dependency correctly? (i know can #if 0 blocks , include files, either includes many dependencides other sources, or defeats whole purpose in first place -- depending on how it) you can add explicit dependency source file setting object_depends property: set_property(source source.cpp append property object_depends "somefile.h") you'll have source file includes configuration file.

asp.net - Simple question about xml element in C# -

i'm not in asp.net(c#) , xml. have textbox control, button, , website url(ex: http://chelseacole.com/question ) has content of xml file, this: <paragraph> <text att1="1" att2="2"> facebook, facebook, facebook, facebook. </text> <text att1="3" att2="4"> twitter, twitter, twitter, twitter. </text> <text att1="5" att2="6"> facebook, twitter, facebook, twitter. </text> </paragraph> so want is: went click button, result appear in textbox control, this: facebook, facebook, facebook, facebook. twitter, twitter, twitter, twitter. facebook, twitter, facebook, twitter. anyone gonna me? in advance! :"> if i've understand want achieve, try this: xdocument document = xdocument.load("file.xml"); or: xdocument document = xdocument.parse("<paragraph><text att ... "); foreach (xelement item in documen...

linux - Run text files in terminal -

does know if there's way run automatically in shell list of commands (from text file)? i need run lot of scripts (around 1000). scripts in python , take 2 arguments each (dir_#, , sample#) the text file i've made looks this... python /home/name/scripts/get_info.py dir_1 sample1 python /home/name/scripts/get_info.py dir_2 sample2 python /home/name/scripts/get_info.py dir_3 sample3 python /home/name/scripts/get_info.py dir_4 sample4 ... so, expect passing text file argument command in terminal, job automatically... thanks in advance, peixe that's called "shell script." add top of file: #!/bin/sh then execute command: chmod +x filename then execute program: ./filename alternately, can execute shell directly, telling execute commands in file: sh -e filename

c# - Concurrent collections eating too much cpu without Thread.Sleep -

what correct usage of either, blockingcollection or concurrentqueue can freely dequeue items without burning out half or more of cpu using thread ? i running tests using 2 threads , unless had thread.sleep of @ least 50~100ms hit @ least 50% of cpu. here fictional example: private void _dequeueitem() { object o = null; while(socket.connected) { while (!listofqueueitems.isempty) { if (listofqueueitems.trydequeue(out o)) { // use data } } } } with above example have set thread.sleep cpu doesnt blow up. note: have tried without while isempty check, result same. it not because of blockingcollection or concurrentqueue , while loop: while(socket.connected) { while (!listofqueueitems.isempty) { /*code*/ } } of course take cpu down; because of if queue empty, while loop like: while (true) ; which in turn eat cpu resources. this not way of using concurrentqueue...

JQuery Popup character map -

does know of popup 'character map' jquery plugin? have text field , user able insert special characters (easily). similar tinymce plugin. thanks one i've used , found pretty useful special edit (http://www.ganzogo.com/projects/specialedit). gives control on characters want appear, , stylable fit site.

android - How to turn on bluetooth on button click -

in application, need turn on bluetooth of device on button click. how can achieve that? example helpful. also, permissions require include in mainfest.xml same? following code excerpts android documentation on bluetooth in manifest file permissions: <manifest ... > <uses-permission android:name="android.permission.bluetooth" /> ... </manifest> source code enable bluetooth bluetoothadapter mbluetoothadapter = bluetoothadapter.getdefaultadapter(); if (mbluetoothadapter == null) { // device not support bluetooth } if (!mbluetoothadapter.isenabled()) { intent enablebtintent = new intent(bluetoothadapter.action_request_enable); startactivityforresult(enablebtintent, request_enable_bt); } if enabling bluetooth succeeds, activity receive result_ok result code in onactivityresult() callback. if bluetooth not enabled due error (or user responded "no") result code result_canceled .

Magento Free Shipping for Match Items Only - Using Table Rates Based on Order Total -

can achieve following magento: i'm using table rate system of price vs destination. , i've got shopping cart price rule of free shipping products attribute free_shipping -> set yes. this works fine if have normal products in basket or free shipping products in basket. if have both normal product , free shipping product in basket. calculates shipping based on order total including product free shipping. how can correct this, shipping applied order total of products not including free shipping, when both type of products exist in basket? is there magento plugin this? in advance. i had same problem , implemented small code change make work. basically forget promotion rule. disable it. doesn't seem work shipping rates table when applying free shipping individual items. shipping rules seem take precedence , calculate based on cart total. the trick subtract free shipping items cart total @ point shipping rates module making calculation. in case insid...

c# - Detect when console application is closing/killed? -

i wanted make safe exit console application running on linux using mono can't find solution detect wether signal sent or user pressed ctrl+c. on windows there kernel function setconsolectrlhandler job doesnt work on mono. how closing event on console application safe exit ? you need use mono.unixsignal , there's sample posted jonathan pryor : http://www.jprl.com/blog/archive/development/mono/2008/feb-08.html there's shorter example on mono page: faq / technical / operating system questions / signal handling : // catch sigint , sigusr1 unixsignal[] signals = new unixsignal [] { new unixsignal (mono.unix.native.signum.sigint), new unixsignal (mono.unix.native.signum.sigusr1), }; thread signal_thread = new thread (delegate () { while (true) { // wait signal delivered int index = unixsignal.waitany (signals, -1); mono.unix.native.signum signal = signals [index].signum; // notify main thread signal received, ...

java - does loadClass() of classLoader loads the class into memory? -

i want create custom class loader. confused loadclass(), method loads specified class memory? if yes why static block of specified class not invoked? //main class package custom_class_loader1; public class custom_class_loader1 { public static void main(string[] args) { try{ customclassloader c=new customclassloader(); class c1= c.loadclass("custom_class_loader1.abc");/**does load abc class memory?**/ }catch(exception e) { system.out.println(e); } } } when load class doesn't initalise until used default. invoking method equivalent invoking loadclass(name, false); here false means don't resolve class. one way control use class.forname() public class main { public static void main(string[] args) throws classnotfoundexception { classloader cl = new urlclassloader(new url[0], classloader.getsystemclassloader()); system.out.println("unresolved test...

Restarting Apache from Django -

i need django app able restart apache server running it. i'm using mod_python. which easiest way? the way possible if gave django application root permissions, horribly unsafe. but, assuming app running root, can run import subprocess subprocess.popen(['/etc/init.d/apache2', 'restart']) or whatever command distribution has restarting apache. if django app not root, may able run sudo using pexpect python library. import pexpect child = pexpect.spawn('sudo /etc/init.d/apache2 restart') child.expect('[sudo] password .*:') child.sendline(password) child.interact() note way requires give apache user ability run sudo insecure. in general, can't see secure way accomplish this.

svn - Getting the last revision of several files to resolve merge conflicts -

on company, have created new version of application in production. may guess, development composed multiple iterations , made multiple commits regarding same file. in order merging process (i'm using subclipse plugin) know if possible select last revision of given file, avoiding intermediate merges once "blocking" merging process. i recommend using svnmerge ; automates lot of confusing aspects of merging in subversion. with regards specific question, might if provide example of project structure in subversion , whether people have been working on separate branches. i'm not quite sure mean 'select last revision of file' - can merge whatever individual revisions like, won't merge cleanly if rely on earlier changes.

django - Matching query does not exist? -

this view: def showproject(request, project_slug): project = project.objects.get(slug=project_slug) tickets = ticket.objects.filter(project=project) payload = { 'project':project, 'tickets':tickets } return render(request, 'project/project.html', payload) this error: traceback: file "c:\python27\lib\site-packages\django-1.3-py2.7.egg\django\core\handlers\base.py" in get_response 111. response = callback(request, *callback_args, **callback_kwargs) file "c:\\project\views.py" in showproject 13. project = project.objects.get(slug=project_slug) file "c:\python27\lib\site-packages\django-1.3-py2.7.egg\django\db\models\manager.py" in 132. return self.get_query_set().get(*args, **kwargs) file "c:\python27\lib\site-packages\django-1.3-py2.7.egg\django\db\models\query.py" in 349. % self.model._meta.object_name) exception type: doesnotexist @ /project/ticket/ ...

iphone - Objective-C initializing an NSArray vs NSMutableArray -

why work: self.array = newarray; but doesn't: [[self mutablearray] addobject:object]; meaning, why need init nsmutablearray work when don't have init nsarray ? edit: hops clearer guys. interface: @interface foo : uiviewcontroller { } @property (nonatomic, retain) nsarray *array; @property (nonatomic, retain) nsmutablearray *mutablearray; @end implementation: @implementation foo @synthesize array; @synthesize mutablearray; - (void)viewdidload { [super viewdidload]; self.array = [class returninganarray]; [[self mutablearray] addobject:objectihaveomittedthecode]; } @end self.array = newarray; in line, assigning created object self.array . so, you've no need create it. [[self mutablearray] addobject:object]; but in line trying add object array not created actually. if don't create array, nil , , sending message nil won't take effect.

c++ - Can we declare a function with the same signature but different return type in the base class? -

the question may silly ,but want ask.. there way can declare method in class same signature different return type (like int fun(int) , float fun(int) ) , during object creation can dynamically decide function executed! have got compilation error...is there other way achieve logic may using templates... you can take return value template. template<typename t> t fun(int); template<> float fun<float>(int); template<> int fun<int>(int); can decide dynamically @ run-time call? no.

dhtmlx - dhtmlxScheduler using ASP.NET MVC Refresh Error -

i getting error incorrect html when return save view means displayed scheduler not being refreshed fix last set of data. having made change or addition, displayed correctly if close website , open again, update has been saved in table. refreshing of currennt view having problems with. have suggestions might look? as usual, mistake. had created new project , copied save.aspx view project. inherits="system.web.mvc.viewpage<rlsbcwebsite.controllers.calendaractionresponsemodel>" still referred old project. make sure create new page in project , copy contenets old projects!

mvvm - knockoutJS + master page/view -

doubt possible don't have 1 page app, pretty every view make contains 80% of same css/javascript, there way tell knockoutjs master view else populate? i doubt pretty 1 page app for... best can hope use combres combine non-changing stuff 1 resource file per type... == edit == adding example of mean, pretty sure wouldn't able inject multiple areas shown below, here example: <!doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> <html> <head> <title>master page</title> <link type="text/css" rel="stylesheet" href="../assets/styles/main.css"> <link type="text/css" rel="stylesheet" href="../assets/styles/themes/simple.css"> <link type="text/css" rel="stylesheet" href="../assets/styles/jquery.qtip.min.css"> {per page css...

c# - How to install System.Data.Sqlite -

i using visual studio 2010. trying install sqlite framework here . i've installed precompiled binary windows, in visual studio there no system.data.sqlite. i've added configuration file this: <configuration> <system.data> <dbproviderfactories> <remove invariant="system.data.sqlite" /> <add name="sqlite data provider" invariant="system.data.sqlite" description=".net framework data provider sqlite" type="system.data.sqlite.sqlitefactory, system.data.sqlite" /> </dbproviderfactories> </system.data> i still cannot import library. i'm not sure how working. in xcode drag source files wrapper project, , add sqlite db. not easy here guess. also, on mac create db structure through bash shell using sqlite3. how can on windows too? i suggest go older version the original website . comes installer solves c...

ruby on rails 3 - How to set Mongoid fields from within the class -

i lost scope of variables in rails mongoid. (probably due lack of coffee). all want, way set fields within application, way can find this, calling write_attribute . class example include mongoid::document field :foo def bar @foo = "meh" end def hmpf foo = "blah" end def baz write_attribute(:foo, "meh") end end e.bar #=> "meh" e.foo #=> nil e.hmpf #=> "blah" e.foo #=> nil e.baz #=> [nil, "meh"] e.foo #=> "meh" am using scope wrong? why running foo = "bar" not set field within, works outside: e.foo = "blah" works trough magic methods. try adding self attribute references when working in model's instance methods: def hmpf self.foo = "blah" end should trick.

java - Consecutive named parameter problems in Hibernate (Spring HibernateTemplate) -

i trying use named parameters inject strings query. using spring , hibernatetemplate, , and new hibernate. have gotten unnamed , named parameters work in past, seems though when right next each other throw error. have made similar example code problem below (simplified highlight problem @ hand). orderby contains string of field , orderdirection contains asc or desc. public list<hashmap<string, object>> examplelist(string orderby, string orderdirection) { logger.debug(orderby); logger.debug(orderdirection); final string querystring = "select new map("+ "a.id id, "+ "a.name name, "+ "a.number number ) "+ "from asset "+ "order :orderby :orderdirection"; string[] parameternames = {"orderby", "orderdirection"}; obj...

sql server 2005 - IF, RAISERROR & RETURN in Stored Procedure -

i have stored procedure, proc , receives parameters. if 1 of them, @id , not null, given stored procedure, proc_a , must executed. otherwise, proc_b must executed. problem both of them may issue raiserror , want propagate through call stack displayed @ client application. however, raiserror won't stop rest of proc stored procedure should, and, since using if clause, checking if ( @@error <> 0 ) return isn't option either. choice seems using try...catch block wrap if clause , rethrow raiserror within catch block, awkwards because have cache error_message() , error_severity() , error_state() , use raiserror once again. isn't there more elegant way? just use try - catch block , echo original error, isn't hard do: begin try --used in catch block echo error declare @errormessage nvarchar(400), @errornumber int, @errorseverity int, @errorstate int, @errorline int --your stuff here end try begin catch --your error code/lo...