Posts

Showing posts from March, 2015

Publish messages using CometD Java client that can be consumed by Javascript subscribers -

i have java web application uses cometd. workflow simple: i have defined service acts upon receiving messages on channel "/service/hello". service expects parameter "name". based on creates channel named: "/"+message.getdataasmap().get("name") . channel attaches callback method send message subscribers. the javascript client (uses dojo) publishes message channel "/service/hello" , subscribes channel name has sent "/service/hello" parameter. lets take example: .... cometd.subscribe('/1234', function(message) { //do smth on message received; }); cometd.publish('/service/hello', { name: '1234' }); .... this works fine. ,what want achieve following: have javascript clients subscribers , java client publishing. have tried using examples given in cometd2 documentation java client api, doesn't work expected. seems service called messages aren't seen...

javascript - Cookie having "=" in value -

i have check whether cookie exist or not while making request. problem cookie value having "=" in e.g. ....;username=firstname=meet;.... here cookie name "username" , cookie value "firstname=meet". problem when try cookie document.cookies. getting cookies after exploding result using split function ";". for getting values exploding / splitting each value "=" cookie value coming till firstname only. any thoughts can whole value firstname=meet. thanks, meet // when cookie string: unescape(cookiedata); // when set cookie string: escape(yourstring);

Best way to make nested custom objects parcelable in Android -

there lot of information out there concerning parcelable in android. after looking around, couldn't find nice solution problem. so, need create class (let's call "myclass") extends custom class else wrote ("hisclass"). there many instance variables in hisclass, of objects of custom classes, themselves. want pass myclass object 1 activity , realize, need make parcelable. instance variables custom objects? reading this , think need make every single custom object implement parcelable. since, there many custom objects in myclass , hisclass again have custom objects instance variables, doing seems bad solution me. is there better way? maybe, being totally blind here. hope can me. well, can make use of serializer , result in slow performance. afaik, implementing parcelable best way passing data. additionally, don't try complicate creating complex data structure pass using intent . either use parcelable cheap/light-weight/less-in-amount ...

PHP: Sorting custom classes, using java-like Comparable? -

how can make own custom class sortable using sort() example? i've been scanning web find method of making class comparable in java without luck. tried implementing __equals() without luck. i've tried __tostring(). class looks this: class genre { private $genre; private $count; ... } i want sort them count integer, in descending order... ($genre string) you can create custom sort method , use http://www.php.net/manual/en/function.usort.php function call it. example: $collection = array(..); // array of genre objects // either must make count public variable, or create // accessor function access function collectionsort($a, $b) { if ($a->count == $b->count) { return 0; } return ($a->count < $b->count) ? -1 : 1; } usort($collection, "collectionsort"); if you'd make more generic collection system try this interface sortable { public function getsortfield(); } class genre implements s...

winforms - .NET DataGridView: Remove "current row" black triangle -

in datagridview, if set grid readonly there black triangle @ rows headers shown @ current row. i'd avoid shown, i'd avoid big padding of cells caused triangle. guess padding caused triangle because cell's padding 0. is posible that? how? thanks! edit this how row headers text created: for (int = 0; < 5; i++) { datagridviewrow row = new datagridviewrow(); row.headercell.value = headers[i]; datagridview1.rows.add(row); } and headers array of strings. ( string[] ) if want keep row headers rather hide them, can use cell padding push triangle out of sight: this.datagridview1.rowheadersdefaultcellstyle.padding = new padding(this.datagridview1.rowheaderswidth); if using row header text , want keep visible need use custom painting - thankfully simple. after above code, attach rowpostpaint event shown below: datagridview1.rowpostpaint += new datagridviewrowpostpainteventhandler(datagridview1_rowpostpaint); and in rowpostpa...

javascript - Rails3: change content of table column on mouseover -

given simple view table: <% entries.each |entry| %> <tr> <td class="align-left"><%= entry.date.strftime("%d.%m.%y") %></td> <td class="align-right><%= my_number_to_currency entry.amount_calc %></td> <td class="align-left"><%= entry.description %></td> <td class="align-left"><%= entry.tag %></td> </tr> <% end %> i want change content of second column (for every entry) my_number_to_currency entry.amount @ runtime on mouseover , change original value when mouse leaves again. in addition, want add style, either class="over" or directly set color of element. i'd grateful pointers how best achieved in rails3 (and put code if needed in 1 view). (remarks: my_number_to_currency simple helper, think of normal number_to_curr...

python - Why does adding my Sql UPDATE break my loop? -

i have following code which, without escaped sql statement, working fine - iterates on full set of returns previous select query printing id, detected language (from bingtranslate) , text. for row in c: lang=bingtranslate(row[0]) tweetid = row[1] print tweetid, lang, row[0] #c.execute('update tweet set iso_language_code=? id=?',(lang, tweetid)) when unescape update call, loops once, , stops. what gives? no error reported. i'm sure it's simple can't crack it... i don't know python, try explain in c#. you're executing command using same object of datareader ( c in python), have reset , strange behaviour. in opinion don't need copy rows in object, create new command object (empty) , use execute query taking params c . correct me if i'm wrong, please.

algorithm - Shopping cart and different kinds of discounts. Storing discounts in DB and applying it to order calculations -

currently, i'm looking best practice "applying discounts" cart/order. so, i'm planning implement such kind of discounts as... fixed user's discount (for example, i'd give 10% discount favourite customer) discount number of items (for example, you're buying 10 different colored pens , you'll getting discount of 1.5%) discount coupon (for example, during promo action we've produced 100 coupons 10% discount each. coupons work 1 order , expire on yyyy-mm-dd) present purchasing item or group of items (for example, you're buying pen, list of paper , shop presents sharpener you) discount total order price (for example, you're buying 10 pens , gettin no discount, you're adding 5 more pens , getting 5% discount) only 1 discount applied specific item. we're applying biggest discount. profitable discount user. beside admin should able modify items price in specific order , cancel discounts in order. frankly speaking, fir...

image processing - Finding the concavness pixel/point in binary map using Matlab -

Image
given binary mask object in matlab. going find concavity point of object boundary. concavity point mean here deepest concavity point respect euclidean distance convex hull chords k_1, k_2 ,and k_3 in concavity regions b_1, b_2, b_3, respectively. red dot indicates concavity point want find, in concavity region b_1 draw 3 lines perpendicular chord k_1, deepest concavity point middle 1 since has largest length. anyone have efficient way/code that? thanks. another figure below gives example convex hull, red dot indicates valid concavity point. efficient relative... how computing convex hull (there standard algorithms it) , shrinking until inside object boundaries. last point touching desired concavity point. alternative strategy: calculate convex hull find differences between convex hull , object boundary (have straight lines, k1 k2 k3 in case) for every line, rotate image such line horizontal take lowest pixel of object boundary below line

C# add to class in another DLL -

...is possible? for example, can add simple function... public static double deg2rad(double degrees) { return math.pi / 180 * degrees; } ...to convert class? (using default..."usings") can call double radians = convert.deg2rad(123); can done? if so, how? no can't, can add extension method double , call like double x = 180.0; double y = math.cos( x.deg2rad() ); double z = math.sin( 0.5.pi() ); in static class add following extension method: public static class extensionmethods { public static double deg2rad(this double angle) { return math.pi*angle/180.0; } public static double pi(this double x) { return math.pi*x; } }

code coverage - Android JUnit: Define a different Application subclass -

so normal android project, have following in androidmanifest.xml: <application android:name=".utilities.app" ...> .... </application> and have app class: public class app extends application { .... } and have android junit test project associated android project. fine , dandy , can write junit tests. however, i'm trying run code coverage junit tests , i'm getting bloated results. reason because app class gets called , initialized if application started. not want custom app class execute when run junit tests or code coverage. setup need junit tests go in appropriate junit setup() method. there way can prevent executing custom app class or way classes/methods/lines executed due creation of app class aren't counted towards code coverage? a temporary solution i've found work unless has better ideas. go main android project's androidmanifest.xml. change android:name attribute ".utilities.app" "andro...

java - Where can I find detailed info regarding Twitter4J Query strings? -

hi have project need use java access twitter api, , found twitter4j easy use , tried samples site. cannot find details regarding query class regarding query strings object, knows comprehensive info one? cheers. if "query string" mean value in query field, that's literally text can type search box on twitter's website. there's no list of examples because it's wide open. use whatever happen thinking @ particular instant in time.

security - Trac. Uploading attachment shows its contents in History View for all users. How to customize privileges? -

i'm using "mypage" plugin trac. i have figured out useful store ssh keys on private page attachment, can clone git repository computer. have our found user can view history tab, can see content of attachment :/ any idea how secure thing? since in general meant feature, you'd block 1 or several specific attachments common view. if true, tracfinegrainedpermissions you. you'll able have like [wiki:users/killdaclickhome@*/attachment/supersecret.file] killdaclick = attachment_view * = !attachment_view to deny access specific file yourself. have @ finegrainedpageauthzeditorplugin alternative way define these permission (from web-ui instead of direct access authz file). you'll think twice granting permission 'trac_admin' - hint these user can edit file , possibly circumvent restriction. 'trac_admin' have 'attachment_view' anyway.

matlab - Plotting graph error (values not showign up) -

how plot value of approximation - answer s varies in code below? if @ code below, can see method used (i put in separate file). however, not show me graph 1 1000 . instead graph 999 1001 , not have points on it. for s = 1:1000 error = laplacetransform(s,5) - (antiderivative(1,s)-antiderivative(0,s)); end plot(s,error); title('accuracy of approximation'); xlabel('s'); ylabel('approximation - exact answer'); the functions used: function g = laplacetransform(s,n); % define function parameters a=0; b=1; h=(b-a)/n; x = 0:h:1; % define function g = ff(x).*exp(-s*x); % compute exact answer of integral exact_answer=antiderivative(b,s)-antiderivative(a,s) % compute composite trapezoid sum if=0; i=1:(n-1) if=if+g(i).*h; end; if=if+g(1).*h/2+g(n).*h/2; if with function fx=ff(x) fx=x; and function fx=antiderivative(x,s); fx= (-exp(-s*x)*(s*x+1))/(s^2); any appreciated. thanks. the following for s = 1:1000 error = laplacetr...

Modify contents of Firefox download dialog from add-on kit -

i'd able add option download dialog pops-up in firefox when starting file download. possible using new add-on sdk or have old way? edit: obviously, if new option selected, need way know , execute code based on it. that's use xul overlays for. guess dialog talking chrome://mozapps/content/downloads/downloads.xul - download manager. afaik doing isn't possible add-on sdk, provides common ui integration points. create traditional extension however, can overlay dialog.

php - How to check if a file exists from a url -

i need check if particular file exists on remote server. using is_file() , file_exists() doesn't work. ideas how , easily? you have use curl function is_url_exist($url){ $ch = curl_init($url); curl_setopt($ch, curlopt_nobody, true); curl_exec($ch); $code = curl_getinfo($ch, curlinfo_http_code); if($code == 200){ $status = true; }else{ $status = false; } curl_close($ch); return $status; }

Is it possible to have one view for two action in asp.net mvc3 razor view? -

i need add time zone in view. dynamic viewdata = new expandoobject(); viewdata.timezones = p in timezoneinfo.getsystemtimezones() select new selectlistitem { text = p.displayname, value = p.id }; how can send "viewdata" view. have done in different action, cannot in same action. you use viewbag : public actionresult index() { viewbag.timezones = p in timezoneinfo.getsystemtimezones() select new selectlistitem { text = p.displayname, value = p.id }; return view(); } and in view: @html.dropdownlist( "selectedtimezone", (ienumerable<selectlistitem>)viewbag.timezones )

Use variable Column name in Select statement on SQL server 2008 -

i select value table using column name variable ! eg declare @spalte varchar(10) set @spalte = 'ecomp' select @spalte dbo.matdata 2>= tmin , 2<=tmax , 1 = matcode when try 'ecomp' back, not expected value. any idea? information_schema meta data describing objects in database - isn't placeholder table. if want return data table, then select * dbo.matdata 2 >= tmin , 2<=tmax , 1 = matcode if want build query against table don't have schema for, need build dynamic sql query , call sp_executesql. edit : to select 1 column: select eocomp dbo.matdata 2 >= tmin , 2<=tmax , 1 = matcode edit #2 : your updated question doesn't bear resemblance original q, , you've accepted redfilter's answer. to select dynamic column, need dynamic sql. can't call procs udf, , udfs should return standard type (if scalar) or table. here's how sproc: given create table dbo.matdata ( column1 int, co...

azure - How to have two deployments into production and none in staging? -

this situation: have bizspark account gives me 1500 hours per month of azure instances free. so, can use 2 instances not billed. i have 1 deployment 1 instance in production , deployment instance in staging. want have secondary deployment (ans instance, of course) in production also. see "swap vip" option interchanged 1 other. want 2 deployments go production , use staging mode changes. how can that? or i'm missing something? note: know can have deployment 2 instances. in case, updates, should set staging deployment (with 2 instantces later swapped), use 4 instances while. your production instance instance addressible through known url (e.g. foo.cloudapp.net). staging instance(s) addressible through (random) guid prefix (e.g. 61c91c4b-d949-4c62-837c-f780586f96d8.cloudapp.net). therefore staging instance(s) should not relied upon production use. if want multiple instances of service running, configure service require 2 instances. then, when comes deplo...

Synchronizing with server time - jquery countdown plugin and php -

i have following code in php file: <div id="clocktimestamp" class="hidden"><?=$_server['request_time'];?></div> <div id="clock"></div> i using jquery countdown plugin keith wood , calling this: $('#countdown').countdown({until: until, serversync: getservertime}); and following code in js file: function getservertime() { var time = $('#clocktimestamp').html()*1000; time = new date(time); return time; } now, question is: approach $_server['request_time'] ok or should this: function getservertime() { var time = null; $.ajax( { url: '../../_ajax/getservertime.php', async: false, datatype: 'text', success: function(text) { time = new date(text); }, error: function(http, message, exc) { time = new date(); } }); return time; } i'm...

Display html formatting in listview android -

i've got list view in have dispaly text html proper formatting. though pass html string html.fromhtml method formatting align="justify" don't work. here code snippet: string text = "<ul><li><p><div align="justify">as part of growth plan, ranchi-based central coalfields ltd (ccl) gearing double company's production in next couple of years , increase capacity of coal washeries.</div></p></li></ul>"; i pass this string spanned ntext = html.fromhtml(text); and display on screen when string ntext displays on emulator screen formatting should there, i.e. text should displayed justified, gone. please help i have found using html.fromhtml() can hit , miss because html tags supported, , others not. justified text not supported within android because, suspect, can pretty dreadful relatively short lines of text. not surprise me if justified text not supported in fromhtml(). per...

Generics in GWT -

i building application uses, gwt (2.4), app engine (1.5.4), , objectify (3.0). application evolving, adding more domain classes , forcing me write more services, more or less same. example should have code crud operations. tried create generic services //client side @remoteservicerelativepath("generic") public interface genericservice<t extends basedomain> extends remoteservice { .... } public interface genericserviceasync<t extends basedomain> { ... } //serverside @suppresswarnings("serial") public class genericserviceimpl<t extends basedomain> extends remoteserviceservlet implements genericservice<t> { //implementation } when trying create instance of on client side using //domain extends basedomain public static final genericserviceasync<domain> domainservice = gwt.create(genericservice.class); i getting following exception java.lang.runtimeexception: deferred binding failed 'com.planner.client.generic...

android - how to decode videofile -

in decoding of image file use bitmapfactory instead of can use video? public void decodefile(string filepath) { // decode image size bitmapfactory.options o = new bitmapfactory.options(); o.injustdecodebounds = true; bitmapfactory.decodefile(filepath, o); // new size want scale //final int required_size = 1024; // find correct scale value. should power of 2. //int width_tmp = o.outwidth, height_tmp = o.outheight; int scale = 1; /*while (true) { if (width_tmp &lt;required_size &amp;&amp; height_tmp &lt; required_size) break; width_tmp /= 2; height_tmp /= 2; scale *= 2; }*/ //int scale = 1; // decode insamplesize bitmapfactory.options o2 = new bitmapfactory.options(); //o2.insamplesize = scale; ...

gem - integrating sorcery in a checkoutprocess -

i'd integrate sorcery-gem achieve authentication while checking out in online shop. followed ryan bate's railscast episode 283 - authentication sorcery . given vistor has put products in session[:cart] , wants checkout. clicks on "checkout" , railsapp checks if logged in. if not, redirected sessions#new , got log in. the problem sorcery's #login session_reset , session[:cart] destroyed. is there nifty solution that? can think of some, imho, dirty hacks creating new controller actions or trying save cart temporarily in database. cheers, cs just in session controller (the place call login): temp_cart = session[:cart] login(…) session[:cart] = temp_cart this way you'll hand cart around session reset. bests, jjs

php - can I call requestAction from within a requestAction chunk in cakephp? -

i have bunch of independent controller actions, need cascade in single page. thinking of making requestaction call within requestaction. second call fails everytime 404. new cakephp , not sure whether if possible. is there better way using jquery can me achieve this. +----------------------------------------------------------------+ | header | +----------------------------------------------------------------+ | | |+---------------------------------------------+ +--------------+| || submenu | | main menu || |+---------------------------------------------+ | || | +--------------+| |+---------------------------------------------+ | || content view | | || | ...

flash - How to change textfields on stage from an external class in as3 -

i tried change textfield on stage external class doesn't work. thats code how tried it: package { import flash.display.*; import flash.text.textfield; public class exp extends sprite { public function exp() { trace(stage.getchildbyname("abc")); textfield(stage.getchildbyname("abc")).text = "abc"; } } } on stage got textfield wich dynamically instancename: "abc". everytime start program flash tells me stage.getchildbyname("abc") null-object. i hope can me. i've never used getchildyname before.. can use this: var rt:movieclip = movieclip(root); trace(rt["abc"]); or shorter: trace(movieclip(root)["abc"]); if example document class - package { import flash.display.movieclip; import flash.text.textfield; public class exp extends movieclip { public function exp() { va...

How to delete an old/unused Data Model Version in Xcode -

how can delete old data model in xcode? option disabled on menu. (the models want delete have not been released public - interim development models.) it's hack, worked me: set current version of model in xcode 1 want keep remove .xcdatamodeld project (right-click -> delete -> remove reference only ) show contents of .xcdatamodeld package in finder (right-click -> show package contents) delete .xcdatamodel file(s) don't want anymore re-add .xcdatamodeld file project this eliminates need manually modify of project metadata files.

Converting html tag into text in android -

i developing android app. in app retrieve data database stored in html format. converting html code plain text use html.fromhtml(string) . convert html code convert <font> color="######">some string</font> . please me if 1 have idea. thank in advance. html.fromhtml(string) supports few tags. check here, http://commonsware.com/blog/android/2010/05/26/html-tags-supported-by-textview.html

mysql - rails server error ? (rails 3) -

/library/ruby/gems/1.8/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle: dlopen(/library/ruby/gems/1.8/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle, 9): library not loaded: libmysqlclient.18.dylib (loaderror) referenced from: /library/ruby/gems/1.8/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle reason: image not found - /library/ruby/gems/1.8/gems/mysql2-0.3.2/lib/mysql2/mysql2.bundle /library/ruby/gems/1.8/gems/mysql2-0.3.2/lib/mysql2.rb:8 /library/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `require' /library/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:68:in `require' /library/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `each' /library/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:66:in `require' /library/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `each' /library/ruby/gems/1.8/gems/bundler-1.0.12/lib/bundler/runtime.rb:55:in `require' /library/ruby/gem...

fwrite in php not working in binary mode -

i .net guy , have got code works on 1 of our servers not on other, not on local machine. code snippet given below: //$flocal1 = fopen($mvfile_name.".txt", "w"); //@fwrite($flocal1, "my name gaurav pandey!!!"); //opening file $flocal = fopen($mvfile_name, $mode); //writing file if (!(@fwrite($flocal, $contents))) { //writing error if writing operation failed exit(notupload); } //closing file fclose($flocal); as can see, tried same code writing text file string , worked fine, binary files, getting error. if you're on windows server, use b flag fopen. fopen($filename, 'wb'); this should set php according manual, maybe on old server isn't case.

php - How to Import Multi-Database MySQLdump with 'DROP TABLE IF EXISTS'? -

i want copy bunch of db's server1 server2 , want drop db's on server2 conflict imported db's, import db's. i'm using import: mysql -u root -p[password] < a_bunch_of_dbs.sql i used phpmyadmin perform several exports totally unusable. the problem phpmyadmin either put: drop database `database1`; (it results in error #1008 - can't drop database 'database1'; database doesn't exist) or: create database `database1`; (it results in error #1007 - can't create database 'database1'; database exists) but not : drop database if exists `database`; create database if not exists `database1`; (obviously "if not exists" redundant liked there reassurance) so, solve either need command line options or need find out phpmyadmin creates query strings , add "if exists" drop table option , solve everything. any ideas? thank you. take advantage of mysql backup , restore tools in dbforge stu...

asp.net - Pass integer value of radio button to sql server 2008 -

i trying pass value of radio button database. when radio button not checked value 2 pass in no problem. when radiobutton checked value not pass database. error: "input string no in correct format". below code: dim rbval integer rbval = convert.toint16(radiobutton1.checked) rbval = int16.parse(radiobutton1.checked) if radiobutton1.checked rbval = 1 else rbval = 2 end if cmd.parameters.add(new sqlparameter("@ethics", sqldbtype.int)) cmd.parameters("@ethics").value = rbval i sure simple nto seeing it! your code reads int16.parse(radiobutton1.checked) . problem radiobutton1.checked returns boolean value rather integer value, , parse error occurs. based on code, can delete these lines , things work: rbval = convert.toint16(radiobutton1.checked) rbval = int16.parse(radiobutton1.checked) so imagine code like: dim rbval integer if radiobutton1.checked rbval = 1 else rbval = 2 end if ...

mysql - Two tables - how to delete rows if ID not referenced in both tables -

i have 2 tables: listings(item_id, ...) images(item_id, ...) the item_id value same in both tables - goofed , deleted listings 'listings' table without deleting corresponding row in 'images' table. so - want delete rows in second 'images' table if item_id in images doesn't correspond of more up-to-date item_id values in primary 'listings' table. how delete records in 'images' table not referenced 'listings'? i've been experimenting sql script , sub-query this: delete images item_id in (select item_id images except select item_id listings) but before screw up, want confirm if correct? you should use sub query delete images item_id not in(select item_id listings) more examples , explanation .

sql - Rails: Has many through associations -- find with AND condition, not OR condition -

i have following query method in activerecord model: def self.tagged_with( string ) array = string.split(',').map{ |s| s.lstrip } select('distinct photos.*').joins(:tags).where('tags.name' => array ) end so, finds records have tags taken comma separated list , converted array. currently matches records matching tags -- how can make work matches tags. ie: if if input: "blue, red" records tagged blue or red. i want match records tagged blue , red. suggestions? -- edit -- my models so: class photo < activerecord::base ... has_many :taggings, :dependent => :destroy has_many :tags, :through => :taggings ... def self.tagged_with( string ) array = string.split(',').map{ |s| s.lstrip } select('distinct photos.*').joins(:tags).where('tags.name' => array ) end ... end class tag < activerecord::base has_many :taggings, :dependent => :destroy has_many :photos, :th...

Buildr doesn't find JAVA_HOME from Intellij -

i have buildr installed on ubuntu , works fine running command line. i've installed buildr plugin intellij idea. can't run commands such compile ide. gives following message: /usr/local/bin/buildr compile (in /path/to/project, development) compiling scala-spike compiling scala-spike /path/to/project/target/classes buildr aborted! runtimeerror : forgetting something? java_home not set. but java_home is set. command echo $java_home prints correct path java installed. make sure passing java_home while starting idea.sh. try starting idea sh -c "export java_home=/opt/java && $idea/bin/idea.sh"

python local modules -

i have several project directories , want have libraries/modules specific them. instance, might have directory structure such: myproject/ mymodules/ __init__.py myfunctions.py myreports/ mycode.py assuming there function called add in myfunctions.py , can call mycode.py naive routine: execfile('../mymodules/myfunctions.py') add(1,2) but more sophisticated it, can do import sys sys.path.append('../mymodules') import myfunctions myfunctions.add(1,2) is idiomatic way this? there mention modifying pythonpath ( os.environ['pythonpath'] ?), or other things should into? also, have seen import statements contained within class statements, , in other instances, defined @ top of python file contains class definition. there right/preferred way this? don't mess around execfile or sys.path.append unless there reason it. rather, arrange code proper python packages , importing other library. if mymodules in fact part of...

cvs - Renaming Folder in wincvs -

i having folder named 'subfolder' inside 'mainfolder' in wincvs.now decided rename folder 'subfolder' make letters in lower case.so have deleted contents 'subfolder' folder , did refresh see 'subfolder' folder disappearing.then created new folder 'subfolder' inside 'mainfolder' folder , kept files there in old 'subfolder' folder inside , added folder , files repository.but whenever checking out cvs still getting folder 'subfolder' instead of 'subfolder'.any solutions ? cvs doesn't ever delete directories. it's dumb. in order see them "disappear", need turn on pruning during updates. i'm not sure how in wincvs.

Two "id" fields in one MongoDB collection with Rails 3? -

i've got rails 3.0.9 project using latest version of mongodb , mongoid 2.2. i imported csv "id" field mongodb collection named college, resulting in collection so: { "_id" : objectid("abc123"), "id" : ######, ... } observations: the show action results in url utilizing objectid displaying 'college.id' in index.html.erb displays objectid questions: how use original "id" field parameter is "id" reserved mongodb, meaning need rename "id" field in college collection (perhaps "code") - if so, how? thanks! update answer: db.colleges.update( { "name" : { $exists : true } } , { $rename : { "id" : "code" } }, false, true ) i used "name" since field check existence. _id reserved , required property in mongodb - think mongoid mapping id _id since makes sense. there might way access id property through mongoid think better off...

r - Breaking up a character string into multiple character strings on different lines -

i have data frame contains long character string each associated 'sample': sample data 1 000000000000000000000000000n01000000000000n0n000000000n00n0000nn00n0n000000100000n00n0n0000000nnnn011111111111111111111111111111110000000000000000000n000000n0000000000n 2 000000000000000000000000000n01000000000000n0n000000000n00n0000nn00n0n000000100000n00n0n0000000nnnn011111111111111111111111111111110000000000000000000n000000n0000000000n i code easy way break string 5 pieces in following format: sample x cct6 - characters 1-33 gat1 - characters 34-68 imd3 - characters 69-99 pdr3 - characters 100-130 rim15 - characters 131-168 giving output looks each sample: sample 1 cct6 - 000000000000000000000000000n01000 gat1 - 000000000n0n000000000n00n0000nn00n0 imd3 - n000000100000n00n0n0000000nnnn0 pdr3 - 1111111111111111111111111111111 rim15 - 0000000000000000000n000000n0000000000n i've been able use substr function break long string individual pieces id able automat...

java - In getAsObject arg2 is passed as null -

i using jsf2.0 tomcat 7 , have couple of selectonelistbox defined in page. these assigned empty arraylists below <h:selectonelistbox value="#{memberbean.currentavailable}" converter="memberconverter" size="10" style="width:150px;"> <f:selectitems value="#{memberbean.availablemembers}" var="member" itemvalue="#{member}" itemlabel="# {member.fname} #{member.lname}" /> </h:selectonelistbox> <h:panelgrid> <a4j:commandbutton value="add" render="groupmessage_page" listner="#{memberbean.moveavaiablemember}"/> <a4j:commandbutton value="remove" render="groupmessage_page" listner="#{memberbean.moveselectedmember}"/> </h:panelgrid> <h:selectonelistbox value="#{memberbean.current...

javascript - two commands are not running on browser please find the problem? -

two commands below not running on browser.......anybody please findout problem........ <script language="javascript"> var myvariable="my name sonia"; document.writeln(myvariable.big()); document.writeln(myvariable.blink()); document.writeln(myvariable.bold()); document.writeln(myvariable.fixed()); <!-- following 2 lines have problems --> document.writeln(myvariable.fontcolor(“red”)); document.writeln(myvariable.fontsize(“18pt”)); document.writeln(myvariable.italics() ); document.writeln(myvariable.small()); document.writeln(myvariable.strike()); document.writeln(myvariable.sub()); document.writeln(myvariable.sup()); document.writeln(myvariable.tolowercase()); document.writeln(myvariable.touppercase()); var finalstring = myvariable.bold().tolowercase().fontcolor("red"); document.writeln(finalstring); var newvar=myvariable.split(''); document.write(newvar); </script> it looks me used wrong double quotes in there...

iphone - how to sort an NSArray of nested NSArrays by array count? -

i have nsarray contains nested nsarrays. im looking way sort parent array according object count of nested arrays in ascending order. if [array1 count] 4, [array2 count] 2 , [array3 count] 9, : array2, array1, array3... there few solutions, 1 of is: nssortdescriptor *sd = [nssortdescriptor sortdescriptorwithkey:@"@count" ascending:yes]; nsarray *sds = [nsarray arraywithobject:sd]; nsarray *sortedarray = [array sortedarrayusingdescriptors:sds];

What's a good WordPress Plugin Architecture? -

i'm building wordpress plug-in i'm thinking first of looking open source 1 follows best practices , has architecture. what plug-in recommend? atahualpa personal favorite.

Java to Android conversion problems -

i have pretty complex java (jdk 6) code needs converted works on android. java code intended work graphics: have class extends jlabel (swing component), "paintcomponent" method reshapes extended jlabel ("cuts" circle) , draws on screen (i know, know - might use come "drawcircle" method need extend jlabel because has popup menu attached it). now, have problem - android don't seem have "graphics" type, "dimension" type, "rectangle" type, "paintcomponent" method , after all, have no idea control should use draw customized jlabels on (in jdk 6, have used jpanel container customized jlabels). please help! need advice on painless method converting given java logic android logic? android provides graphics , 2d graphics , used drawing. have @ shape drawable should assist in drawing rectangles. instead of jlabel use textview . have spend time in getting know android , redrawing gui, hope provided sta...

php - PHPUnit Test Suite - Cannot redeclare class Mocking & Concrete classes -

here problem. i have test suite testing few classes. classes use dependency injection. i have class called schedulehandler passes tests. other class rulehandler has method requires instance of schedulehandler. dont want pass in real schedulehandler tried create mock schedulehandler inject in. the problem have because schedulehandler class tested in suite above rulehandler, when mock created get:- php fatal error: cannot redeclare class schedulehandler if dont use test suite, , run tests individually fine. anyone know of way round ? my best guess far: var_dump(class_exists('schedulehandler', false)); returns false you. means class doesn't exist yet. if autoloader doesn't find class when phpunit trying extend phpunit create class it's self. if later down road require real class somewhere classes collide. to test make sure have required real schedulehandler class before creating mock object.

android - How can I disable scroll of a grid view -

this question has answer here: how disable gridview scrolling in android? 2 answers i have background image in gridview , want disable scroll of gridview, doesnt scroll image. how go doing this? try here if want avoid gridview scrolling

facebook - How much times per day my app can post to users wall -

have appid , secret key facebook , making test 1 acount create week ago, yesterday started make test posting account , working fine (im using facebookapi.cs dll), today after 10 post can anymore, test 2 diferent accounts , work fine, think there's limit of post per day user wall or similar, knows limit or time has pass until can make post in account again? in advance, , sorry english... are trying execute same post request(same content) frequently? if facebook block request cosidering spam. no specific values found in facebook graph documentation. but 600 requests per 600 sec found in facebook developer forum (not verified value) reference : http://forum.developers.facebook.net/viewtopic.php?id=56950

Visual studio - prevent linking of static library -

i creating static library in visual studio 2010. library statically linked of applications produce .exe. thing want .exe statically linked against c adn c++ library (don't want dependency on msvcp100.dll , msvcr100.dll). ever can't working. if link static library static c , c++ libs can't compile .exe - linker complains "already defined symbols". if link static library c , c++ dll .exe ends having dependency on msvcp100.dll , msvcr100.dll. how tell vs link static library static c , c++ libs when it's being linked in .exe? edit here fre linker errors when both static lib , .exe user /mt (i.e. static linking of runtime library): 1>msvcrt.lib(ti_inst.obj) : error lnk2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@aae@abv0@@z) defined in libcmt.lib(typinfo.obj) 1>msvcprt.lib(msvcp100.dll) : error lnk2005: "public: class std::locale::facet * __thiscall std::locale::facet::_decref(void...

apache - mapping non exist file -

if robots.txt non exist mupping on robots.php, if exist -return robots.txt rewriteengine on rewritecond %{robots.txt} !-f [nc] rewriterule robots.txt robots.php [l] this code return robots.php rewritecond %{request_filename} !-f rewriterule ^/robots\.txt/$ robots.php [l] think that's need...

java - check the value of a word inside a string -

i have string string example = "tag: id: somethingelse score: 0.8"; how can check if score higher/equal/lower 0. by using lastindexof , substring string object, can value string. string scorestr = example.substring(example.lastindexof("score:") + "score:".length()); double score = double.parsedouble(scorestr.trim()); now, can if ... else if statement on score . ps: if want returned float, change last line so: float score = float.parsefloat(scorestr.trim());

copy data from one field to another mysql mulitple rows -

i want copy data 1 field mysql mulitple rows. i've tried following not working , mysql says " returns more 1 row " update agreement set _date2 = (select concat(substring(_date, 7), '-', substring(_date, 4, 2), '-', substring(_date, 1, 2)) newdd agreementtemp); try update `table_name` set destination_field=source_field

jquery - TinyMCE Interst existing HTML -

ok, have div, when click on div, insert textarea, add tinymce controll textarea. ok, type in wsgi editor , press save save it. then html form tinymce editor gets saved, , textarea , tinymce element removed , html tinymce inserted in div again. that works nice, now, when click on div, html, want html display inside tunymce editor. this have done, once click on div, adds html, removes it, why happening? // click on div element $(".editable").live("click", function(e){ var f = $(this); // html if there html = f.html(); // insert textarea unique id f.html('<textarea class="item_html" id="'+ e.timestamp +'"></textarea> ') f.css("height","100%") //add tinymce control textarea tinymce.execcommand( 'mceaddcontrol', false, f.find("textarea").attr("id") ...

ruby - How can I read WKT from the shapefile .prj? -

i building system lets users upload shapefiles. converts shapefiles postgis using shp2pgsql . command requires srs id in form of epsg code. so need ruby gem can read shapefile's *.prj file (which contains projection/spatial reference system encoded wkt) , return corresponding srs id. i'm not sure how ruby bindings work gdal, osr (part of gdal) can extract either projection wkt (text) or srid (integer). see this gis.se answer solution python/gdal/osr. update: turns out ruby bindings work nicely expected. going, try code: require 'gdal/osr' prj_fname = 'myfile.prj' prj = file.open( prj_fname ) # import wkt prj file srs = gdal::osr::spatialreference.new() srs.import_from_wkt( prj.read ) # various exports puts srs.export_to_wkt srs.auto_identify_epsg puts srs.get_authority_name(nil) puts srs.get_authority_code(nil) if need other aspect of projection, explore available public methods: srs.public_methods.sort

Preferred Scala collection for progressively removing random items? -

i have algoritm takes many iterations, each of scores items in collection , removes 1 highest score. i populate vector initial population, continually replacing var , or choose mutable collection val . of mutable collections best fit bill? you consider doublelinkedlist , has convenient remove() method remove current list cell.

android - Java handling XML using SAX -

i've got xml need parse given structure: <?xml version="1.0" encoding="utf-8"?> <root> <tag label="idad"> <child label="text">text</child> </tag> <tag label="idnumpage"> <child label1="text" label2="text">text</child> </tag> </root> i use sax parser parse it: rootelement root=new rootelement("root"); android.sax.element page_info=root.getchild("tag").getchild("child"); page_info.setstartelementlistener(new startelementlistener() { @override public void start(attributes attributes) { /*---------------*/ } }); i want read second "tag" element attributes( label1 , label2 ), startelementlistener reads first tag, because have same structure , attributes(those label="idad" , label="idnumpage" ) distinguis...

unable to open program using php -

i have tried exec, system , not able open notepad even. using xampp on windows 7. system("cmd /c notepad"); works here (notepad opened), should realize 2 things: if you're running apache service, won't have notepad windows pop because service running user in non-interactive fashion. it's normal no response long (perhaps indefinitely) because wait program finish. see proc_open or popen more control.

linux kernel - Howto create 100M Byte Buffer -

i testing throughput of interface on linux. using dma todo data transfer. dma needs contiguous memory location. kmalloc unable allocate more 1mb. there other way create big buffer location upto 100m bytes? i thought kmalloc couldn't allocate on 128kb, how did allocate 1mb ? anyway, assuming you're working on freshly booted system, can reserve 2048 contiguous pages. pages 4k, makes 8mb. _get_free_pages(_gfp_dma, get_order(2048)); however, if need more memory, should allocation @ boot-time. if writing driver, can achieved alloc_bootmem_* functions. if writing module, have pass mem= argument kernel , later use ioremap . for example, if have 2gb, can pass mem=1gb forbid kernel using upper 1gb, , later call ioremap(0x40000000, 0x40000000) access upper 1gb, you. but know, should split huge buffer many small ones, it'll easier , more real-life applications.

jquery - CSS issue - I want the client area totally filled -

i struggle css. trying mod sliding door technique opens onto full-client area div, cannot full client area filled up. modding here: http://web.enavu.com/tutorials/sliding-door-effect-with-jquery/ here code: <!doctype html> <html> <head> <title>title</title> <style type='text/css'> .box_container{ position:relative; /* important */ width:100%; /* must set specific width of container, doesn't strech when image starts moving */ height:100%; /* important */ /*min-width: 100%;*/ /*min-height: 100%;*/ overflow:hidden; /* hide content goes out of div */ /*just styling bellow*/ background: black; color:white; } .images_holder { width: 100%; height: 100%; position:absolute; /* important, div positioned on top of text */ } .image_div { position:relative; /* important can work left or right indent */ o...

css - Most efficient way of having 100% header and wrapper with fixed content within? -

what efficient way of having 100% header, fixed width content, , 100% footer? i'm trying limit divs maximum, i'm quite stuck... anybody help? thx lot here simplest version: <div class="header"> <p>header</p> </div> <div class="main"> <p>content</p> <p>content</p> <p>content</p> </div> <div class="footer"> <p>footer</p> </div> css: div { margin:0 auto; } .main{ width:400px; } http://jsfiddle.net/madmartigan/adkff/3/ here version header , footer's inner content fixed width align main content: http://jsfiddle.net/madmartigan/adkff/1/ 3 divs simple can go, assumed wanted minimize divs , not "limit divs maximum" :)

c# - Why can't static classes have non-static methods and variables? -

why can't static classes have non-static methods , variables when non-static classes can have static methods , variables? what advantage of having static methods , variables in non static class? though having static constructor in non-static class understandable. static classes can't instantiated in first place, if declare non-static (instance) members, can never accessed. since there isn't point allowing reason, language prohibits it. bear in mind static classes just classes , while there 2 things directly related non-static classes: the classes themselves, , the instances/objects of classes. a non-static class can have both static , non-static members static members apply class, whereas non-static members apply instances of class.

.net - Style guide / optimal way to layout web.config & app.config for ongoing support -

config files have grown complex have suggested their own programming language. if take analogy further, make sense have consistencies when editing file. i going limit question wcf, sensitive smallest configuration change, think other sections (web.config) benefit structure well. given vs2010 handle indentation of file, other standards applicable when updating config file? ideas came : sort <config sections> alphabetically the name identifier within <config sections/> should pushed left alternatively group identifiers , config sections similar function i'm guessing guidance may vary between specialties (web vs wcf vs identity model) i'd appreciate hearing own perspective. i (until forces opposite) sort alphabetically (sections, nodes, subnodes), except sections' declaration, have going first.

c - CUDA issue in a simple program -

i've spent time trying find out going on? problem i'm not able invoke simple kernel host code. i'm sure error notable people feel i'm wasting lot of time without reason probably. i'd appreciate help. this .cpp code #include <stdio.h> #include <stdlib.h> #include <math.h> #include <time.h> #include <windows.h> #include <shrutils.h> #include <cutil_inline.h> #include <cutil_gl_inline.h> #include <cuda.h> cufunction reduce0; //i've used many ways declare kernel function,but..... int main( int argc , char *argv[] ){ int i,n,sum; int *data; int *md; srand ( time(null) ); n=(int)pow((float)2,(float)atoi(argv[1])); data=(int *)malloc(n * sizeof(int)); (i=0;i<n;i++){ data[i]=rand() % 10 + 1; } cudamalloc((void**) &md, n ); clock_t start = clock(); dim3 dimblock(512,0); dim3 dimgrid(1,1); reduce0<<< dimgrid,dimblock ...

.net - How to record high quality videos with Windows Media Encoder in C# -

i created software recording screen activity of windows media encoder tutorial.. having serious problems quality. seems quality of video bad. know how can around this, i'm guessing has setting format of output, don't know how this. thanks note windows media encoder no longer offered download microsoft, may want consider moving technology. without seeing of code @ all, can't comment on doing. however, have used wme in past , can offer bit of advice. choose 1 of high quality profiles, or consider making own. used use cbr profile of 5000 kbps achieve high quality encodes. note higher quality, more disk space used. fill if encoding lot of video.

c - buffer overflow problem -

after reference this website , want simulate simple buffer overflow bug environment ubuntu 10.10 gcc version 4.4.5 download execstack enable executable stack of file. following code char code[] = "\x90\x90\x90\x6a\x00\xe8\x39\x07\x00\x00\x90\x90\x90";< char msg[] = "run !!\n"; int main() { int *ptr; int i; for(i=1;i<128;i++){ ptr = (int *)&ptr + i; (*ptr) = (int)code; } return 0; } i use gcc -fno-stack-protector -g -static -o main.out main.c compile source code. when use gdb debug executable file, weird happened. here gdb output looks like: (gdb) x/i 0x8048492 0x8048492 <__libc_start_main+402>: call 0x8048bd0 <exit> (gdb) x/5b 0x8048492 0x8048492 <__libc_start_main+402>: 0xe8 0x39 0x07 0x00 0x00 (gdb) x/i 0x80ce02e 0x80ce02e <code+6>: call 0x80ce76c <_dlfcn_hooks+44> (gdb) x/5b 0x80ce02e 0x80ce02e <code+6>: 0x...

Which would be the proper way to install one publisher policy in to the GAC using WIX? -

which proper way install 1 publisher policy in gac using wix 3.5 ? i tried this: <file id="libgac" assembly=".net" keypath="yes" vital="yes" name="classlibrary1.dll" processorarchitecture="msil" diskid="1" source="..\classlibrary1\bin\release\classlibrary1.dll" > </file> </component> <component id="config" guid="f089b1aa-b593-4662-9df4-f47eb9fba1f4" > <file id="libgacpolicy" assembly=".net" keypath="yes" vital="yes" name="policy.1.0.classlibrary1.dll" diskid="1" source="..\classlibrary1\policy.1.0.classlibrary1.dll" > </file> <file ...