Posts

Showing posts from May, 2015

osx - Can a Cocoa app's executable steal focus from caller? -

say have standard cocoa application call foo.app (like 1 choosing new project > cocoa application in xcode), if open app via terminal using: open foo.app/ then see foo's name on status bar top , window in focus, in front of other apps. if instead directly call terminal executable buried in .app folder, like: foo.app/contents/macos/foo nothing appears happen. on inspection app has indeed opened not in focus (the terminal still is), have find on dock or find window. is there way foo application make sure in focus when run? if run via executable described above? your app can "steal focus" calling [[nsapplication sharedapplication] activateignoringotherapps:yes]; see nsapplication docs more info.

objective c - Table Border for an Iphone app -

i new iphone app development. have been trying draw border table in iphone app. of posts see how remove seperation lines between cells or change colors or add background. i tried following - (void)viewdidload { [super viewdidload]; self.tableview.layer.border = 1; } however, says border not attribute. it great if me out in this. perhaps mean you'd display table in 'grouped' style, adds border? [table setstyle:uitableviewstylegrouped]; http://developer.apple.com/library/ios/#documentation/uikit/reference/uitableview_class/reference/reference.html

security - How safe is to use an online SVN repository? -

how safe use online svn repository? i want develop collaboratively friends. know can create non-public accounts in of services, can't fell confortable send of our intelectual products company manage. after all, if idea works, companies can find source code! do think care important ? if so, best solution? my question isn't "how is" or "which better", want know if trust them , why (or why not). below give svn repositories examples: xp-dev unfuddle assembla thank all! it important concerned source code in cloud. @ end of day have weigh cost of installing, securing, maintaining, backing vs $10/month plan hosted svn service. there going sector never upload code hosted repo, i.e. banks, military, etc, majority of risk low , minor compared benefits of not doing yourself. make sure provider choose enforces ssl, has regular backups (at least hourly granularity), datacenter provider sas70, , policy allowing download full svn repo dump if...

Why GNU Make canned recipe doesn't work? -

i'm expecting see files foo1 , foo3 created makefile below. file foo3 created. me seems canned recipe make-foo ignored make. debug outcome of targets foo1 , foo2 (empty recipe) identical. # why canned recipe doesn't work ? # http://www.gnu.org/software/make/manual/make.html#canned-recipes define make-foo = echo making $@ touch $@ endef .phony: all: foo1 foo2 foo3 # foo1 not created, why ? .phony: foo1 foo1: $(make-foo) # debug output similar foo1 .phony: foo2 foo2: # works .phony: foo3 foo3: echo making $@ touch $@ running make: xxxx@xxxx:/dev/shm$ make -drr gnu make 3.81 copyright (c) 2006 free software foundation, inc. free software; see source copying conditions. there no warranty; not merchantability or fitness particular purpose. program built i686-pc-linux-gnu reading makefiles... reading makefile `makefile'... updating makefiles.... considering target file `makefile'. looking implicit rule `makefile'. no implicit rule fo...

In Typo3, what is the difference between setup, constants, and TSConfig -

it seems there 3 different places can write typoscript: in templates, there constants field , setup field, , in each page, there tsconfig field. however, seems each typoscript command need go in specific field. of time, have try before finding if given configuration goes template setup, or in root page tsconfig . why there 3 different places write typoscript? use of each of them? tsconfig backend configuration. can add/alter/remove values forms, change behavior kind of records users can add, default usergroups etc. see here more details. typoscript in template used change frontend behavior, template parsing, extension configuration, navigation etc. typoscript in template has called cobjects provide useful functionality image manipulation (image), getting records database (records), creating menus (hmenu), see reference . typoscript constants variables, can used within template typoscript. e.g. have email address occurs in many different places within typoscript temp...

Can't find git plugin in Netbeans 7.0 beta 2 -

although it's written in several pages of netbeans beta 2 release notes (there's a tutorial ), downloaded linux version , can't find how install promised git plugin add git support netbeans. have tried beta , found same problem me? i'm on netbeans beta 2 linux. i have done: 1) go tools>plugins , must click on available plugins find: git . check it. install it. 2) then, right click on project properties, choose: versioning > initialise git repository the tutorial mention, all: http://netbeans.org/kb/docs/ide/git.html perhaps temporary issue?

Static variable inside of a function in C -

void foo() { static int x = 5; x++; printf("%d", x); } int main() { foo(); foo(); return 0; } what printed out? 6 6 or 6 7 and why? there 2 issues here, lifetime , scope. the scope of variable variable name can seen. here, x visible inside function foo(). the lifetime of variable period on exists. if x defined without keyword static, lifetime entry foo() return foo(); re-initialized 5 on every call. the keyword static acts extend lifetime of variable lifetime of programme; e.g. initialization occurs once , once , variable retains value - whatever has come - on future calls foo().

perl - Adding values to a hash in Template Toolkit -

i have hash keys iterating on in template toolkit. example below.... <select name="selectlist_[% feed.num %]" id="selectlist_[% feed.num %]" size="5" style="width: 250px;" multiple> [% foreach xvar = feed.xvars.keys %] <option value="[% xvar %]">[% xvar %]</option> [% end %] <option value="x_file_name">x_file_name</option> </select> what need alphabetize select list (using sort, know how do. problem <option value="x_file_name">x_file_name</option> line. hoping add value "x_file_name" feed.xvars hash. this... [% feed.xvars = { "x_file_name" => "1" } %] hoping that add value hash (as opposed obliterating it). no such luck. looking in template toolkit book , googling doesn't yield either. know how this? after asked figured out. [% appendval = { "x_file_name" => "1" } %] [%...

android - ImageView bitmap scale dimensions -

i have bitmap larger imageview i'm putting in. have scaletype set center_inside. how dimensions of scaled down image? ok. should have been clearer. needed height , width of scaled bitmap before it's ever drawn screen draw overlays in correct position. knew position of overlays in original bitmap not scaled. figured out simple formulas calculate should go on scaled bitmap. i'll explain did in case else may 1 day need this. i got original width , height of bitmap. imageview's height , width hard-coded in xml file @ 335. int bitmap_width = bmp.getwidth(); int bitmap_height = bmp.getheight(); i determined 1 larger correctly figure out 1 base calculations off of. current example, width larger. since width scaled down the width of imageview, have find scaled down height. multiplied ratio of imageview's width bitmap's width times bitmap's height. division done last because integer division first have resulted in answer of 0. int scaled_height...

c# - Return a finite set matching a regex expression -

something similar http://regexio.com/prototype.html , i'm trying set matching particular regex. basically, need parse regular expression , then, instead of reading input while walking parsed expression, output variants. i have hacked following program doing need very simple regular expression (only alternate options using | , iteration using * , grouping using () , , escaping using \ supported). note iteration done 0–5 times, conversion possibly infinite iteration left exercise reader ;-). i have used straightforward recursive-descent parser building abstract syntax tree in memory; tree in end walked , possible sets built. solution not optimal @ all, works. enjoy: public class testprg { static void main() { var expression = new regexparser("a(b|c)*d").parse(); foreach (var item in expression.generate()) { console.writeline(item); } } } public static class enumerableextensions { // build c...

Looking for samples of WPF / Silverlight popup animations -

can recommend site or application demonstrates various animations popup windows? i've seen many smart apps on years can't locate ones animated popups. given 0 artistic skills, i'd happy borrow other people's ideas. thanks i came across today, blacklight drag dockpanel

IE cannot download foo.jsf. IE was not able to open this internet site. The requested site is either unavailable or cannot be found -

i'm providing file download (usually csv or pdf) in jsf web application on https (ssl) host. works fine in browsers, ie7/8 gives following error: internet explorer cannot download foo.jsf. internet explorer not able open internet site. requested site either unavailable or cannot found. please try again i think error related jsf <h:commandlink> tag not being compatible ie. <h:commandlink value="download" action="#{bean.download}" /> how caused , how can solve it? this typical msie error message when download been provided on https (ssl) while response headers been set disable browser cache via no-cache . issue not related jsf. you need relax response headers have influence on browser cache. should not contain no-cache instruction. set public , private or no-store . response.setheader("cache-control", "public"); response.setheader("pragma", "public"); see ms kb q316431 . addit...

python - Where is my ipy.exe? -

i've got clean install of windows 7 ultimate, vs 2010 professional, , latest ironpython installed. in vs can create ironpython project fine (seems install ok), when try run project (a simple print), error message: interpreter "c:\program files\...\0.4\ipy.exe" not exist. i have no prior experience ironpython, might making silly mistake here. realised should install python too, did, version 2.7 , 3.1, makes no difference. right click on project - in properties, provide interpreter path whereever ipy.exe located. c:\program files\ironpython 2.7\ipy.exe?

css - Layered Backgrounds in IE8 -

background-image: url('/images/tenticles.png'), url('/images/header.png'); i have above code, works in both firefox , chrome. not work in ie8. wondering if there way around not working. similar html5shiv. there multiple workarounds ie's lack of multiple background support . 1 such technique involves creating div spans entire page, , setting background along background of body element. technique can repeated necessary. example: body { background-url('/images/tenticles.png'); } #background1 { background-url('/images/header.png'); } <body> <div id="background1"> </div> </body> however, looks want along lines of css3 pie (progressive internet explorer) , "makes internet explorer 6-8 capable of rendering several of useful css3 decoration features". pie's website: pie has full or partial support following css3 features: border-radius box-shadow border-image ...

ruby on rails - How do I reference a custom class in lib from one of my models? -

if create file in lib/ called toast_mitten.rb , , in file have class called toastmitten , how use class models? for example, inside method on comments class (one of models), if try call toastmitten.grasp , error uninitialized constant comment::toastmitten . the class created intended dry repeated code in both models , rake task. rails 3 doesn't autoload lib the problem lib not being autoloaded. i'm using rails 3.0.0. apparently, rails team decided stop autoloading lib in rails 3, josé valim says here . to load, added application.rb : config.autoload_paths += %w(#{config.root}/lib) my colleague tells me other options be: add config/initializers explicitly require in model want use it

c++ - Profiling only the namespaces that I need with VS2010 -

Image
vsinstr.exe has option include namespaces needs profile. with option, vsp file. cl /zi helloclass.cpp /link /profile vsinstr helloclass.exe /include:fpga::* vsperfcmd /start:trace /output:trace.vsp helloclass vsperfcmd /shutdown however, still contains std:: namespaces. added i tried /exclude:std::*, , way many functions including std:: functions. what might wrong? according http://msdn.microsoft.com/en-us/library/ms182402%28v=vs.80%29.aspx /include doesn't accept wildcards, try using /exclude:std::* edit: try adding /exclude:::__* or /exclude:__* rid of global namespace functions starting __. haven't tested this, , documentation isn't clear, worth try.

c# - Adding a new node as a child is automatically adding the xmlns attribute -

i'm trying modify xml document. xml structured this: <?xml version='1.0' encoding='iso-8859-1'?> <modelo39 xmlns="http://www.dgci.gov.pt/2002/ot" versao="1"> <rosto> <quadroinicio /> <quadro01> <q01c01>555555555</q01c01> </quadro01> <quadro06> <rostoq06t> </rostoq06t> </quadro06> </rosto> </modelo39> i'm trying add rostoq06t new node this: <rostoq06t-linha numero="1"> <nif>100000000</nif> <codrend>01</codrend> <rendimento>2500</rendimento> <retido>500</retido> </rostoq06t-linha> i'm creating new element name rostoq06t-linha , i'm adding node rosto06t: xmlelement node06t = xmldoc.createelement("rostoq06t-linha"); node06t.setattribute("numero", linha.tostring()); //here add elements node06t xmldoc.documentelement.getelementsbytagname("ro...

ipad - UIModalPresentationFormsheet action does not refresh the main view -

i have table list of employee data. user can select employee , approve/reject employee's application. if rejected user supposed select reason rejection , enter comments. using uimodalpresentationformsheet display view uitextfield, uipicker , 2 buttons(reject & cancel). when user taps on reject button, make web-service call change status in server , change value in local object holding employee data. when reject action tapped, able perform both actions, main screen in background not refreshed. when try push rejection screen normally(not uimodalpresentationformsheet) works fine. i have tried calling function force refresh view still doesn't work. can please issue. thank you... use nsnotificationcenter . [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(updatesomething:) name:@"updatesomething" object:nil]; [[nsnotificationcenter defaultcenter] postnotificationname:@"updatesomething" object:nil];

c - Writing a JIT compiler in assembly -

i've written virtual machine in c has decent performance non-jit vm, want learn new, , improve performance. current implementation uses switch translate vm bytecode instructions, compiled jump table. said, decent performance is, i've hit barrier can overcome jit compiler. i've asked similar question not long ago self-modifying code, came realize wasn't asking right question. so goal write jit compiler c virtual machine, , want in x86 assembly. (i'm using nasm assembler) i'm not quite sure how go doing this. i'm comfortable assembly, , i've looked on self-modifying code examples, haven't come figure out how code generation yet. my main block far copying instructions executable piece of memory, with arguments. i'm aware can label line in nasm, , copy entire line address static arguments, that's not dynamic, , doesn't work jit compiler. need able interpret instruction bytecode, copy executable memory, interpret first argument, cop...

cocoa - How to pass click on NSView through to app window beneath it? -

my app has nsview in nswindow covers screen , draws semi-transparent shade on it, above i've got nswindow contains app's ui, full screen view designed fade out background distraction of other windows. how can allow mouse clicks on full screen view go straight through underlying window, belong app, or desktop? note don't want keep focus on app. shady matt gemmell same, take @ source: http://instinctivecode.com/shady/ it sending following message window: [window setignoresmouseevents:yes];

c++ - Problem populating dynamically created array -

in code below, trying use for loop initialise member name of 5 objects of class book using names taken string array array (numbers in case testing purposes). #include <iostream> #include <string> using namespace std; class book { private: string name; public: book(); book(string&); }; book :: book() {} book :: book(string& temp) { name = temp; } int main() { string array[] = {"1", "2", "3", "4", "5"}; book *booklist = new book[5]; (int count = 0; count < 5; count ++) { booklist[count] = new book(array[count]); } return 0; } however, whenever try compile code, following error: main.cpp: in function ‘int main()’: main.cpp:28: error: no match ‘operator=’ in ‘*(booklist + ((unsigned int)(((unsigned int)count) * 4u))) = (operator new(4u), (<statement>, ((book*)<anonymous>)))’ main.cpp:6: note: candidates are: book& book::operator=(const b...

java - Mapping a servlet in my JSP -

i have java ee application has war file , ejb file. war file contains jsps/html , ejb contains servlets/beans , ejb. try call servlet in 1 of jsp pages, cant find it. file im looking authenticate. located in ejb file figure path action="../../ejbshoppingcart-ejb/build/classes/servlet/authenticate i played around url, modifying taking taking away build or classes , bunch of other ways.... servlet has @webservlet(name = "authenticate", urlpatterns = {"/authenticate"}) annotation. i know can transfer of files ejb file war file , think solve problem. there way map correctly? urlpatterns = {"/authenticate"} so, it's mapped on url pattern of /authenticate . assuming server runs on localhost:8080 , webapp context name myapp , /web-inf/web.xml conform servlet 3.0 spec, can access http://localhost:8080/myapp/authenticate i'm not entirely sure whether @webservlet class inside ejb ever located , loaded servletcontainer. se...

c# - Building a security library, I think I'm overbuilding it -

so i'm building custom security library, interfaces our database. it's supposed provide basic access control in-house apps: users can x, others can't. needs @ moment pretty basic, library used several apps , control lot of securables. my basic object model user member of 0 or more groups. groups bestow 0 or more permissions. in reality these one-to-many don't want referentially enforce that. permissions grant-only (if no groups give permission, don't have it, there isn't "deny" overrides granted permission in windows rbs), , groups can nest (a tier 2 user has rights of tier 1, plus new ones). when attempting access securable area of program, application imperatively assert user has requisite permission via examining group hierarchy. however, want there several levels of redundancy built library. of particular importance user doesn't have permission change security settings shouldn't able to. so, want make security hierarchy readonly in ...

webview - Cannot get web view to work on Android sdk 1.6 -

i blank screen when try fill web view on android. program runs out errors, blank screen. i'm ussin g sdk 1.6 , running in simulator the code package mikenorman.org; import android.app.activity; import android.view.*; import android.os.bundle; import android.view.view; import android.webkit.webview; public class cblog extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.blog); webview mwebview; mwebview=(webview) findviewbyid(r.id.bwebpage); mwebview.loadurl("http://www.besttechsolutions.biz"); } the layout file <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content"> <webview android:id="@+id/bwebpage" android:layout_width="fill_parent" android:l...

com interop - Take a picture from Integrated Laptop Camera using C# -

i trying write 1 portion of huge c# program allows me capture 1 picture integrate camera in laptop. have done research , notice there 2 ways via wia , directshow. trying easier 1 : wia. working on windows 7 32 bit machine running vs 2010 .net 4.0 . trying run following example found on web, want , experienced several errors regards it. http://www.c-sharpcorner.com/uploadfile/yougerthen/610262008064756am/6.aspx i have added necessary reference using system.windows.forms; using microsoft.win32; using wia; majority of errors following : interop type 'wia.commondialogclass' cannot embedded. use applicable interface instead. interop type 'wia.commandid' cannot embedded. use applicable interface instead. any provided appericiated. try this: wia.commondialog wiadiag = new wia.commondialog(); creating com interfaces new operator allowed. need prefix namespace name because commondialog ambiguous winforms commondialog class.

linq to sql - How to lock a SQL record with LinqToSql? -

i'm using linqtosql datacontext , want lock record being opened in write mode. meaning while 1 user in hong kong has record open in write mode, user in france can't open record in write mode. how? linqtosql supports optimistic concurrency, not pessimistic concurrency.

php - How can I write this Drupal snippet more efficiently? -

i'm working on patch submit registration code module drupal. in short, there more efficient way write code below? if (module_exists('regcode_voucher')) { $cnfg = variable_get('regcode_voucher_display', array('regform' => 'regform')); if (empty($cnfg['regform'])) { return; } } it seems should able reduce 1 if statement && combining 2 conditions, haven't found syntax or necessary php array function allow me that. in case context helps, regcode_voucher sub-module allows users enter registration code on user edit page. on our sites, after "beta" period, want simplify registration form removing registration code field; we'd users still able enter code on account edit page. code above part of patch allows regcode's hook_user changes bypassed. code looks good, efficient want? little changes may be: if (module_exists('regcode_voucher')) { $cnfg = variable_get('regcode_vo...

java - How can you protect info contained in an APK? -

i assume someone's built apk decompiler..... what's best practice secure sensitive info (like auth parameters backend database)? suppose kind of middleware work can't things speed. what's "right way"? it's difficult reverse-engineer dalvik byte code; understanding there's not simple mapping java byte code, less java source, particularly if it's gone through proguard. however , auth parameters data, not code, , can snooped rather more easily. moreover, interested in breaking credentials has lots of other means of attack, including packet sniffing, don't require recovering source code. comment anon right—don't trust client. as best practices, can use public key encryption system, credentials server, etc., avoid putting sensitive info .apk file. don't trust obfuscation or obscure byte code keep secrets. won't.

c# 3.0 - How to break the data in rdlc after grouping? -

i working rdlc report in vs 2010.while displaying report after grouping table customername in rdlc ,i getting output mentioned below: page 1 customername invoice invoiceamount narmadha 6 250.00 61 550.00 62 1250.00 63 2500.00 customername invoice invoiceamount soorya 16 1250.00 21 560.00 page 2 customername invoice invoiceamount soorya 26 2150.00 163 500.00 upto n records but need output in following format: page 1 customername invoice invoiceamount narmadha 6 250.00 61 550.00 62 1250.00 63 2500.00 ...

unit testing - How to deal with memory leaks when following TDD -

say want follow pure tdd i.e. write unit tests before writing other code. when find bug must write unit test reproduces , implement fix. say there's memory leak in application. can reproduce - running particular method 1,000,000,000 times causes outofmemoryexception. test takes 10 seconds fail. long running unit tests not welcomed when consume lots of memory. later there may other memory leaks number of such tests may increase. so how fix bug tdd-way? write test demonstrates used memory did not go above threshold, not ran out of memory.

actionscript 3 - How to avoid the display of multiple alert windows in Flex -

i have timer in application. every 30 min, hit web services , fetch data , updates ui. application working fine till yesterday. suddenly, because of issue, web services not available time. during period, application displayed rpc error multiple times(more 100 alert boxes) in alert window. because of alert boxes, application hanged , not able anything. i have tried several approaches, nothing worked.finally, have tried use flag. in approaches, looked promising. have implemented it.basically, in approach whenever open alert set flag.while opening , closing alert reset flag. didn't work expected. there approach, can in avoiding multiple alert windows. please me, fix issue. i write wrapper opening alerts, , use wrapper, not alert.show in code: public class alertwrapper { private static var lastalert:alert; public static function showalert(text:string, title:string):void { if (lastalert) { popupmanager.removepopup(lastalert); //o...

json - Working with concatenated JValues in liftjson -

using scala 2.8 , lift 2.2. i'm calling github api , requesting repositories user. when user has less 30 repos 1 call made , there no need concatenate jvalues. however, when user has more 30 repos multiple calls made. concatenate these results these calls , "flatten" them. i.e. "repositories" name on jvalue should return repos not first 30. the code below returns following: array(list(jobject(list(jfield(repositories,jarray(...jobject(list(jfield(repositories,jarray...)))))))) what want is: array(list(jobject(list(jfield(repositories,jarray(....))))) repositories name points all of repos. i've wrestled bit , can't seem it. import java.io._ import net.liftweb.json.jsonast._ import net.liftweb.json.jsonparser._ import org.apache.http.client.methods.httpget import org.apache.http.impl.client.{ defaulthttpclient } object github extends application { implicit val formats = net.liftweb.json.defaultformats val client = new defaulthttpclient...

Optimal way of checking if any of multiple strings are non-empty (in php) -

i have several strings may or may not empty. if of them non-empty, mysql insertion should called. i've coded simply, thinking fastest method of testing if any of them non-empty. $a = something; $b = something; $c = something; options if($a!="" || $b!="" || $c!="") if($a.$b.$c!="") if(strlen($a) || strlen($b) || strlen($c)) if(strlen($a)>0 || strlen($b)>0 || strlen($c)>0) if(strlen($a.$b.$c)) if(strlen($a.$b.$c)>0) i this: if (!$a || !$b || !$c){ ... } there no overhead of function strlen etc. ! bet there.

hyphenation - HTML: Soft hypen (&shy;) without dash? -

i have little layout problem: on clients website, show contact information of people in little box. width of box constrained. happens, there people long names (this in germany, after all...), , email address concatenation of given name , family name. result: names, email address overflows constraints given box. inserting &shy; before @ results in correct line break, looks this: john.doe- @example.com is possible suppress dash? don't want use <br /> , because 90% of names, available width more enough. though i'm not sure how cross-browser (probably pretty well), use thin space character ( &thinsp; ) or zero-width space ( &#8203; ). ++ john.doe&thinsp;@example.com ++ not suggest using zero-width space, apparently browsers not render correctly ( source ).

mysql - Problem with multiple prepared statements -

here's issue. have prepared statement, this: $select_something = $db->stmt_init(); $select_something->prepare (" select whatever table "); $select_something->execute(); $select_something->bind_result($whatever); when alone - works. when add 1 after it's execution works. when try first prepare them both: $select_something = $db->stmt_init(); $select_something->prepare (" select whatever table "); and execute them later on: $select_something->execute(); $select_something->bind_result($whatever); the first statement gets executed, , second 1 throws error both lines above: *warning: mysqli_stmt::execute() [mysqli-stmt.execute]: invalid object or resource mysqli_stmt* note, statements named differently ($select_something , $select_something_else), thought it's needless repeat code. thanks! note mysqli extension has been replaced pdo , simpler use , better behaved. should use rather mysqli. if need pdo t...

how do i clone a widget in GWT , any widget not just button? -

i saw on here gwt clone widget using dom.clone had method button.wrap , dont wanna clone button wanna clone child elements of horizontalpanel. im using clone widget removing handlers , stuff cloned widget using setelement method , copying html stuff new html , class clonedwidget extends widget { public clonedwidget(element element) { setelement(element); } } any other way ? afaik there's no built-in way clone arbitrary widget. 1 way solve problem create new widget (in case factory method can helpful). also, can take @ this question .

Google App Engine PIL lib TypeError: object of type 'Image' has no len() -

i want crop image using images library of google app engine. code part using following. key = self.request.get("blobkey") img = images.image(str(key)) images.crop(img,0.0,0.0,0.5,0.5) resim = img.execute_transforms(output_encoding=images.png) content = { } self.response.headers['content-type'] = "image/png" self.response.out.write(resim) but when try crop image, gives such error. typeerror: object of type 'image' has no len() is there knows error or there other way can crop image in python? thanks in advance.. looking @ image documentation class image(image_data=none, blob_key=none) you forgot specify blob_key name parameter calling image constructor: key = self.request.get("blobkey") img = images.image(blob_key = str(key)) #you should specify blob_key images.crop(img,0.0,0.0,0.5,0.5) resim = img.e...

sql - WITH statement not working in Postgresql -

i have following sql query run in pgadmin: with table1 ( select int1, int2, int3 atbl ) select int1, <complex computation involving large number of values of int2 , int3 table1> table1 the result of running error message: error: syntax error @ or near "with" line 1: table1 why happen? statement should available postgresql: http://www.postgresql.org/docs/8.4/static/queries-with.html it understood version lower 8.4. there alternative using achive same results? i found this , this helpful. , make sure using version >= 8.4 that's when introduced. not having ; shouldn't issue. your syntax looks correct though... works. with table1 ( select * atbl ) select * table1 so i'd check version running. give error experiencing.

cocoa touch - Is there a way to use UIView animations with custom ease equation -

uiview provides few easing options ( uiviewanimationoptioncurveeasein , uiviewanimationoptioncurveeaseout , uiviewanimationoptioncurveeaseinout ) animation, want more control on easing. is there way provide custom equation, or in way more control on it? is, aside using touchesbegan: etc. roll own animations. i think need use core animation this. http://developer.apple.com/library/mac/#documentation/cocoa/conceptual/coreanimation_guide/introduction/introduction.html using cakeyframeanimation ( http://developer.apple.com/library/mac/#documentation/graphicsimaging/reference/cakeyframeanimation_class/introduction/introduction.html#//apple_ref/occ/cl/cakeyframeanimation ) can customize timing of animaiton

ruby on rails - Deploy static assets to Amazon S3 -

what easiest way deploy static assets (javascript, images, css, …) amazon s3? there perfect solution? with "perfect" mean: git push heroku master thing have both code pushed heroku , assets uploaded s3. i don't think you're going able 'perfectly' using git. what may more use use heroku san plugin , use after_deploy task move assets final resting places perhaps? although, aren't static assets best suited on heroku can take advantage of caching makes use of? typically commit js, css , images layout git , deploy heroku whilst user assets uploaded s3.

c# - Load implementation based on a parameter -

i have problem: in c# i'm making program should connect various databases (sqlite, sql server compact, ms access, etc). set in app.config parameter called "dbtype" (it 1 sqllite, 2 sql server compact, 3 ms access, etc.). parameter should changed user while program running, dropdown menu or this. then program reads parameter , creates instance of implementation of database interface (idatabase) corresponds chosen database. the code is: class objectdatabasecreator { protected objectdatabase objectdb; protected object objectdao; protected int dbtype; protected string dbname; public objectdatabasecreator() { } public objectdatabasecreator(string dbname) { this.dbtype = objectconfiguration.getdbtype(); this.dbname = dbname; } public objectdatabase getobjectdatabase() { //1 - sqlite; 2-sqlserver compact; 3-sqlserver express; 4-ms...

php - Why does using $this inside a class in a Wordpress plugin throw a fatal error? -

i'm in process of writing wordpress plugin creates page in admin area, executing frontend code. the code below throws nice fatal error: using $this when not in object context error. rather mystifying, variable called inside class. maybe i'm not following intended wordpress plugin structure functions , classes, conceptual code below created using relevant entries on plugin development in wordpress codex. could explain why error triggered, because when create instance of class outside of wordpress codebase fine. if (!class_exists("myclass")) { class myclass { var $test = 'test variable'; public function index() { //index code } public function add() { echo $this->test; } } } add_action('admin_menu', 'my_plugin_menu'); function my_plugin_menu() { add_menu_page('my plugin', 'my plugin', 'manage_options', 'my-plugin', array('myclass', 'index'));...

c++ - boost-units - using a dimensionless type of arbitrary system -

i trying make dimensioned vector class boost-units so, //vector constructed vec<si::length> v(10, 1.0*si::metre); template<typename dimension> class vec { public: //constructor setting values q. vec(const size_t, const boost::units::quantity<dimension> q) //etc } it works fine except operator*= , operator/= element wise multiplication , division. since these not change dimension, make sense when multiplying/dividing dimensionless quantity: struggling find arbitrary dimensionless quantity not locked specific system (e.g. si or cgs units). i want like, /** multiply dimensionless vector. */ vec<dimension>& operator*=(const vec<boost::units::dimensionless_type>& b); or perhaps metaprogramming magic (i notice boost::units::is_dimensionless exists, have no idea how use not versed in general metaprogramming techniques) template<typename dimension> template<typename a_dimensionless_type> vec<dimension...

string - Help needed in Segmentation Error in my C code -

i have been trying identify program generates segmentation no avail. need in pin-pointing of strings operations or char pointers causing segmentation fault during runtime. program compiles gives segmentation error during run-time. #include<curses.h> #include<strings.h> #include<unistd.h> #include<stdlib.h> /*implements scrolling headband takes string argument , continously scrolls*/ int main(int argc, char* argv[]) { /*a substring function return substring of string*/ char *substr(const char *src, int start, int len); /*appends character given string*/ void append(char* s, char c); /***check if argument invalid***/ if(argc!=2) { puts("invalid number of arguments: usage:headband <string>"); } /**get headtext string argument argv[1]**/ char *headtext = argv[1]; /*headband(headtext);*/ /*temporary variable store strings execution progresses*/ char temp[100]; /*co...

c# - Do generic classes have a base class? -

i pass generic interface function: private i<t> createstubrepository<t, >() : agenericbaseclass so wondering if generic interfaces implement base class or specific interface? i know using reflection can test if generic class dont see helping me well. what's point of forcing usage of any interface? not (or question). you should more this: public interface imyrepository<t> { } public class repository<t> : imyrepository<t> { } private imyrepository<tentity> createstubrepository<tentity>() { return new repository<tentity>(); } var repos = createstubrepository<user>(); update thanks answer thats not asking. want know class implements generic interface have base class or inherit interface? dont want force interface more question of object passed generic classes not inherit interfaces. implement them. different subtle important. a class can inherit class. means if not specify class inherits...

Socket Listener (on Linux) -

i'm searching way listen specific port on specific ip , dump incoming data. it has work on linux, perferrably comes debian package if have compile thats fine to. would nice if data gets stored in mysql database, file ok to. thanks! use command nc -l hostname 10000 > op.txt

Jquery Facebox - Login problem -

i'm going implant jquery plugin facebox show popup box username , password input fields login in site. problem browsers firefox won't show remembered password in password field. anyone know how solve problem? it's linked firefox settings , not jquery plugin

c++ - assigning the value of a 2d matrix to an variable -

i have 3x3 matrix not sorted. after sorting 3x3 matrix in ascending or descending order want store median value in integer variable ( int med ). as matrix having odd number of elements know every time median value matrix[1][1] , have written this: int med = matrix[1][1]; though no compile time error in visual studio while running application median, got below run time error: "#2 run time check failure..the stack around variable matrix[][] corrupted.. here code: #include "stdafx.h" #include <math.h> #include <mtip.h> #define max 3 int medianfilter_mif(hmtipmod hmod ,dataset_byte *in,dataset_byte **out,int th) { if(!in) { mmsg_reporterror("missing input!"); return mrv_failure; } *out = (dataset_byte*)md_datasetclone((dataset*)in, dst_same); if(!*out) { mmsg_reporterror("could not clone image!"); return mrv_failure; } byte *pin = data_ptr(in); byte *pou...

java - wagon-ssh-1.0-beta-2.jar usage problem -

did use wagon-ssh-1.0-beta-2.jar ( http://grepcode.com/snapshot/repository.jboss.org/maven2/org.apache.maven.wagon/wagon-ssh/1.0-beta-2 ) library scp upload files in java ? can give me example how upload scp file ? this ssh provider maven wagon . doesn't make sense unless used maven context. if want use scp java, check out previous question: scp via java

c# - HttpWebRequest returns empty text -

when try fetch content of url http://www.yellowpages.com.au/qld/gatton/a-12000029-listing.html using system.net; httpwebrequest request = (httpwebrequest)webrequest.create(link); request.allowautoredirect = true; httpwebresponse response = (httpwebresponse)request.getresponse(); stream resstream = response.getresponsestream(); streamreader objsr; objsr = new streamreader(resstream, system.text.encoding.getencoding("utf-8")); string sresponse = objsr.readtoend(); i don't response server. please me find out why happens. thanks in advance! it may looking @ user agent , refusing serve content client doesn't identify itself. try setting useragent property on request object.

java MultiTouch application on windows? -

can develop multitouch applications in java runs on windows? replacement events need write in java touch events touch down, touch , used in .net framework. im new java programming please help. at time, java not come support multitouch. have @ mt4j framework.

How to remove a row from Google Datastore using Java? -

i want remove row entry google datastore. i have coded : string[] elements = deletedrow.split(","); datastoreservice datastore = datastoreservicefactory.getdatastoreservice(); entity row = new entity("row"); key rowkey; (string element : elements) { row.setproperty("username", "kapil.kaisare"); out.print("username : " + element); row.setproperty("description", element); rowkey = row.getkey(); out.print("\nkey : " + rowkey); datastore.delete(rowkey); } deletedrow query parameter coming ajax javascript call & that's not empty sure. username printed successfully. while key prints : key : key 0 this surprising me ! why there key 0 if setting row properties ! please suggest solution. for reference : queries , indexes , enti...

flash - When Upload photo to Facebook with Rest API I get duplicate posts in Wall -

i'm developing facebook app flash builder users can create 6 pictures , publish them photo album. the upload works fine different number of duplicates wall once photos published album. want see post wall last 3 photos i've uploaded, in 1 row. 3 posts same photos, 4 etc... weird post news feed or wall behaves in different way. this how upload photos protected function uploadphotos(event:mouseevent):void { var values6:object = {caption:'caption', filename:'file_name', image:img6}; facebook.callrestapi('photos.upload', handleuploadcomplete6, values6, 'post'); var values5:object = {caption:'caption', filename:'file_name', image:img5}; facebook.callrestapi('photos.upload', handleuploadcomplete5, values5, 'post'); var values4:object = {caption:'caption', filename:'file_name', image:img4}; facebook.callrestapi('photos.upload', handleuploadcomplete4, values4, ...

wcf - Restarting a persisted workflow using a self-hosted WorkflowServiceHost -

i'm trying work out how resume persisted workflow i'm self-hosting workflowservicehost. host wires persistence , idling behaviour so: // persistence var connstr = @""; var behavior = new sqlworkflowinstancestorebehavior(connstr); behavior.instancecompletionaction = instancecompletionaction.deletenothing; behavior.instancelockedexceptionaction = instancelockedexceptionaction.aggressiveretry; behavior.instanceencodingoption = instanceencodingoption.none; host.description.behaviors.add(behavior); // idle behaviour var idlebehavior = new workflowidlebehavior(); idlebehavior.timetopersist = timespan.fromminutes(2); idlebehavior.timetounload = timespan.fromminutes(2); host.description.behaviors.add(behavior); i storing workflow instance guid against productid in database inside custom activity contained in workflow, able trace specific workflow instance product id. want ...

jquery - Is continuation-style-programming prone to stack overflow -

in response this question jquery effects, thought using callback argument .fadein( 500, my_function ) . while in principle, viable idea, have no clue (and neither has jquery documentation :( ) if callback allowed recurse: function keep_animating(){ $("#id").fadein(500).fadeout(500, keep_animating ); } you add debugger breakpoint , test if stack size increases or not. :) however, since animations/fadings use settimeout/setinterval highly guess call depth not increase, i.e. it's not prone stack overflows.

user interface - GUI library for PyPy -

is there presently gui library can used development in pypy? there no gui working pypy of now, except wxpython ( blog post ). use web-based uis stuff anyway, that's irrelevant.

C#/XAML/WPF binding working partially, only displays first item in List -

i have should simple binding, problem i'm seeing instead of displaying 3 companies (company_list list, company contains company_id bind to), see window pop first company_id in company_list. have other bindings seem work fine, , in other cases see i've used itemsource instead of datacontext, when use "items collection must empty before using itemssource". i've searched extensively simple answer in stackoverflow, msdn , elsewhere, , have seen complex solutions haven't been able understand/apply. when window appears, has: companya where should have: companya companyb companyc which content of company_list (yes, verified in debugger). suggestions appreciated! code , xaml follow. readmastercompanylist(); // populates a_state.company_list 3 companies // display company list dialog companyselect cs_window = new companyselect(); cs_window.companylistview.datacontext = a_state.company_list; // fails: cs_window.companylistview.ite...

PHP: Check if email already exists when running this code -

i have built simple php form allows user send application using following php code: if($_server['request_method'] == 'post') { $host = '###'; $username = '###'; $pass = '###'; mysql_connect($host,$username,$pass); mysql_select_db("###"); $status = mysql_real_escape_string($_post['status']); $firstname = mysql_real_escape_string($_post['firstname']); $lastname = mysql_real_escape_string($_post['lastname']); $email = mysql_real_escape_string($_post['email']); $url = mysql_real_escape_string($_post['url']); $query = "insert creathive_applications values (null,'$status','$firstname','$lastname','$email','$url')"; $result = mysql_query($query) or trigger_error(mysql_error().". query: ".$query); } ...