Posts

Showing posts from January, 2010

wordpress - Getting SVG to work on Android 2.* -

i creating website , it's using svg images due retina support. had use modernizer swap svg .png , use alternative .pngs ie8. i have problem images not showing on samsung galaxy ace android version 2.3.6. how can phone support svg images? thank kind people. the stock android browser didn't start supporting svg until android version 3.0, see http://caniuse.com/#feat=svg . you can find alternative free browsers support svg on android 2.3, such opera mobile (disclaimer: work @ opera). the modernizr solution should work fine ( see guide ), though pngs in stock browser on android 2.3.

jquery - javascript function doesn't execute -

hi,i have simple login form, fields validated javascript. don't why below code not working. my html , js code: <head> <script type="text/javascript"> function handlelogin() { var u = $("#username").val(); var p = $("#password").val(); if(u=="a" && p=="a") { window.location="/site/site.html"; } else { alert("fail"); } } </script> </head> <li dojotype="dojox.mobile.listitem"> <input dojotype="dojox.mobile.app.textbox" placeholder="username" type="text" id="username" name="username" /> </li> <li dojotype="dojox.mobile.listitem"> <input dojotype="dojox.mobil

Ruby: Understanding _why's cloaker method -

i'm trying understand _why's cloaker method wrote in " a block costume ": class html def cloaker &blk (class << self; self; end).class_eval # ... rest of method end end end i realise class << self; self; end opens eigenclass of self , i've never seen inside instance method before. self @ point this? under impression self should receiver method called on, cloaker called inside method_missing : def method_missing tag, text = nil, &blk # ... if blk cloaker(&blk).bind(self).call end # ... end so self inside method_missing call? , self when call: ((class << self; self; end).class_eval) inside cloaker method? basically, want know whether we opening eignenclass of html class, or if doing specific instance of html class? inside cloaker method, self instance of html since you'll call on object, you're creating singleton method on html class instances. instance: class

exception - java.io.EOFException When trying to read a serialized object -

i have serialized data object file , tried read object inside servelet.im getting below exception java.io.eofexception @ java.io.objectinputstream$peekinputstream.readfully(unknown source) @ java.io.objectinputstream$blockdatainputstream.readshort(unknown source) @ java.io.objectinputstream.readstreamheader(unknown source) @ java.io.objectinputstream.<init>(unknown source) my code is fileinputstream fin; try { fin = new fileinputstream( "g:\\search\\webapp\\datamanager\\wslist" ); objectinputstream ois = new objectinputstream( fin ); inforpc newobj = ( inforpc ) ois.readobject(); newobj.getcategories(); ois.close(); return newobj; } catch ( filenotfoundexception e ) { e.printstacktrace(); } catch ( ioexception e ) { e.printstacktrace(); } catch ( classnotfoundexception e ) { e.printstacktrace(); } any idea ?

terminal - Bower: Install 2 versions of jQuery -

how go installing 2 versions of jquery using bower ? want have v2.0 1.9.1 browser support fallback the issue i'm having if run bower install jquery#1.9.1 jquery#2.0.0 first version gets overwritten second because same component in dependencies part of bower.json can have this: "dependencies": { "jquery": "2.0.0", "jquery-1.9.1": "http://code.jquery.com/jquery-1.9.1.js" } one shouldn't have this, have maintain / migrate existing website (for whatever reason) uses different versions of jquery in different pages!

windows - Diagnostic Monitor Trace Listener -

i know if possible modify way trace recording trace information ? trace.listeners.add(new diagnosticmonitortracelistener()); trace.traceinformation("onstart"); i able use current wadlogstable , adding 1 or more custom columns table. right default table created diagnosticmonitorconfiguration looks that: partitionkey|rowkey|timestamp|eventtickcount|deploymentid|role|roleinstance|level|eventid|pid|tid|message| i add @ end custom columns : partitionkey|rowkey|timestamp|eventtickcount|deploymentid|role|roleinstance|level|eventid|pid|tid|message|custom1|custom2 so every time trace able add data 2 custom columns thanks i don't think you'll able this. while windows azure diagnostics quite extensible, you'll not able modify schema trace logging. recommend looking implementing custom diagnostics. may find link useful this: http://convective.wordpress.com/2009/12/08/custom-diagnostics-in-windows-azure/ .

bash - crontab failed with exit status 12 -

from syslog may 8 01:00:01 mvtspro-main /usr/sbin/cron[22645]: (root) cmd (/usr/local/ky4k0b/cdrs_backup_daily.sh) may 8 01:00:01 mvtspro-main /usr/sbin/cron[22638]: (cron) error (grandchild #22645 failed exit status 12) from /etc/crontab mvtspro-main:/cdrs/backup# cat /etc/crontab shell=/bin/sh path=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin # m h dom mon dow user command 17 * * * * root cd / && run-parts --report /etc/cron.hourly 25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily ) 47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly ) 52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly ) # 25 6 * * * root ntpdate pool.ntp.org 0 1 * * * root /usr/local/ky4k0b/cdrs_backup_daily.sh 0 2 1 * * root /usr/local/ky4k0b/cdrs_backup_monthly.sh 0 3 1 * *

SFML 2.0 c++ projectiles -

i have projectile firing tank. @ moment works fine, unable "re-use" projectiles once have either hit target, or gone off screen. code using @ moment; //laser shape sf::texture lasertexture; lasertexture.loadfromfile("images/laser.png"); std::vector<sf::sprite>laser(1000, sf::sprite(lasertexture)); this if statement when keyboard pressed: if (event.key.code == sf::keyboard::space) { if (lasercount==1000) { lasercount=0; } /*if (sf::keyboard::iskeypressed(sf::keyboard::space)) { }*/ laserspeed=4; lasercount++; laser.play(); std::cout << "laser count = " << lasercount << std::endl; } and clock counter firing missile: s

asp.net mvc 3 - Linq query filter by date (Month and year) -

public class content { public int id { get; set; } public string name { get; set; } public datetime date { get; set; } } id name date 1 content1 01/01/2013 2 content2 05/01/2013 3 content3 05/03/2013 4 content4 01/06/2013 5 content5 10/03/2012 6 content6 01/01/2012 i'm trying if query passes '01/2013', query should return content id 1,2 . there knows how query above situation ? looks should able do: // type , property names changed match .net conventions public ienumerable<content> getcontents(int year, int month) { return db.contents // or wherever you're getting data .where(c => c.date.year == year && c.date.month == month); } i've split out year , month separate parameters, that's how described them - if want able handle "01/2013" want split '/' , parsing each of pieces integer first. (alternatively, parse date in specific

azure - service bus 1.0 not showing up in windows platform installer 4.5 -

i trying install service bus 1.0 on developer machine. when searching "service bus 1.0" in web platform installer 4.5, not able find it. i downloaded .exe file manually http://go.microsoft.com/fwlink/?linkid=252361 . when setup runs, gives me error message in web platform installer "microsoft web platform installer couldn't find product tried install. either link clicked incorrect or may overriding feed different feed." i checked feed , set "default" . my operating system windows 7 sp1 enterprise edition. vs 2010 , v2012 installed. have sql server 2008 r2 express any idea causing problem? it turned out os 32 bit , requires 64 bit os.

Dynamically select the value of a select item javascript/jquery -

i have select list of options, , when user selects 1 of options, want dynamically select same option on similar select list on page. so these 2 lists: <select id='b_orientation'><option>horizontal</option><option>vertical</option></select> <select id='orientation'><option>horizontal</option><option>vertical</option></select> now after user changes b_orientation , want orientation mirror change. relevant line of code that: $('#orientation').val($('#b_orientation')); but doesn't make difference orientation . why not? you forgot mention val() as of adding element not element's value . change line $('#orientation').val($('#b_orientation').val());

android - Uncaught ReferenceError: FileTransfer is not defined (using cordova 2.7.0) -

i want use filetransfer download file web server, code following: function downloadfile(url) { var filetransfer = new filetransfer(); var uri = encodeuri(url); var filepath="www/download/"; filetransfer.onprogress = function(progressevent) { if (progressevent.lengthcomputable) { loadingstatus.setpercentage(progressevent.loaded / progressevent.total); } else { loadingstatus.increment(); } }; filetransfer.download( uri, filepath, function(entry) { console.log("download complete: " + entry.fullpath); }, function(error) { console.log("download error source " + error.source); console.log("download error target " + error.target); console.log("upload error code" + error.code); }, false, { headers: { } } ); } when run app in simulator or real devide, hit erro

ios - UILabel text issue -

Image
i have issue label text. label text not dislay text thats get. put nslog , able see text, label reasom cant. my code: -(void)viewdidload { [super viewdidload]; [_scroller setscrollenabled:yes]; [_scroller setcontentsize:cgsizemake(250, 420)]; self.description = [_description stringbytrimmingcharactersinset:[nscharacterset whitespaceandnewlinecharacterset]]; if ([self.description isequaltostring:@""]) { self.description = @"ללא תקציר"; } [self positionlabel:self.lbltitle withtext:self.stitle withy:10]; [self positionlabel:self.lblpubdate withtext:self.pubdate withy:cgrectgetmaxy(self.lbltitle.frame)+10 ]; [self positionlabel:self.lbldescription withtext:self.description withy:cgrectgetmaxy(self.lblpubdate.frame)+25 ]; -(void)positionlabel:(uilabel*)lbl withtext:(nsstring*)text withy:(cgfloat)y { lbl.textalignment = uitextalignmentright; lbl.text = text; lbl.numberoflines = 0; lbl.linebreakmode =

ruby - rails tutorial 2nd edition. chapter 6.3.4 -

i hope can help. going through michael hartl's rails tutorial book , stuck on chapter 6.3.4 . trying tests validate , keep getting several errors. have posted error messages , user.rb , user_spec.rb file reference. can see going wrong. appreciated. errors failures: 1) when email address taken ←[31mfailure/error:←[0m ←[31muser_with_same_email = @user.dup←[0m ←[31mtypeerror:←[0m ←[31mcan't dup nilclass←[0m ←[36m # ./spec/models/user_spec.rb:69:in `dup'←[0m ←[36m # ./spec/models/user_spec.rb:69:in `block (5 levels) in <top (required )>'←[0m 2) when password not present ←[31mfailure/error:←[0m ←[31mbefore { @user.password = @user.password_confi rmation = " " }←[0m ←[31mnomethoderror:←[0m ←[31mundefined method `password_confirmation=' nil:nilclass←[0m ←[36m # ./spec/models/user_spec.rb:78:in `block (5 levels) in <top (required )>'←[0m 3) when password doesn't match confirmation

c++ - Recursive largestS integers -

int* m = new int [d1*d2]; this array. ( j = 0; j < d2; j++ ) { ( = j; < d1*d2; +=d2){ cout << *(m+i); } cout << endl; } and using can group , print largest integer in each column if think multidimensional array. hard explain want do. i'll try giving example. assume input 1 4 2 5 2 1 0 3 4 output 1 5 0 4 2 3 2 1 4 i want largest integer , keep listing following largest integers behind of integer. for first row want 5, 0 for second row want 4 , 3. for third row want 4. output be: 5, 0, 4, 3, 4 if a[] contains row, looks want is: int = column_count - 1; deque<int> largests_list; largests_list.push_front(a[i]); int largest_found = a[i]; while (i-- > 0) { if (a[i] > largest_found) { largests_list.push_front(a[i]); largest_found = a[i]; } }

asp.net - Debug SimpleMembershipProvider source -

i went through article ( http://msdn.microsoft.com/en-us/library/cc667410.aspx ) shows how 1 can debug asp.net source code. now, i'm having serious trouble using new simplemembershipprovider in webmatrix.webdata namespace, , want debug it, i'm not able to. when try step websecurity.createaccount method, steps on method call. i'm using visual studio 2012 ultimate. missing? is webmatrix.webdata third party dll? if so, might need decompile it, source , add source solution. otherwise don't think you'll able set it.

c# - What are my controller in my application with a MVVM design pattern -

i have developed wpf-application. have mainwindow inherit window, tabcontrol , many tabitems in tabcontrol inherit usercontrol. every tabitem has own cs-file, code in c# businesslogic, , xaml-file development of ui done. have sql server database connect trough linq. so have write choice of controller use in application. confused, since havent manually programmed controller , thought viewmodel behave controller in case. correct? can viewmodel behave controller? a controller can send commands associated view change view's presentation of model (e.g., scrolling through document). can send commands model update model's state (e.g., editing document). model_view_controller the viewmodel “model of view” meaning abstraction of view serves in mediating between view , model target of view data bindings. seen specialized aspect of controller (in mvc pattern) acts converter changes model information view information , passes commands view model. view model exposes publi

android update/install version checking -

i'm new in android developing. (and in developing after all) here problem: if install android application onto mobile device or avd, want check current app version number , if it's lower 1 want install install it, , if higher , alert users use latest version. because when install .apk file, installs app again , nothing happens. is possible develop this? best regards, weeyas the install process managed @ system level, application has no control on it. per versioning guide , android system allow install updates same or newer version codes (i.e., version 1 can replaced version 2, version 2 can never overridden version 1 unless complete uninstall/reinstall). applies both google play updates , sideloading apks yourself.

how to return a char array from a function in C -

i want return character array function. want print in main . how can character array in main function? #include<stdio.h> #include<string.h> int main() { int i=0,j=2; char s[]="string"; char *test; test=substring(i,j,*s); printf("%s",test); return 0; } char *substring(int i,int j,char *ch) { int m,n,k=0; char *ch1; ch1=(char*)malloc((j-i+1)*1); n=j-i+1; while(k<n) { ch1[k]=ch[i]; i++;k++; } return (char *)ch1; } please tell me doing wrong? #include<stdio.h> #include<string.h> #include<stdlib.h> char *substring(int i,int j,char *ch) { int n,k=0; char *ch1; ch1=(char*)malloc((j-i+1)*1); n=j-i+1; while(k<n) { ch1[k]=ch[i]; i++;k++; } return (char *)ch1; } int main() { int i=0,j=2; char s[]="string"; char *test; test=substring(i,j,s); printf("%s&q

javascript - JSF execute Ajax before a onClick Event -

i have javascript function changes position of elements according hiddenfields in document, updated regularly ajax. problem: since javascript function (onclick) executed before ajax (which reloads element in hiddenfields are) elements should change position 1 turn behind. what want achive: the problem solved if ajax reload executed before onclick event, reference hiddenfields correct. (and not on turn behind) is possible in way or there solution problem?? code: call: <h:commandbutton id="dice" onclick="animate()" alt="w&uuml;rfel mit einer eins" image="resources/img/wuerfel1.png" action="#{spiel.dice()}" tabindex="4" title="w&uuml;rfel mit einer eins"> <f:ajax render="gameinfo" /> </h:commandbutton> javascript function: function animate() { var newplayer1 = document.g

How to pause/resume repository cloning in mercurial? -

i've needed clone development tree of large projects (e.g. https://hg.mozilla.org/mozilla-central ), problem i'm on slow unstable connection , may not clone repository in single pass. is possible pause/resume cloning process somehow? to clone large repository in multiple passes, can use --rev option on clone command . example: hg clone --rev 100 <remote url> <local path> cd <local path> hg pull --rev 200 hg pull --rev 300 etc see this related question .

perl - Dynamical array as a class member -

there following class: package myclass; use strict; use warnings; sub new { $class = shift(); $self = { _class_array => [] }; bless ($self, $class); return $self; } how can set/get add values array? i tried following code: sub adddatatype { $self = shift(); $new_element = shift(); @array = $self->{_class_array}; print("number of elements ".($self->{_class_array})."\n"); push(@array, $new_element); $self->{_class_array} = @array; print("element added. number of elements ".($self->{_class_array})."\n"); } the output following: number of elements array(0x21bb4c) element added. number of types 2 number of elements 2 element added. number of types 2 number of elements 2 element added. number of types 2 questions are: what mean: number of elements array(0x21bb4c) ? why array length stays 2 ? you using arrayref array.

web applications - Access json file in web app folder from gsp grails? -

i have json file called flare.json in web-app folder of grails application. i have gsp called test.gsp in folder called reports views folder. i have script in test.gsp needs take json file input can't seem access it.. i've tried several different ways have had no luck far. example i'm looking @ uses following line : d3.json("flare.json", function(error, data) { ..... i have tried same , several other variations keep getting 404 errors saying resource can't found. i'm new @ grails. have missed something? you can try g.resource create link json file. d3.json('${g.resource(file: "flare.json")}', function(error,data){});

preprocessor - Adjust data vector to have certain variance -

i have set of integers x, 0<=x<=255 need transform data in way : average of values in set == 0 variance == 1 i can meet first condition with: array arr[]; av = average(arr); foreach(x in arr) { x = x - av;} but not know, how meet second one. the best idea have: compute current variance , divide or multiply integers closer desired variance. a=a/2 , repeat until error small. (resembles basic algorithm of estimating square root of x.) is there (more efficient) way of achieving this? after meeting first condition, need divide every number standard deviation.

linux - Bash, splitting files from directory into groups by size (low peformance) -

i have problem bash script split files directory groups each group size 1gb. i have script looks this: #!/bin/bash path=$1 unset echo $path start fpath=`pwd`"/files" find "$path" -type f>files max=`wc -l $fpath | awk '{printf $1}'` while read file; files[i]=$file size[i]=$(du -s $file | awk '{printf $1}') ((i++)) echo -ne $i/$max'\r' done < `pwd`"/files" echo -ne '\n' echo 'sizes , filenames done' unset weight index groupid item in ${!files[*]}; weight=$((weight+${size[$item]})) group[index]=${files[$item]} ((index++)) if [ $weight -gt "$((2**30))" ]; ((groupid++)) filename in "${group[@]}" echo $filename done >euenv.part"$groupid" unset group index weight fi done ((groupid++)) filename in "${group[@]}" echo $filename done >euenv.part"$groupid" echo 

Minecraft Mod to create files and folders -

i'm creating mod minecraft. it's computer mod , need store files , folders user creates on computer computers own personal folder. each instance of computer folder computers number created , folder of files , folders inside of specific computer loacated instance: folders in directory c:/mc/mods first computer have folder c:/mc/mods/1 second c:/mc/mods/2 , on computercraft does. problem despite many attempts , research have been able create neither folders nor files. here code looks upon block being placed. file file = new file("c:/mc/mods"); if (file.isdirectory() == false) { file.mkdir(); } string s = "c:/mc/mods/1"; file = new file(s); int iii = 2; while (file.isdirectory()) { string ss = s.substring(0,s.length() - 1); s = ss + iii; file = new file(s); iii += 1; } file.mkdir(); file = new file("c:/mc/mods/locs.txt"); try { file.createnewfile(); } catch (exception e) { system.out.println(e); } try { printwriter ou

Copy upper triangle to lower triangle in a python matrix -

iluropoda_melanoleuca bos_taurus callithrix_jacchus canis_familiaris ailuropoda_melanoleuca 0 84.6 97.4 44 bos_taurus 0 0 97.4 84.6 callithrix_jacchus 0 0 0 97.4 canis_familiaris 0 0 0 0 this short version of python matrix have. have information in upper triangle. there easy function copy upper triangle down triangle of matrix? if understand question correctly, believe work for in range(num_rows): j in range(i, num_cols): matrix[j][i] = matrix[i][j]

iphone - UIBarButtonItem:setBackgroundVerticalPositionAdjustment not working properly with custom button -

Image
i have following code customize display of uibarbuttonitem (locationbutton): uibutton *locationbuttonaux = [uibutton buttonwithtype:uibuttontypecustom]; [locationbuttonaux setframe:cgrectmake(0, 0, location_button_width, location_button_height)]; [locationbuttonaux setbackgroundimage:[uiimage imagenamed:@"location_button.png"] forstate:uicontrolstatenormal]; [locationbuttonaux setbackgroundimage:[uiimage imagenamed:@"location_button.png"] forstate:uicontrolstatehighlighted]; [locationbuttonaux addtarget:self action:@selector(userlocation) forcontrolevents:uicontroleventtouchupinside]; uibarbuttonitem *locationbutton = [[uibarbuttonitem alloc] initwithcustomview:locationbuttonaux]; uibarbuttonitem * item = [[uibarbuttonitem alloc] initwithtitle:@"title" style:uibarbuttonitemstyledone target:nil action:@

PHP read everything until first comma -

i have string this: $string = "hello, my, name, is, az"; now wanna echo whatever there before first comma. have been using following: echo strstr($this->tags, ',', true); and has been working great, problem works php 5.3.0 , above. on php 5.2. i know achieve through regular express pregmatch suck @ re. can me this. regards, <?php $string = "hello, my, name, is, az"; echo substr($string, 0, strpos($string, ',')); you can (and should) add further checks avoid substr if there's no , in string.

c# - Groupbox foreach not finding all textboxes -

i trying find textbox have entered information on form , make rest of textboxes within form blanked out , locked no information can entered them. the problem when run code , debug. not seem finding textboxes on form when looping through them. i have tried change of information in foreach trying find if groupbox name.equals , if items within groupbox equal text. assume have made mistake foreach statements. below code. foreach (control c in this.controls) { if (c groupbox) foreach (control t in this.controls) { if (t textbox) { { if (t.text != string.empty && t.name.equals("txtlotno")) { txtheads.enabled = false; txtheads.backcolor = color.lightgray;

google chrome - More complex Flex layout -

only trying achieve layout in chrome . names in layout classes, have bit less confusing orientation in there layout use: (the "nothing changed" part 1 class "info") |------------------------------| | | | header | |------------------------------| | | | | | info | | |-----------------------| | | | | | | | | | nav | | | | | menu | main | | | | | | | | | | | | | |------|------|----------------| link existing example bit messed layout. trying http://codepen.io/akxe/pen/chizx your code large understand, started scratch , made simple template here pen: http://codepen.io/chaitan94/pen/vfgek i made widths using percentages, basic fluid template. hope helps!

java - Code structure with Asynctask Android -

i guess producing "spaghetti-code". perhabs experts can me write better code solution. following pseudocodes show problem: i have procedures runs long. procedures show progressbar. use asynctasks achieve this. works fine, code not maintainable anymore : my wish leave simple code without nesting code : public void oncreate(bundle savedinstancestate) { longrunningtask1(); dosomething1(); longrunningtask2(); dosomething2(); longrunningtask3(); dosomething3(); longrunningtask4(); dosomething4(); } my code asynctasks : public void oncreate(bundle savedinstancestate) { new longrunningtask1().execute("task1"); } class longrunningtask1 extends asynctask<string, void, boolean> { private exception exception; protected rssfeed doinbackground(string... urls) { try { do; return true; } catch (exception e) { return null; } } protected voi

javascript - jQuery .delegate not working -

the following code works toggle class when page loads, not work after ajax call. the html ([field_map_location] drupal token): <div class="clearfix dir-map"> <a href="#" class="show">map</a> <div id="slidingdiv" class="outside"> [field_map_location] </div> </div> the javascript: <script type="text/javascript"> jquery(function($) { $(document).ready(function() { $('.dir-map').delegate('a', 'click', function(e) { e.preventdefault(); $(this).next('div').toggleclass('outside inside'); }); }); }); </script> update i've tried following recommended solution , still not work. <script type="text/javascript"> jquery(function($) { $(document).delegate('.dir-map a', 'click', function (e) { e.preventdefault(); $(this).next('div').toggleclass(

masm32 - Creating a BSOD with assembly in protected mode -

i looking , couldn't find quick , easy way bsod computer in assembly. i'm using masm x86. i'm new @ assembly , want make version or russian roulette computers. keep hitting enter , if lose computer gets blue screen of death. fun few friends. imagine possible because there few post said in c ending process in windows (crss.exe believe). figured since assembly lower level done well. bsod result of error in kernel mode. tools use create error not matter, can assembly, c or other language exists in windows kernel. in user mode there no direct way create bsod, independent of language used. mentioned in comments - user mode code can trigger bsod in case of exploiting flaw in system, allowing breach kernel space.

php - How to get url the same as page title -

i wonder whether can accomplish following? i have dynamic webpage; url of page result of dynamic process. , looks mysite.com/cars/850#.rrptwxgg8 the metadata retrieved automatically , looks like <meta name="title" content="cheap ford taurus in paris" /> how can make url like: mysite.com/cars/cheap-ford-taurus-in-paris hey homes (homeslice), i answered similar question looks relevant problem: do need generate new php file every virtual page created site member?

Configure working directory of Scala worksheet -

i working directory scala worksheet (and scala interpreter) eclipse project path rather eclipse installation directory. how can (non programmatically) achieve that? i know can use system.setproperty("user.dir", "...") , imho not belong in code. further, not seem work: object scratchws { system.setproperty("user.dir", "c:\\") //> res0: string = c:\adt-bundle-windows-x86_64-20130219\eclipse new file("putty.exe").exists() //> res1: boolean = false new file("c:\\putty.exe").exists() //> res2: boolean = true } as of scala worksheet 0.2.1 not possible control worksheet working directory. for security reasons, once jvm running, not (directly) possible change jvm's working directly. see changing current working directory in java? details. therefore, practice specify qualified paths, or specify relative paths qualified "anchor point". here'

Installing distribute in Python 3.3 Ubuntu -

i running ubuntu 12.04 , have distribution of python 3.3.1 installed. want install packages, first sought install distribute-0.6.38. during "install" phase, encountering following runtime error ($home location of python3.3 installation): file "$home/python-3.3.1/lib/zipfile.py", line 583, in _check_compression "compression requires (missing) zlib module" runtimeerror: compression requires (missing) zlib module i tracked through files , function calls, cannot tell why creation of zipfile (i assume root of error) failed. is there missing package? or there issue fact secondary installation of python? it issue fact installed python source. you need install zlib1g-dev package provide headers python able compile in zlib support: sudo apt-get install zlib1g-dev you may missing other dependencies; here list of packages i'd install if compile python on ubuntu machine: build-essential libncursesw5-dev libreadline5-dev libssl-dev lib

getting rdf xml:attribute in sparql query -

given rdf: <?xml version="1.0" encoding="utf-8"?> <!doctype rdf:rdf [<!entity rdf 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'> <!entity rdfs 'http://www.w3.org/2000/01/rdf-schema#'> <!entity xsd 'http://www.w3.org/2001/xmlschema#'>]> <rdf:rdf xmlns:xsd="http://www.w3.org/2001/xmlschema#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dnr="http://www.dotnetrdf.org/configuration#" xml:base="http://www.example.org/"> <rdf:description rdf:about="fadi"> <ns:be xmlns:ns="http://example.org/">nice</ns:be> </rdf:description> <rdf:description rdf:about="fadi"> <ns:not xmlns:ns="http://example.org/" xml:starttime="00:00:13" xml:endtime="00:00:16">go

java - Unparsable date exception MM/dd/yyy hh:mm:ss a z -

string inputstr = "05/01/2012 10:51:47 am pdt"; string inputfmt = "mm/dd/yyyy hh:mm:ss z"; simpledateformat dflong = new simpledateformat(inputfmt);; date localmodifieddate = dflong.parse(inputstr); system.out.println(localmodifieddate); gives me unparsable date exception your default locale may not capable of parsing am/pm marker and/or timezone. try english locale : simpledateformat dflong = new simpledateformat(inputfmt, locale.english);

c++ - Can we say bye to copy constructors? -

copy constructors traditionally ubiquitous in c++ programs. however, i'm doubting whether there's reason since c++11. even when program logic didn't need copying objects, copy constructors (usu. default) were included sole purpose of object reallocation . without copy constructor, couldn't store objects in std::vector or return object function. however, since c++11, move constructors have been responsible object reallocation. another use case copy constructors was, simply, making clones of objects. however, i'm quite convinced .copy() or .clone() method better suited role copy constructor because... copying objects isn't commonplace. it's necessary object's interface contain "make duplicate of yourself" method, sometimes. , when case, explicit better implicit. sometimes object expose several different .copy() -like methods, because in different contexts copy might need created differently (e.g. shallower or deeper). in conte

asp.net mvc 3 - How to want to move my DAL to separate project in my MVC3 solution? -

i have mvc 3 application uses dal (ado.net) communicates set of tsql stored procedures? want add new mvc project current solution. need have dal in separate project 2 mvc project ("monitor" , "audit") can share. here's current dal (which sits in folder of "monitor" mvc project) code below. issue have signature ienumerable located in monitor.models , ienumerable located in audit.models. need make dal generic avoid needing make references models in dal? ex: **//is bad practice?** using monitor.models; using adit.models; namespace monitor.dal { public class questiondal { static ilog log = log4net.logmanager.getlogger(typeof(questiondal)); private string _connectionstring = webconfigurationmanager.connectionstrings["nexgencontext"].tostring(); public ienumerable<agencyterm> searchagencies(string ori, string name) { log.debug("executing: searchagencies(string ori

c++ - Code generation with macros: Class with members and constructor -

let's want define classes of following structure: struct myclass { int x; bool y; float z; myclass(qvariantmap data) : x(data["x"]), y(data["y"]), z(data["z"]) {} }; as can see, have qvariantmap (something similar std::map<std::string, boost::variant<...>> of not familiar qt) want able construct such type no further knowledge of fields, hence convenient constructor should "deserialize" fields map. i need several classes of style, , want definitions clean possible maximum maintainability (regarding typos in string keys), readability , automation. i thought of macro structure following: def_class(myclass)( def_field(int, x) def_field(bool, y) def_field(float, z) ); i don't see problem when want generate fields not constructor (the other way around possible, i'll demonstrate former only): #define def_class(classname) \ struct classname { \ _def_class_tail/*..."curry

C# Regex Validating Mac Address -

i trying validate mac addresses. in instance there no - or : example valid mac either: 0000000000 00-00-00-00-00-00 00:00:00:00:00:00 however keep getting false when run against below code: using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; using system.text.regularexpressions; namespace parsingxml { class program { static void main(string[] args) { console.write("give me mac address: "); string input = console.readline(); input = input.replace(" ", "").replace(":","").replace("-",""); regex r = new regex("^([:xdigit:]){12}$"); if (r.ismatch(input)) { console.write("valid mac"); } else { console.write("invalid mac"); } con

validation - Form - need to allow for apostrophes -

i have form written in classic asp light client-side validation. works except 1 thing - form fails when there's apostrophe. 1 of fields may have apostrophes (last name field - form fail if user's last name o'brien, example). how fix this? you'll have examine asp code. if see code looks like string sql = "select user_id, first_name,last_name users username = " + myusername; where myusername comes user, vulnerable. the fix not try escape input (i.e., replace "'" "''") use different method outlined in article on sql injection , how avoid it in nutshell, try following bobby-tables site string username = "joe.bloggs"; sqlcommand sqlquery = new sqlcommand( "select user_id, first_name,last_name users username = ?username", sqlconnection); sqlquery.parameters.addwithvalue("?username", username);

svn export and deployment on WINDOWS -

how deploy code svn windows envronment? i looking execute following steps: 'svn export' (only changed files after revisons) windows command line. deploy changed files on windows environment. thanks. you need install command line svn client on windows first. tortoisesvn's recent versions reportedly include one. need use same commands did under linux. think mean 'svn co' not 'svn export' assumes have checked out copies on local file system.

node.js - Running a homebrew web app moderately reliably -

i've written application in node.js, , want deploy linode (or somewhere, maybe nodejitsu ?). it's pretty simple app, couchdb server , view rendering , caching logic. properties i'd app environment: one-button restart or redeploy. if app crashes, environment should try restarting (and emailing me) few times before giving up. secure(-ish). maybe chroot jail? replicable. i'd able run same (or similar) environment on local machine, or on new server, easily. what do? see answer here node.js production deployment i have had luck running on smartos joyent. run fleet hub , drones service manifests. can use fleet on local machine deploy new code , spawn processes automatically restart on crashes

MySQL to select or insert based on condition -

how in single mysql query: if (select count(*)..)=10 select record same table else insert record same table if want use 1 single sql command (but don't know why) can use stored procedure: create procedure `select_or_insert`() modifies sql data comment 'blah blah' begin if ((select count(*) `your_table`) = 10) select ... ... ; else insert ... ; end if; end; to invoke procedure issue following command: call `select_or_insert`(); if select executed, statement return resultset.

c++ - class with virtual functions takes more space -

there such code: #include <iostream> class a{ int a; int fun(){} }; class b{ int a; virtual int fun(){} }; int main() { std::cout << sizeof(a) << " " << sizeof(b) << std::endl; std::cin.get(); return 0; } the output is: 4 8 why class b 4 bytes bigger class a? any class virtual function needs pointer vtable class. therefore, there hidden member that's size of pointer. http://en.wikipedia.org/wiki/virtual_method_table

Form action incorrect when set with Javascript -

i have form on page 2 inputs. on submission, page redirected link contains values of 2 inputs, plus preceding string. html following: <form name="searchform"> <label for="property_type">property type</label> <select name="property_type" id="property_type_number"> <option value>- property types -</option> <option value="1432">commercial</option> <option value="1433">land</option> <option value="1434">multifamily</option> <option value="1435">rental</option> <option value="1436">residential</option> <option value="1988">residential / condo</option> <option value="1987">residential / single family</option> </select> <label for="city">city</label>

Is there Android API to control global http proxy? -

i looking android api allow control global http proxy on android. i not interested in solutions involve rooting device. however, ok api works on latest version of os (if such api exist). no, there no api this. need ask user apply change if that's necessary, cannot code w/o rooting

How can I make android delete old native libraries? -

i'm trying delete native libraries application because don't use them anymore, after install apk in phone can see native libraries still there. i've seen, android copy/update native libraries correctly replacing file in libs/ directory, apparently doesn't delete them when they're not in apk anymore. how know libraries still there? first of application's size remains same , i'm deleting big libraries, , second, if leave system.load(...) statement app still able load library. the solution i've found has been uninstall app , make fresh install, that's not obvious solution user updating app google play, , yes problem affects severely app functionality. i've checked , apparently can delete files self, during service creation, don't want mess installation way. do know if there's way tell android needs delete native libraries , copy them again? thanks, mike [edit] i've found gb updates libraries correctly, deletes now-missing

C# StackOverflowException when use getter -

i have getter wich change first letter of string capital. stackoverflowexception. namespace consoleapplication1 { class program { class human { public string name { { char[] letters = name.tochararray(); // upper case first char letters[0] = char.toupper(letters[0]); // return array made of new char array return new string(letters); //return name.first().tostring().toupper() + string.join("", name.skip(1)); } set { } } what wrong? this line char[] letters = name.tochararray(); calls recursively property public string name

user interface - can C# read in a xml file to change its gui at runtime -

i making application generate , sql scripts template , after taking input different fields user. there many templates, gui needs adjust fields user filling out. in interest of keeping scalable, i'd rather not hardcode guis program, have read xml file , change based on template user has selected. this preferred because if new template arise, program needs xml file corresponds template. , actual code not need changed. have eyes set on using c# this, have experiences using it. open suggestions other languages though. edit: project work, , wanted sure possible c# before convincing employers expand using c#. you sort of thing subclassing windows.forms.form , adding constructor accept xml file parameter. add parser xml file interpret instructions labels , fields want add consistent form design (say, 2 columns label field name on left , actual input field on right, achievable filling form tablelayoutpanel). need lay out design constraints beginning , stick them.

Limiting a String to 2 lines in android, then cut it and concatenate a String -

my question may sound bit weird i'll try explain better here. i ahve textview in android, @ inferior part of activity. want have limited 2 lines, reachable adding following line in textview xml element: android:maxlines="2" okay, we've got limited 2 lines. then, in activity, make: termsandconditions = (textview) findviewbyid(r.id.textview1); termsandconditions.settext(terms); okay, i've got big string terms , conditions, limited 2 lines due xml attribute. now question is, how can cut after having limited 2 lines, , concatenate string "read more"? don't need in same textview or whatever, want looks like: terms: blablablalblalbla blal blablalblalblalblalbla lalblalblalblalblalblalb lalblalblalb lalblalblalblalblalb lalblalblalb lalblalblalblalb lalb bla view more. thanks , hope can understand problem. you can use setellipsize (textutils.truncateat where) method of textview or android:ellipsize xml attribute. publ

javascript - Z-index not applying to div – What is wrong with my code? -

i've been working on page day , i'm getting close finishing it, something's not making sense. i have image centered in <section> menu @ bottom of image. i've written script when hovering on 1 of <a> tags in menu, background-image of transparent div on top of changes different image. seems work fine, apart fact image behind centered image part of section. might confusing, can see mean if go top of http://casperfitzhue.co.uk/totemindex.html , hover on "young gods" button. only half of mask appears on left hand side, if underneath main image, although z-index of div higher 1 of main image shouldn't happen. noticed when checking code in chrome's "inspect element" z-index of div appears crossed out, means not being applied – don't understand why? this html: <section id="cover"> <div id="maskover"></div> <img src="coverimage.png" id="coverimage" widt