Posts

Showing posts from February, 2011

How do I get the path of a binary in c#? -

for reporting purposes i'm trying location of binary. i doing this, , working, i'm getting nullreferenceexception when try testproc.mainmodule.filename; , think may program closing before i'm able grab it. there better way this? processstartinfo testpsi = new processstartinfo(runoptions.testbinary); testpsi.redirectstandarderror = true; testpsi.redirectstandardoutput = true; testpsi.useshellexecute = false; process testproc = new process(); testproc.startinfo = testpsi; testproc.start(); ret = testproc.mainmodule.filename; testproc.kill(); if (ret != null) return ret; option 1: use path have. unless i'm missing something, looks you're creating process (with runoptions.testbinary ), should know path. can full path executable path.getfullpath(runoptions.testbinary) , or if binary on path , can manually examine each directory determine binary being executed from. option 2: use c#'s wmi libraries: if there differences in bitness (32-...

linux - Fork()-ing a new process -

fork()-ing process end calling do_fork() inside kernel, making exact copy of itself. when read through books, says child of fork call exec create new process. example: ls command on shell, create way. sh(parent) | sh(child) | ls(new process) but, not able understand how & exec*() called? because, can see shell(child) created in fork. but, when , new process created/executed? you have exec() if want new program running in 1 of processes (usually child not absolutely necessary). in specific case shell executes ls , shell first forks, child process execs. it's important realise 2 distinct operations. all fork() give 2 (nearly) identical processes , can use return code fork() decide if you're parent (you positive pid of child, or -1 if fork() failed) or child (you 0). see this answer description on how fork() , exec() work (under your control) , how can used without each other. similar do_fork() , exec stuff boils dow...

hyperlink - LESS stylesheet not registering -

is there trick less? can't of function in-browser. maybe i'm declaring stylesheet in browser wrong? it's literally not showing at all . i've included min , less files in same folder, make sure it's not directory issue. here html: <!doctype html> <head> <meta charset="utf-8"/> <meta http-equiv="x-ua-compatible" content="ie=edge,chrome=1"/> <meta name="viewport" content="width=device-width, initial-scale=1"/> <title>jessica colding</title> <link rel="stylesheet/less" type="text/less" href="style.less"/> <script src="less-1.3.3.min.js" type="text/javascript"></script> <!--[if lt ie 9]> <script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> </head> <body lang="en"> ...

javascript - Target specific google chart data set -

say if google chart data array looks below, there way target specific data set google charts , something. if data = "13 dec 11 tue" point of 56 should use different color rest... ["13 dec 11 tue",56], ["14 dec 11 wed",168], ["15 dec 11 thu",181], ["16 dec 11 fri",163], ["17 dec 11 sat",172] ... yes, possible, requires coding in javascript , cannot done innately within google visualization save within tables using colorformatter . assuming want in chart, need write code it. option 1: create array of colors you can use series configuration option of charts set color of how each series displayed. for instance, if have 3 series, can set following option turn second 1 red: series: [{}, {color: 'red'}, {}] this set no options series 1 , 3, change color of series 2 red. so can loop through data javascript, , create array of colors assign various series. instance, if want value in column 1 higher 1...

java - How to get fragment from the view for Google Map v2 -

i have android application using google map api v1 key , working fine. need give code professor , show him working demo scratch on new desktop machine. means, cannot use google map api v1 key anymore reason needed make changes in code have google map api key v1 can used google map api v2 key . i trying show google map on top half of android screen , in bottom half, trying show list view . below code works fine google map api v1 key , need make changes in below code make work google map api v2 key meaning need show google map on top half of android screen. private googlemap map; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); bundle bundle = getintent().getextras(); user_id = bundle.getstring("userid"); layoutinflater inflater = layoutinflater.from(this); scrollview = (myhorizontalscrollview) inflater.inflate(r.layout.horz_scroll_with_list_menu, null); setcontentview(scrollview); menu = inflater.inflate(r.la...

C++ Passing pointer to function -

ok have function int main { .... char *wordl=word();//wordl pointer array of characters ... gamewindow(wordl,length); } void gamewindow(char &wordl,int length); my question how pass pointer such passed pointer points same array list.. , can access wordl[i] in gamewindow function. from comment below, implementation of word() : char* word() { int j=1988497762; cout<<j<<endl ; static char original[25]; int x; ifstream fin("out.txt"); (j=0;!fin.eof();j++) fin.getline(original,25); fin.close(); srand ( (unsigned) time(null) ); x = rand()%j; cout<<x<<"\n"; cout<<rand()<<endl; char c; ifstream finn("out.txt"); (j=0; !finn.eof(); j++) { finn>>c; finn.getline(original,25); if (x==j) break; } finn.close(); return original; } if want use (and not use std::vector or std::string ) need change gamewindow...

hadoop - How to handle multiline record for inputsplit? -

i have text file of 100 tb , has multiline records. , not given each records takes how many lines. 1 records can of size 5 lines, other may of 6 lines may 4 lines. not sure line size may vary each record. so cannot use default textinputformat, have written own inputformat , custom record reader confusion : when splits happening, not sure if each split contain full record. part of record can go in split 1 , in split 2. wrong. so, can suggest how handle scenario guarantee full record goes in single inputsplit ? thanks in advance -je you need know if records delimited known sequence of characters. if know can set textinputformat.record.delimiter config parameter separate records. if records aren't character delimited, you'll need logic that, example, counts known number of fields (if there known number of fields) , presents record. makes things more complex, prone error , slow there's lot of text processing going on. try determining if records delimi...

c# - Does a code that combines single() with yield make any sense? -

i came across code should return single object expected in list, code has iterator block yields found items, have simplified case in following example: private static void methode_a() { console.write("{0} ", numberlist(2, 8).single()); } private static ienumerable<int> numberlist(int min, int max) { while (min < max) yield return min++; } does make sense or there known benefits of combining single() yield on building list , asserting contains 1 single element? the way works following: you call numberlist(2, 8).single() the execution flow enters while loop first time , returns first result (2). the execution flow continues on second iteration of loop , returns second element (3) the .single method throws exception , stops execution because expected there 1 element contained in enumerator on other hand if call numberlist(2, 8).first() here's happen: the execution flow enters while loop first time , re...

php - Facebook API how to allow only members of a group to access the app -

i using php code. with code using few problems. when log on asks permission use id/username not groups. i error message: "warning: invalid argument supplied foreach() in index.php on line 23" foreach check group. yes correct values set in code, don't want entire world know it. <?php require 'src/facebook.php'; // create our application instance (replace appid , secret). $facebook = new facebook(array( 'appid' => 'app id', 'secret' => 'secret', )); // logg ut if(isset($_get['action']) && $_get['action'] === 'logout'){ $facebook->destroysession(); } // user id $user = $facebook->getuser(); if ($user) { try { // proceed knowing have logged in user who's authenticated. $user_profile = $facebook->api('/me?fields=id,name,groups','get'); $user_belongs_to_group= false; foreach($user_profile['groups']['data'] $g...

hibernate - JPA @PreUpdate not called on all entities -

i have @mappedsuperclass contains metadata stuff creation , last modified date. entities extend class. class has method annotated @preupdate set these properties before according action. what driving me crazy work entity , c not b. extend baseentity directly. there 0 reason should behave differently. more confusing @prepresist called correctly on of entities, b. anyone has idea why happens? it's driving me nuts... public class extends baseentity {} public class b extends baseentity {} public class c extends baseentity {} @mappedsuperclass public abstract class baseentity implements serializable { @getter @setter(accesslevel.protected) @version private long version; @getter @setter(accesslevel.protected) @temporal(temporaltype.timestamp) @column(name = "created") private date created; @getter @setter(accesslevel.protected) @temporal(temporaltype.timestamp) @column(name = "last_modified") ...

php - iframe Regular Expression form validation -

i'm having trouble validating form entry using regular expression. learning regular expressions , task. the problem: have attempted write regex match soundcloud iframe. however, form entry accepted whether entry soundcloud iframe or not. appreciated! this function came with: function iframe_match ($iframe){ return(preg_match('#/<iframe width="100%" height="450" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/\?url=http%3a%2f%2fapi.soundcloud.com%2f|[a-z]|%|[0-9]| [f]|">\</iframe\>/#', $iframe)) ? true : false; } and specific form check: else if (iframe_match($_post['track_file1']) === false){ echo '<br/><br/><font color="red"><strong>must include iframe</strong><font>'; } function iframe_match ($iframe){ return(preg_match('/<iframe[^>]*src="https:\/\/w.soundcloud.com\/player\/[^"...

android - Blank page is shown when pop the fragment & replace to the same fragment again -

i have 3 fragments, frag_a, frag_b & frag_c. my navigation logic is: frag_a ==> frag_b ==> frag_c . that's frag_a added layout firstly, so, @ first time, frag_a shown on screen, then, if user press next button, frag_a replaced frag_b, frag_b shown on screen, if user press next button, frag_b replaced frag_c, frag_c shown on screen. everything works fine code @ point. method change next fragment: //here, argument 'fragment' either frag_b or frag_c public void showfragment(fragment fragment){ fragmentmanager fragmgr = activity.getsupportfragmentmanager(); fragmenttransaction fragtrans = fragmgr.begintransaction(); fragtrans.replace(r.id.frag_placeholder, fragment, fragmentname); fragtrans.addtobackstack(null); int transid = fragtrans.commit(); fragmgr.executependingtransactions(); } layout file of activity (frag_a added frag_placeholder when activity starts): <?xml version="1.0" encoding="utf-8"?> <merge ...

How can I redirect svn urls to another domain? -

background: dyndns has started require once month logon keep free accounts active (previously had renew ip address once month). sure sooner or later forget , lose account. i use mysvn.dyndns.org accessing subversion repository on server can (as of now) reached svn.mydomain.com. unfortunately projects refer externals located @ mysvn.dyndns.org , don't want go through projects (>100) , change externals, because take several hours , rather error prone. is there way configure windows or subversion / tortoisesvn clients redirect 1 domain another? e.g.: https://mysvn.dyndns.org/svn/blablub should redirected to https://svn.mydomain.com/svn/blablub i know can add entry hosts redirect ip address, prefer redirection domain name. you (really) asked 2 related questions: can redirect somename.domain.com anothername.somedomain.com ? can svn-clients use old name, intecat new host? and short answers be yes no longer versions for redirecting old hostna...

Error in drupal-commons installation -

i´ve got drupal 7 installed on pc running on localhost acquia dev stack. tried installed drupal-commonns, got error when install profile stage running: an ajax http error occurred. http result code: 200 debugging information follows. path: ....... sitechoose site color paletteenter homepage welcome textcreate first groupfinished sqlstate[42s02]: base table or view not found: 1146 table 'dc.watchdog' doesn't exist what might be? thanks you need enable database logging module. module create watchdog table. after error go away. hope help. :)

Ironpython module has no attribute fsync -

Image
i'm loading dulwich ironpython , when try run example code below how pull remote using dulwich? from dulwich.repo import repo dulwich.client import httpgitclient local = repo.init("local", mkdir=true) client = httpgitclient('http://github.com/adammorris/') remote_refs = client.fetch("history.js.git",local) local["head"] = remote_refs["refs/heads/master"] i get: attributeerror: 'module' object has no attribute 'fsync' . i know in case of attributeerror: 'module' object has no attribute '_getframe' passing -x:frames enables appropriate call disabled default performance reasons. similar case , if not how should proceed? edit: this looks ironpython issue #7267 . i'll see if can fix 2.7.4.

IntelliJ 12 Python - Issues with manage.py Tasks -

i'm looking nifty python/django ide , came across pycharm jetbrains tested week , i'm quite impressed piece of software. however, i've read intellij ultimate jetbrains own python plugin offers same features pycharm itself, went ahead , gave try, experienced issues didn't have within pycharms. in intellij, built in feature 'tools > "run manage.py task..."' works (e.g. runserver, startapp, syncdb, ...), not commands: almost sql-related commands "sql", "sqlall", "sqlclear", ... shown available commands, raise "no applications" error message when entered. in pycharm commands works fine. running test suite via "test" opens box have choose applications want test. however, there 1 entry "[all applications]" , running causes several exceptions thrown. adding new applications "settings.py" file has no effect on "run manage.py task..." whereas in pycharm adds new comman...

java - Persistance.xml vs DispatcherServlet -

i using jpa 2.0, hibernate 3 annotation version, problem confusing in persistence.xml & dispatcherservlet my persistence.xml file contains: <?xml version="1.0" encoding="utf-8"?> <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> <persistence-unit name="hello" transaction-type="resource_local"> <provider>org.hibernate.ejb.hibernatepersistence</provider> <class>models.student</class> <properties> <property name="hibernate.show_sql" value="true" /> <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.driver" /> <...

javascript - populate observable array from json -

i have working test example of want here: http://jsfiddle.net/2bxvk/6/ instead of test months populate observable array called allmonths (like this) self.tak = ko.observable(100); self.styckpris = ko.observable(10); self.grundpris = ko.observable(500); self.allmonths = ko.observablearray([ new monthdata(2013, 1, 412, 142, self), new monthdata(2013, 2, 112, 642, self), new monthdata(2013, 2, 100, 742, self), new monthdata(2013, 3, 6513, 69, self), new monthdata(2013, 4, 34, 211, self), new monthdata(2013, 5, 123, 435, self), new monthdata(2013, 6, 412, 142, self), new monthdata(2013, 7, 412, 142, self) ]); i want $.getjson , insert obs array instead. this output of $.getjson source if view directly url: [{"tak":2700,"styckpris":35,"grundpris":20000,"year":2012,"month":2,"ss":784,"ms":576,"count":1360,"price":20000},{"tak":2700,"styckpris":35,"gr...

android - unfortunately project name has stopped -

i got "unfortunately app has stopped" error in emulator many applications.all applications can have same logcat.java file mentioned here.please post solution.thanks........... this manifest file: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.onitemclicklistener" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:minsdkversion="8" android:targetsdkversion="17" /> <application android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" > <activity android:name="com.example.onitemclicklistener.mainactivity" android:label="@string/app_name"...

debugging - Heroku: get error stack when an error is happening -

is there chance can modify heroku's behaviour error stack have in local? ex: nameerror in best#search showing /media/augustin/documents/workspace/best/app/views/layouts/application.html.haml line #29 raised: undefined local variable or method `new_user_session_pat' #<#<class:0x00000002eb09b8>:0x00000004a12008> instead of: we're sorry, went wrong. i know there heroku logs, know not recommended in production environment, since i'm still developping, i'd happy have nicer messages logs ones. thanks you can use heroku logs: $ heroku logs --app your_heroku_app_name references: http://devcenter.heroku.com/articles/logging

php new dateTime and gmdate -

this question has answer here: how convert php date formats gmt , vice versa? 3 answers how convert following uses datetime class ?: array( 'post_date' => date('y-m-d h:i:s', $date), 'post_date_gmt' => gmdate('y-m-d h:i:s', $date), ); eg part easy how gmdate? $odate = new datetime($date); array( 'post_date' => $odate->format('y-m-d h:i:s'), 'post_date_gmt' => gmdate('y-m-d h:i:s', $date), ); in case need 2 object 1 gmt . $odate = new datetime($date); $gmdate = new datetime($date, new datetimezone('gmt')); array( 'post_date' => $odate->format('y-m-d h:i:s'), 'post_date_gmt' => $gmdate->format('y-m-d h:i:s'), );

Relay Emails with Java -

i want software (java-based) relay messages send address given group of recipients. for example: messages group1@mysite.com relayed part of group1. therefor catch mails send group1@mysite.com , , want send them each person individually, person should not see other recipients, should still see message intended for. for example: part of group1 are: james@yahoo.com , stacy@gmx.net , francis@gmail.com . original message group1@mysite.com " to "-recipient , not seeing in group. i thought putting them in bcc , not have to -recipient set. , if set to -recipient message again , relay again, produces , endless loop. any ideas? if want act mailinglist, need work mailing list. acutaly send out e-mail every member. so need send 3 mails james@yahoo.com stacy@gmx.net , francis@gmail.com if want set to: field group1@mysite.com have track message id's of own sent e-mails, prevent loops

exchangewebservices - How to set the contact Email1DisplayName using the EWS Java API (Exchange Web Service)? -

Image
i figured out how set title (see how set contact title using ews java api (exchange web service)? ). trying set email 1 display name. if use exposed api contact.getemailaddresses().setemailaddress(), display name automatically set same email address (and overrides extended properties). so trying set complete email information via extended properties. works, except when @ address book, name , display name empty. i have feeling related email1originalentryid property, not know how set correctly. any ideas? my current attempt looks this: extendedpropertydefinition propdef_pidlidemail1displayname = new extendedpropertydefinition(// uuid.fromstring("00062004-0000-0000-c000-000000000046"), 0x8080, mapipropertytype.string); extendedpropertydefinition propdef_pidlidemail1addresstype = new extendedpropertydefinition(// uuid.fromstring("00062004-0000-0000-c000-000000000046"), 0x8082, mapipropertytype.string); extendedpropertydefinition propdef_pidlide...

c++ - Is an if statement guaranteed to not be evaluated more than necessary? -

this question has answer here: is short-circuiting logical operators mandated? , evaluation order? 7 answers how c++ handle &&? (short-circuit evaluation) 7 answers given 2 conditions && connection. know order of evaluation left right. if first condition resolves false, second condition guaranteed not evaluated? #define size bool array[size]; int index; // play variables // ... if(index < size && array[index]) { // ... } in example, if first condition false second must not evaluated since access in array out of range. by way cannot nest conditionals 2 if statements, since need inverse (!(in_range && get_element)) . nested statements need use goto jump on code block below that. but if first condition resolves false, s...

c# - What is the php equivalent for Encoding.ASCII.GetBytes(vstrEncryptionKey.ToCharArray()) -

this question has answer here: how byte values of string in php? 4 answers what php equivalent following c# code encoding.ascii.getbytes(vstrencryptionkey.tochararray()) where vstrencryptionkey variable? use ord function ( http://php.net/ord ) , mb_strlen function http://php.net/manual/en/function.mb-strlen.php ) <?php $var = $vstrencryptionkey; for($i = 0; $i < mb_strlen($var, 'ascii'); $i++) { echo ord($var[$i]); } ?> this modified code answer given in how byte values of string in php?

sql - How to explode in MySQL and use it in the WHERE clause of the query - MySQL -

i have database table below. promotion_table id(int), promotion_name(varchar),......, bungalow_ids(varchar) we can add promotion bungalow(23). row added bungalow id below. 1, promotion, ........, 23 but if single promotion added multiple bungalows(23,42) ids saved in bungalow_ids column below. 2, promotion 2, ........, 23 | 42 if user search promotion specific bungalow(23) promotions bungalow should shown in result. i have query below. select * promotion_table bungalow_ids = '23' it gets 1 rows. 2nd row should shown since there offer. can nt use like since gets wrong records. given have referred below links have no idea how use them in query. can split/explode field in mysql query? equivalent of explode() work strings in mysql how can fix this? how can explode column data , use in query ? use , separate string , try query select * promotion_table find_in_set("23",bungalow_ids) http://sqlfiddle.com/#!2/7bbcb/1

wix - Why does managed bootstrapper application always install .Net framework no matter the .net framework exists or not? -

if wixvariables wixmbaprereqpackageid , wixmbaprereqlicenseurl not added, fails compile. the windows installer xml variable !(wix.wixmbaprereqpackageid) unknown. windows installer xml variable !(wix.wixmbaprereqlicenseurl) unknown. if 2 variables added, though test computer has .net framework 4.0 installed, bootstrapper installs .net framework 4.0 every time. how avoid installing .net framework when target computer has .net framework? below sample code. <?xml version="1.0" encoding="utf-8"?> <wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/utilextension"> <bundle name="testbootstrapper" version="1.0.0.0" manufacturer="microsoft" upgradecode="e8c02687-b5fe-4842-bcc4-286c2800b556"> <bootstrapperapplicationref id='managedbootstrapperapplicationhost'> <payload sourcefile='myba.dll...

MySQL Union always returns one row with NULL's -

Image
given following query… select distinct * pas_post post_user_id = 21 group post_post_id union select distinct pas_post.* pas_follow left join pas_post on ( pas_follow.folw_followed_user_id = pas_post.post_user_id ) pas_follow.folw_follower_user_id = 21 group post_post_id order post_posted_date desc i row in results null's, unfortunately need preserve null values in data post's table (pas_post) holds different types of information. can steer me in right direction rid of null row. i not want or need last row here you're using (left) outer join in second part of union , cases not satisfy join criteria result in data table on left of join ( pas_follow ), null in every column of table on right of join ( pas_post ); subsequent selection of columns latter table results in null rows observe. therefore, simplest solution use inner join (that excludes records join criteria not met). however, in c...

oracle10g - Oracle BI - Sharing Ibot to users With less previleges -

i m working oracle bi standard edition. i developed ibot , working fine. developed within administrator domain (as administrator). i can't send ibot others users, low previleges. i select recepients, subscriptions options, changed users previliges. but missing, can't send ibot others users. some help? thx.

prolog - Finding values without creating new unifications -

i have set of definitions of form pair/2 , predicate propagate/3 : pair(1, 2). pair(2, 3). pair(3, 4). pair(4, 5). propagate([], _, []) :- !. propagate([pair(n, num)|tail], num, [n|resulttail]) :- propagate(tail, num, resulttail), !. propagate([pair(num, n)|tail], num, [n|resulttail]) :- propagate(tail, num, resulttail), !. propagate([_|tail], num, result) :- propagate(tail, num, result), !. if have list = [pair(1, 2), pair(2, 3), pair(3, 4), pair(4, 5)] , do propagate(list, 2, result). i desired output, result = [1, 3] ; i.e. list of numbers form pair 2 . however, if have list = [pair(n1, n2), pair(n2, n3), pair(n3, n4), pair(n4, n5)] , if do propagate(list, n2, result) then output n2 = n3, n3 = n4, n4 = n5, result = [n1, n5, n5, n5]. i output result = [n1, n3] , instead. how can that? ( == )/2 trick propagate([], _, []) :- !. propagate([pair(n, x)|tail], num, [n|resulttail]) :- x == num, propagate(tail, num, resulttail), !....

python - Adding multiple arrays to a MySQL Table -

i wrote script scrape trough multiple urls, add useful information of beautifulsoup 2 arrays (ids , names) , add values of these arrays mysql table ids[0] , names[0] row0 of table , on... however code ugly , sure there way better approaches mine. can give me hint? specificly need input on how iterate trough 2 arrays... thanks in advance! #!/usr/bin/env python bs4 import beautifulsoup urllib import urlopen import mysqldb #mysql connection mysql_opts = { 'host': "localhost", 'user': "********", 'pass': "********", 'db': "somedb" } mysql = mysqldb.connect(mysql_opts['host'], mysql_opts['user'], mysql_opts['pass'], mysql_opts['db']) #add data sql query data_query = ("insert tablename " "(id, name) " "values (%s, %s)") #urls scrape url1 = 'http://somepage.com' url2 = 'http://so...

android - Grainy Markers with rotation in GoogleMaps -

i've create maps images using code: icon_pin = bitmapfactory.decoderesource(getapplicationcontext().getresources(), r.drawable.arrow); int w = icon_pin.getwidth(); int h = icon_pin.getheight(); bitmap.config conf = bitmap.config.argb_8888; bitmap bmp = bitmap.createbitmap(w, h, conf); final float centerx = w / 2.0f; final float centery = h / 2.0f; canvas canvas = new canvas(bmp); canvas.rotate(m.getdirection(), centerx, centery); canvas.drawbitmap(icon_pin, new matrix(), null); but when rotated image, result grainy (like green arrow in example: http://img837.imageshack.us/img837/4624/screenshot2013052111381.png ) i've wrong something? it's possibile bettering definition? it looks need draw anti-aliasing enabled. in line: canvas.drawbitmap(icon_pin, new matrix(), null); you can specify paint object use drawing. above, use null . can add these lines before call canvas.drawbitmap() : paint mypaint = new paint(paint.anti_alias_flag); mypaint....

python - How do I override a field in a base class with a property in a derived class? -

i have base class uses field: class base(object): def __init__(self, member): self.member = member and derived class promote property, , add behaviour: class derived(base): @property def member(self): return super(derived, self).member @member.setter def member(self, value): print "intercepting setter" super(derived, self).member = value however, doesn't correctly delegate base class: >>> d = derived(0) intercepting setter traceback (most recent call last): file "<pyshell#8>", line 1, in <module> d = derived(0) file "<pyshell#3>", line 3, in __init__ self.member = 2 file "<pyshell#6>", line 9, in member super(derived, self).member = value attributeerror: 'super' object has no attribute 'member' how should doing this? you're trying access super's member if class attribute. try with: class ...

asp.net mvc 3 - How to return a list of stores which are a specified distance from the entered Postcode -

i using google maps create store locator. the user enter postcode , select dropdown menu distnce location - 5, 10 15 20 miles. which return stores specified distnace location , put markers on map. i have postcode table has following columns: postcode latitude longitude easting northing grid ref country district ward and stores table has foreign key relationship table i using mvc3 , linq-sql, have no idea how write query pull stores 5 miles postcode has been entered edit i've found following: select *, acos(cos(51.720663 * (pi()/180)) * cos(-0.299929 * (pi()/180)) * cos(latitude * (pi()/180)) * cos(longitude * (pi()/180)) + cos(51.720663 * (pi()/180)) * sin(-0.299929 * (pi()/180)) * cos(latitude * (pi()/180)) * sin(longitude * (pi()/180)) + sin(51.720663 * (pi()/180)) * sin(latitude * (pi()/180)) ) * 3959 dist postcodes having dist < radius order dist but part doesn t work: having dist ...

java - Which is preferred: abstract class vs interface? -

i came across few design constructs in large application: independent use of abstract classes independent use of interfaces abstract class implementing interface interface extending , interface being new java, appreciate if pinpoint leverage/advantage of 1 on other in specific situations. miss if dont use such constructs? what abstract class? abstract class special kind of class cannot instantiated. question why need class cannot instantiated? abstract class sub-classed (inherited from). in other words, allows other classes inherit cannot instantiated. advantage enforces hierarchies subclasses. in simple words, it kind of contract forces subclasses carry on same hierarchies or standards . what interface? interface not class. entity defined word interface. interface has no implementation; has signature or in other words, definition of methods without body. 1 of similarities abstract class, contract used define hierarchies subclasses or defines specific set of m...

domxpath - Get Title, URL, Description and insert it to database -

i'm new here , need fix code. i'm trying make code using domxpath grab title, url , description bing search , save db. here code : <?php $s="something-words"; $keywords = strstr($s, '-') ? str_replace('-', '+', $s) : $s; $html5 = new domdocument(); @$html5->loadhtmlfile('http://www.bing.com/search?q='.$keywords.'&go=&qs=bs&filt=all'); $xpath5 = new domxpath($html5); $nodes = $xpath5->query('//div[@class="sb_tlst"]/h3'); $nodes = $xpath5->query('//div[@class="sb_meta"]/cite'); $nodes = $xpath5->query('//div[@id="results"]/ul[@id="wg0"]/li/div/div/p'); $data = array(); $data2 = array(); $data3 = array(); $i = 0; foreach ($nodes $node) { $data = $node->textcontent; $i++; // insert table urlgrab mysql_query( "insert urlgrab(title) values ('$data')"); $data2 ...

click - Css help? Images on hover -

hey guys need css have images expand when hover on them pushes away @ same time <style> .box { width: 750px; height: 1000px; border:1px solid green; } .enlarge-onhover { width: 125px; height: 125px; } .enlarge-onhover:hover { width: 225px; height: 225px; } </style> i dont want want overlap rest of images , expand on left click rather hover one way can use absolute positioning . the problem is, you're hovering, changing sizes (width , height), move across , re-render page.

javascript - How to change background-color in header with scrollpsy on each ID -

i'm using scrollpsy bootstrap. i made example of i'm trying do: http://jsfiddle.net/te3v4/15/ all good, passing 1 active class li @ each section id, want change background @ header @ each section for example: if #studio background-color: #0915ff; if #green background-color: 085606; $(function() { var $spy = $('.nav'); $spy.bind("activate", function(e) { //e.target current <li> element var header = $(e.target).find("a").attr("href"); alert (header); $studio = $('#studio') $duplex = $('#duplex') $tower = $('#tower') if( $(header) == "#studio" ) window.alert( “alert actived”); }); }); i'm not familiar scrollspy i've updated fiddle http://jsfiddle.net/te3v4/18/ basically on each tag i've added "data-background" property value of color want. reset colors on when runs, , assign correct color using fol...

apache - Java FTPClient listFiles return empty result with unicode path -

i tried list ftp server , have encoding problem ftpclient.listfiles(string path) method its returns empty array if path has non-latin characters. (also using server python , perl scripts in unicode - , there havent problems this) please solve problem. this method connection debug output: public static ftpclient ftpconnect(string host, string login, string password) throws ioexception { ftpclient ftp = new ftpclient(); ftpclientconfig config = new ftpclientconfig(); ftp.configure(config); debug(ftp.getreplystring()); debug("connected " + host + "."); ftp.connect(host); debug(ftp.getreplystring()); debug("set passive transfer mode"); ftp.enterlocalpassivemode(); debug(ftp.getreplystring()); debug("login " + host + "."); ftp.login(login, password); debug(ftp.getreplystring()); int reply; ftp.setcontrolencoding("utf-8"); ftp.setautodetect...

c# - Converting GPS coordinates into 3D model -

as question says, looking use gps coordinates (say google maps) build 3d model (a road). so should work follows: go google maps , select route (this can between 2 points or circuit). lat long coordinates route. using data, feed program generates height map of coordinates obtained google maps. i trying make demo in c# (xna) can generate course of neighbourhood driving sim (as long main road sections right ok, wont able add detailed characteristics of road e.g. ditch next road or small bumps in actual road surface). does have ideas on start problem (tried google best find here ) gps coordinates (latitude, longitude, altitude) uses speherical 3d modell. want transformation cartesian 3d model. for case can convert them ecef coordinates, x,y,z coordinates for ecef overview see ecef

.htaccess - htaccess add RedirectMatch 301 rules -

i add rules .htaccess file: redirectmatch 301 /wp-content/my-image-5x5.jpg /wp-content/default-5x5.jpg redirect works well, add old image name address. why? don't need this. what i'm now: www.mypage.lt/wp-content/default-5x5.jpg?file=/wp-content/my-image-5x5.jpg what need: www.mypage.lt/wp-content/default-5x5.jpg redirect works well, add old image name address. why? don't need this. this because have wordpress rules internal routing (to index.php file) , rewrite rules belong mod_rewrite, while redirectmatch directive belongs mod_alias. these modules both applied @ different points in url-file mapping pipeline, both applied, , end mangled redirect url. should stick mod_rewrite in instance. try adding these rules before wordpress rules: rewriteengine on rewriterule ^/?wp-content/my-image-5x5.jpg /wp-content/default-5x5.jpg [l,r=301]

database - Select one random row from cycle of function with SQLite and Perl -

hi tried select 1 random number this: my source: use dbi; use cgi; $file = '.\input.txt'; # name file open(file, $file) or die("unable open file"); @data = <file>; foreach $line (@data) { chomp $line $sth = $dbh->prepare("select columna table columna '%$line%'"); $sth->execute; $result = $sth->fetchall_arrayref; foreach $row ( @$result ) { print "- "; print "@$row\n"; print "<br />"; } } how can print 1 random row??? tried that: my $sth = $dbh->prepare("select nazov_receptu recepty nazov_receptu '%$line%' , kategoria == 'p' , (rowid = (abs(random()) % (select max(rowid)+1 recepty)) or rowid = (select max(rowid) recepty)) order rowid limit 1;"); but not clear... dont know why... i using sqlite , printing web interface. you can try when have input.txt: a c database: id name 1 2 b 3 c 4 d 5 e out: a or c (random) ...