Posts

Showing posts from September, 2013

android - how to send extras to an activity with Intents? -

i have broadcastreceiver listens incoming sms messages. while new sms arrives, displays notification user can click on , open app. want pass message text activity. inside receiver: notification notifacation = new notification(); notifacation.icon = icon; notifacation.tickertext = tickertext; notifacation.when = system.currenttimemillis(); bundle bundle = new bundle(); bundle.putstring("sms_parameters", smsparameters); intent notificationintent = new intent(context, myactivity.class); notificationintent.putextra("sms_parameters", bundle); pendingintent contentintent = pendingintent.getactivity(context, 0, notificationintent, 0); notifacation.setlatesteventinfo(context, tickertext, message, contentintent); notificationmanager.notify(1, notifacation); inside activity: @override public void onresume() { bundle bundle = this.getintent().getextras(); if( bundle != null) { string smsparameters = bundle.getstring("sms_parameters");

ASP.NET MVC 4 and ContextDependentView -

i have started playing beta , discovered bit of black magic in there. when @ _loginpartial.cshtml line builds register link says: @html.actionlink("register", "register", "account", routevalues: null, htmlattributes: new { id = "registerlink", data_dialog_title = "registration" }) the link rendered on browser says /account/register . however, form in register view renders action /account/jsonregister based on viewbag.formaction value. value set? have suspicion it's contextdependentview returned register action can't quite figure out how or why. any ideas please? the real magic in ajaxlogin.js file, modifies link add content=1 querystring parameter used in contextdependentview decide whether send json form or regular form. this jquery stuff people don't bother at.

What bytes to emit for an ARM equivalent of EBFE? -

in x86, if want cause infinite loop, can emit ebfe , jump current instruction. what's arm equivalent of ebfe? that 0xeafffffe -- unconditional branch itself

RSS Failed to Fetch Wordpress Embed Videos -

before go on i'd clarify use google reader test site's rss feed. ok, if title doesn't explain enough, wordpress using custom made theme bought site, provide support haven't gotten actual answer far, hope can answer here. basically site's rss feed not fetching videos embed directly post. have troubleshoot using wordpress default theme, , embed videos fetched right in google reader. think problem lies in custom theme i'm using. but don't know how troubleshoot , move on point. has got clue might problem? first of all, authors of bought theme should offer solutions that. try source view of rss feed , check if videos included. if so, maybe there reason why google reader not fetch these. add videos rss feed. find out, how theme stores videos. write custom function manipulate rss-feed , put functions.php (be updates, afterwards). see discussion: http://wordpress.org/support/topic/custom-fields-on-rss-feed-how-to plugin additional rss fie

jQuery Lite Accordion Image Positioning -

Image
i looking @ jquery liteaccordion v2. use default set can downloaded from: https://github.com/nikki/liteaccordion , images. kind of learning plug in. however, have encountered problem image not sitting @ right place. please take @ below screen shot: i using firefox. element inspector, can see image going little bit bottom , right. not change settings. still same. have followed guide provided in website. i did try @ css file, not find 1 control image position. please, thoughts helpful me. thank in advance help. edit - code: <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>lite accordion test lab</title> <link href="css/liteaccordion.css" rel=&qu

c# - Download an Excel file -

i have read past posts here on how download excel file website. so, have setup below code: string path = mappath(fname); string name = path.getfilename(path); string ext = path.getextension(path); string type = "application/vnd.ms-excel"; if (forcedownload) { response.appendheader("content-disposition", "attachment; filename=" + name); } if (type != "") { response.contenttype = type; response.writefile(path); response.end(); } however, no download dialog box. i try both in ie 8 , firefox 10.0.2. file there, it's not locked, , it's not set read only. i'm not sure went wrong. according this link , need add line: strfilename = path.getfilename(path); response.transmitfile( server.mappath(strfilename) ); this cause open / save dialog box pop filename of sailbig.jpg default filename preset. this of course assumes you're feeding file exists. if need feed dynamically generated

linux - Which Hypervisor should I use? -

this more of advisory question. virtualization project , need software that. desktop virtualization allows run multiple operating systems on same physical hardware. cannot afford buy developer apis of vmware, have moved on linux. i did research on same , learnt xen can't installed on fedora 16. true? because doubtful of same. my questions : which operating system should install? fedora 16 /ubuntu 11.10 /any other? which software same? xen/any other? i want advise because using first time , post-installation problems hurt me bad. i newbie in linux... can please me out on this? p.s. : no offence, not asking best! asking suit purpose. if looking apis interested in libvirt simple esx style api interfacing locally virtualization hypervisor on system. libvirt works qemu, kvm, , xen , more. http://libvirt.org/ redhat has traditionally had better virtualization support in enterprise offerings. fedora not that. i'd suggest ubuntu oneiric. if looki

javascript - Passing Multiple Inner Child Node to Function -

Image
i need pass contents of inside div function, example myfun(string) . have tried using myfun((this).children[0].innerhtml) myfun((this).children[1].innerhtml) myfun((this).children[0].children[0].innerhtml) but none of seem work. can't pass getelementbyid value because function should generic since called php on various <a> elements (ideally think should include this. keyword). thanks help. in function, "this" refers link, , can't used. a cleaner solution have myfunc know going receive object contains text javascript: myfunc(obj){ alert(obj.childnodes[0].nodevalue); } html <a href="#" onclick="myfunc(document.getelementbyid('target'));return false;">click</a> <div id="target">target contents</div>

c++ - Library to check if two regular expressions are equal/isomorphic -

i need library take in 2 regular expressions , determine whether isomorphic (i.e. match same set of strings or not) example a|b isomorphic [ab] as understand it, regular expression can converted nfa in cases can efficiently converted dfa. dfa can converted minimal dfa, which, if understand correctly, unique , these minimal dfa's can compared equality. realize not regular expression nfa's can efficently transformed dfa's (especially when generate perl regexps not "regular") in case ideally library return error or other indication conversion not possible. i see tons of articles , academic papers on-line doing (and programming assignments classes asking students this) can't seem find library implements functionality. prefer python and/or c/c++ library, library in language do. know if such library? if not, know of library gets close can use starting point? haven't tried it, regexp:compare perl looks promising: 2 regex's equivalent if

Android apk expansion file libs problems -

i'm following steps in dev guide implement google marketplace (play) expansion files setup: http://developer.android.com/guide/market/expansion-files.html i'm @ section "preparing use downloader library" i've added license lib, downloader lib , zip lib projects eclipse , libs main project. question compatibility. main project set minimum api 8 (android 2.2), yet market downloader library (found here: android-sdk-mac_x86/extras/google/market_apk_expansion) set android 4 , uses methods api 11. how work? the link says: note: default, downloader library requires api level 4, apk expansion zip library requires api level 5. should looking older library? i managed fix problem removing values-v9 folder in android-sdk/extras/google/market_apk_expansion/downloader_library project. although library project built using android 4.0, seems work fine in android 2.2 project reference library.

c++ - constexpr and bizzare error -

i'm having: constexpr bool is_concurrency_selected()const { return concurrentgbx->ischecked();//gbx groupbox checkbox } and i'm getting error: c:\...\options_dialog.hpp:129: error: enclosing class of 'bool options_dialog::is_concurrency_selected() const' not literal type any thoughts on why? it means class not literal type... program invalid, because options not literal class type. checker literal type. struct checker { constexpr bool ischecked() { return false; } }; struct options { options(checker *concurrentgbx) :concurrentgbx(concurrentgbx) { } constexpr bool is_concurrency_selected()const { //gbx groupbox checkbox return concurrentgbx->ischecked(); } checker *concurrentgbx; }; int main() { static checker c; constexpr options o(&c); constexpr bool x = o.is_concurrency_selected(); } clang prints test.cpp:12:18: error: non-literal type 'options' cannot have c

c# - When does HttpRequest get created? -

in mvc web application, i'm checking request.islocal see if application running on machine--if is, set global static variable tells rest of application in 'debug mode'. the problem is, don't know when check. i tried in global.asax.cs file, under application_start(), this: protected void application_start() { if (request.islocal) isdebug = true; arearegistration.registerallareas(); registerroutes(routetable.routes); controllerbuilder.current.setcontrollerfactory(new ninjectcontrollerfactory()); } the trouble is, request object has not been initialized yet. httpexception says the incoming request not match route so, question when request object initialized, , there event of sort handle in order run check after request object ready? application_start() fires when mvc site's app pool spun up. doesn't know "request" object. though correct place set application-wide, won't able request.islocal . you&

PHP DOM html get element from another element -

i trying create php html dom work element path pattern. it looks fallow. can have different paths want have text out. like; $elements = 'h1;span;'; $elements = 'div.test;h2;span'; i tried create function handle these inserts stuck on part set 'getelementsbytagname()' in order , receive value of last element, what have done now; function convertname($html, $elements) { $elements = explode(';', $elements); $dom = new domdocument; $dom->loadhtml($html); $name = null; foreach ($elements $element) : $name. = getelementsbytagname($element)->item(0)->; endforeach; $test = $dom->$name.'nodevalue'; print_r($test); // receive value } i hope can give me input or examples. may this: function convertname($html, $elements) { $doc = new domdocument(); libxml_use_internal_errors(true); $doc->loadhtml($html); //

entity framework - Code First for SQL Server 2005? -

my development db 2008 r2 code first generates local database dropcreateifmodelchanges. my method of deploying production generate scripts local db, including data , run in production. creates of tables, including edmmetadata table , populates hash. works: run script in different 2008 r2 instance, change connection string entity model point production instance, run application. does not work: run script in different 2005 instance, change connection string entity model point production instance, run application. error indicating model has changed. i think doesn't work because db compatibility version part of hash. in production generates hash , compares hash stored in edmmetadata table. new hash different because generated against 2005 db. i guessing not have problem if generating 2005 db locally , deploying 2005 production instance. don't have 2005 installed , rather not require developers have install it, when 2008 supports 2005 compatibility mode already.

regex - Remove 'index.php' from URL with .htaccess -

i've been trying sorts of solutions site , none seem work. i'm hosting hostgator. current .htaccess file: <ifmodule mod_rewrite.c> rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ /index.php/$1 [l] </ifmodule> <ifmodule mod_suphp.c> suphp_configpath /home/user/php.ini <files php.ini> order allow,deny deny </files> </ifmodule> this in root folder of site. have tried adding ? after index.php , no luck. know why isn't working? this code can use in .htaccess (under document_root) remove index.php uri: options +followsymlinks -multiviews # turn mod_rewrite on rewriteengine on rewritebase / rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ index.php?$1 [l,qsa] rewritecond %{the_request} ^[a-z]{3,}\s(.*)/index\.php [nc] rewriterule ^ %1 [r=301,l]

python - Write text file to pipeline -

i have multiple spiders in single scrapy project. i want write separate output text file each spider spider name , time stamp. when had single spider creating file in __init method trying this, upromise generate 2 output files while other one. class mallcrawlerpipeline(object): def spider_opened(self, spider): self.awriter = csv.writer(open('../%s_%s.txt' % (spider.name, datetime.now().strftime("%y%m%d_%h%m%s")), 'wb'), delimiter=',', quoting=csv.quote_minimal) self.awriter.writerow(['mall', 'store', 'bonus', 'per_action', 'more_than','up_to', 'deal_url', 'category']) if 'upromise' in spider.name: self.cwriter = csv.writer( open('../%s_coupons_%s.txt' % (spider.name, datetime.now().strftime("%y%m%d_%h%m%s")), 'wb'), delimiter=',', quoting=csv.quote_minimal) self.cwriter.write

tsql - SQL Server 2008 R2 - programmatically copy stored procedure from one database to another -

i developing app provide separate database each subscriber. when new database needed stored proc on master db fires. creates new db , default tables. far good. need copy on several stored procs master db newly created db. not want maintain scripts or use 3rd party tools, needs dynamic. right grabbing sp contents sql_modules attempting exec against new db. problem dont' know how change database exec() fires against, default db when stored proc run master, need target. i've tried changing procedure declaration create procedure [mynewdb].[dbo].[awesomesp] sql complains 'create/alter procedure' not allow specifying database name prefix object name. answer follows: arghh! easier expected this blog post found on kodyaz.com . else. here code copies sp's in master database target database, can copy sp's filtering query on procedure name. @sql defined nvarchar(max) @name target database code: declare c cursor select definition [res

Ruby/curl link expander method is downloading the full target url -

i made handy little link expander using curl within ruby (sintra) app. def curbexpand(link) result = curl::easy.new(link) begin result.headers["user-agent"] = "..." result.verbose = true result.follow_location = true result.max_redirects = 3 result.connect_timeout = 5 result.perform return result.last_effective_url # returns final destination url after x redirects... rescue return link puts "xxxxxxxxxxxxxxxxxxx error parsing link xxxxxxxxxxxxxxxxxxxxxxxxxxx" end end the problem have geniuses using url shorteners link .exe's , .dmg's fine looks curl script above waiting full response returned (i.e. 1gb file!) before returning url. don't want use third party link expander api's have significant volume of links expand. anyone know how can tweak curb find url rather waiting full response? i've done want using using net::http process "head&qu

javascript - Incorrect Touch Event Offsets for Scrolled Page in iOS and Android -

we have web page contains few div/canvas tags allowing user draw: <div id="drawing" class="formfield" style="position: absolute; top: 444px; left: 121px; width: 302px; height: 185px; font-size: 10pt;"> <canvas id="drawingcanvas" class="inkformfield" width="302" height="185" style=""></canvas> </div> <div id="picture" class="formfield" style="position: absolute; top: 915px; left: 121px; width: 302px; height: 167px; font-size: 10pt;"> <canvas id="picturecanvas" class="inkformfield" width="302" height="167" style=""></canvas> </div> the second div/canvas (with top: 915px) not visible can scrolled , inked on. the drawing pretty straight-forward code works correctly desktop browsers (using appropriate mouse events). ipad need use touch events deter

what is a portable way in Ruby to check where STDIN will block if you attempt to read from it? -

i find out if there portable way check in ruby script whether block if attempts read stdin. following approach works unix (and cygwin) not native win32. (it based on perl approach learned long ago.) $ cat read-stdin.rb #! /usr/bin/ruby # test of reading stdin require 'fcntl' # trace info on input objects $stdout.sync=true if $debug # make sure standard output , error synchronized $stderr.print "argv=#{argv}\n" if $debug $stderr.print "argf=#{argf}\n" if $debug # see if input available, showing usage statement if not blocking_stdin = false if (defined? fcntl::f_getfl) $stderr.print "f_getfl=#{fcntl::f_getfl} o_rdwr=#{fcntl::o_rdwr}\n" if $debug flags = stdin.fcntl(fcntl::f_getfl, 0) $stderr.print "flags=#{flags}\n" if $debug blocking_stdin = true if ((flags & fcntl::o_rdwr) == fcntl::o_rdwr) $stderr.print "blocking_stdin=#{blocking_stdin}\n" if $debug end if (blocking_stdin && (argv.len

android - Unable to play Youtube stream via VideoView. How do I fix this? -

i'm trying play youtube video using videoview. gives me "can not play video" error. doing wrong in code below. url using regular youtube url : http://www.youtube.com/watch?v=q7u30li-ooc public void oncreate(bundle icicle) { super.oncreate(icicle); getwindow().setformat(pixelformat.translucent); setcontentview(r.layout.main); //init components use mvideoview = (videoview) findviewbyid(r.id.video); text = (textview)findviewbyid(r.id.textview1); //get uri data videodemo activity bundle uristream = getintent().getextras(); videouri = uristream.getstring("urivalue"); //set texfield uri string text.settext(videouri); //mvideoview.setvideopath(videouri); //provide videoview component file path , play mvideoview.setvideouri(uri.parse(videouri)); mvideoview.setmediacontroller(new mediacontroller(this)); mvideoview.requestfocus(); mvideoview.start(); } no need create separa

wordpress - Custom post type getting wrong categories and tags -

Image
ok have custom post type on blog called videos, post video. there's sceen cap below on right latest post custom post type, on left video, , under video date , time, category , tags. problem is getting wrong, tags, categories, , date. how fix this? here code of template page below <?php /* template name: single videos */ ?> <?php get_header() ?> <div id="wrapper"> <div id="container"> <div id="contentfull"> <?php the_post() ?> <div class="entry-wide"> <center><h2 class="page-title2"><?php the_title() ?></h2> </center> <div class="entry-videoo"> <?php the_content() ?> <?php wp_link_pages('before=<div class="page-link">' . __( 'pages:', 'wpbx' ) . '&after=</div>') ?> </div> <div id="vide

php - Secure transmission of file from client to a server -

i'm uploading encrypted file android phone server , decrypting same file in server side. client: used http post send file server server: php encryption: triple des i hard coded keys , iv in both client , server side. there idea how use keys , iv transmission highly secured? thanks! if android encrypts file prior transmitting , server decrypts on receipt, should use ssl/tls/https. hardcoding either key or iv horribly bad practice. if hardcode key in application, can binary has key , can read message. if hardcode iv, people not have key can potentially something( iv's can public, must random)

user interface - Proper way how to prepare data in async cancellable workflow with responsive UI -

this question based on async.trycancelled doesn't work async.runsynchronously looks complex, cut simple part try solve. suppose have functions: let preparemodel () = async { // might take lot of time (1-50seconds) let! = ... let! b = ... let! res = combine b return res } let updateui model = runonuithread model preparemodel prepares data should displayed user. updateui refreshes ui (removes old controls , creates new ctls based on new data). question: how should call 2 functions preparemodel cancellable time? the flow user clicks refresh preparemodel (1) started , running asynchronously, ui responsive , user can work application user changes data , clicks refresh again preparemodel (1) cancelled , new preparemodel (2) started user changes data , clicks refresh again preparemodel (2) cancelled , new preparemodel (3) started .. preparemodel (n) finished updateui ran on ui thread, redraws ui

mysql - How to create table of tables c# my sql -

i got site selling products. in database have 3 tables: users, countries, products. each user can sale products in many countries. when clients come visit, site, can choose search product country , product price( same product sold same user can have different prices in each country). i thought 2 implementations this: create linked table user_id, country_id, product_id. in case each time add new product need update 2 tables, linked table , products table. or create new table each country, have products in it. when have add new product need update 1 table. i second solution more, because think perform faster, both reading , inserting, how ever it's management hard, have lots of tables, , if instead of counties use cities, thousandths of tables. is there way in mysql create table of tables? what think design perform faster? do not go second solution. relational databases meant have fixed number of tables, , run lot of problems if try have variable amount

mysql - Duplicate column name in "insert...where not exists" statement -

the following part of larger database patch concerning table in roleplay characters linked skills. want on, not skills have in there, skills don't have (with count 0) , must not have (count -1). insert char2skill select * (select null, 23, 23, -1, '') foo not exists (select * char2skill `char`=23 , skill=23); the script crashes on line (character #23 linked skill #23 here), saying 1060 - duplicate column name '23' i guess it's nested select statement use define values should inserted, don't know how fix it...? mysql version 5.0.51a thanks in advance! try add fnurrps "`" around skill insert char2skill select * (select null, 23, 23, -1, '') foo not exists (select * char2skill `char`=23 , `skill`=23);

Doctrine many repository for same entity -

is possible have 2 repositories same entity ? i try that, not work.. class packagerepository extends entityrepository { public function __construct($em, mapping\classmetadata $class) { $cmf = $em->getmetadatafactory(); $class = $cmf->getmetadatafor('product'); parent::__construct($em, $class); } } any ideas ? first of all, why want that? second, answer question. can have many repositories working same entities like, simple classes after all. but can link 1 class entity class using @repository annotation (or yaml, or xml, whatever). mapping data stored in entitymanager. entitymanager know 1 repository class linked entity class, if try $entity->getreposiotry() or similar return linked class. but nothing can stop creating own classes queries , call them directly, explicitly, without relying on entitymanagers repository mapping.

affiliate - SEO Is it better to make a niche site or a page on an established site? -

i've been viewing interesting video on backlinking strategies here: http://www.smartpassiveincome.com/the-backlinking-strategy-that-works/ the strategy seems make perfect sense, have question method. suppose have established site thousands of monthly visitors. example imagine site mobile devices in general, e.g. www.mobiledevices.com now want write particular app iphone , promote earn commissions, app djing. better write article app on existing site, or create totally new niche site e.g. www.djappforiphone.com? i've been thinking pros , cons, , here's came with: in favour of niche site: full flexibility regards design , content style less risk if site gets hit google penalties ability choose specific keyword rich url more freedom write in style when writing on main site in favour of article on existing site immediate visibility existing readership levels an article existing site, more content good no need buy domain, set hosting etc. of course

java - How to get custom space between Jlist item? -

i had add few images in jlist , showing them horizontal want increase space between images in list?could suggest me way it? set fixed width , height jlist items. list.setfixedcellheight(50); list.setfixedcellwidth(100); the setborder() method setting border insets. can add lines above make margin spaces arranged: list.setborder(new emptyborder(10,10, 10, 10));

c# - Dictionary of Enum Values as strings -

i trying make api, 1 function in api takes enum parameter corresponds string used. public enum packageunitofmeasurement { lbs, kgs, }; the trivial method code have list every case in code. 30 cases trying avoid , use dictionary data structure , can't seem connect dots on how relate value enum. if(unit == packageunitofmeasurement.lbs) uom.code = "02"; //please note value has string else if (unit == packageunitofmeasurement.kgs) uom.code = "03"; here 1 way store mapping in dictionary , retrieve values later: var mydict = new dictionary<packageunitofmeasurement,string>(); mydict.add(packageunitofmeasurement.lbs, "02"); ... string code = mydict[packageunitofmeasurement.lbs]; another option use decriptionattribute decorate each enumeration item , use reflection read these out, described in getting attributes of enum's value : public enum packageunitofmeasurement { [description("

jsf 2 - Any reason to use a different JSF 2.0 implementaton other than Mojarra? -

in 1.x versions of jsf, 1 might choose go different jsf implementation oracle's reference implementation e.g. go myfaces. jsf 2.x there reason go other ri? i guess more or less same reasons jsf2 read this... mojarra or myfaces (jsf2.0 starter) and this mojarra vs. myfaces performance there many more articles myfaces vs mojarra jsf...

Where Can I Find Key Events in LightSwitch? -

i'm working on project in lightswitch , i'm trying handle keyup event on specific screen i couldn't find it, can find events (such keyup keydown lostfocus ext. ) and if not supported should handle situation that? i guess referring controls , not actual screen. so, example, handle keyboard events on textbox, 1 way of achieving in example, have "address1" textbox , want change text whenever user types letter: 1 - on activated event of screen, can required textbox: partial void customerslistdetail_activated() { this.findcontrol("address1").controlavailable += addresstextboxavailable; } 2 - on available event handler, can connect required event (you can have keyup, keydown, lostfocus , others): private void addresstextboxavailable(object sender, controlavailableeventargs e) { ((system.windows.controls.textbox) e.control).keyup += addresstextboxkeyup; } 3 - on keyup event handler, can manipulation: private void addresste

Parsing Gigantic Log File in Python -

i trying parse gigantic log file (around 5 gb). i want parse first 500,000 lines , don't want read whole file memory. basically, want below code doing while loop instead of for loop , if conditional. want sure not read entire file memory. import re collections import defaultdict file = open('logs.txt', 'r') count_words=defaultdict(int) import pickle i=0 line in file.readlines(): if < 500000: m = re.search('key=([^&]*)', line) count_words[m.group(1)]+=1 i+=1 csv=[] k, v in count_words.iteritems(): csv.append(k+","+str(v)) print "\n".join(csv) calling readlines() call entire file memory, you'll have read line line until reach line 500,000 or hit eof, whichever comes first. here's should instead: i = 0 while < 500000: line = file.readline() if line == "": # cuts off if end of file reached break m = re.search('key=([^&]*)', line)

database - How to delete child entities before parent with Entity Framework CF? -

i trying use ef code-first delete db record ( deleteme ) , it's children ( deleteme.prices ). foreach (var deleteme in deletethese) { // delete validation if(candeleteitem(deleteme.itemid)) { db.entry(deleteme).state = entitystate.deleted; foreach (var item in deleteme.prices) { db.entry(item).state = entitystate.deleted; // cascade delete } } } db.savechanges(); however, entity framework seems unable track fact child records should deleted before parent. error: the delete statement conflicted reference constraint "itemprice_item". conflict occurred in database "devdb", table "dbo.itemprices", column 'item_itemid'. statement has been terminated. how execute delete in ef? i ended finding quick line that'd me: foreach (var deleteme in deletethese) { // delete validation if(candeleteitem(deleteme.itemid)) { /// deleteme.prices.tolist().fore

ruby - Rails 3. Why is my nested record deleted when I go to the Edit page? -

every company supposed have 1 companycontact. company form has fields company contacts. when update company , add new company contact, works fine, because in show page company, show new company contact. when click edit link takes me edit page (note: don't click update button yet), in edit company form companycontact supposed blank. check logs , companycontact deleted. delete "company_contacts" "company_contacts"."id" = ? [["id", 4]] i'm confused because haven't called delete action. ---------------------------------------- company.rb has_one :company_contact, :dependent => :destroy accepts_nested_attributes_for :company_contact ---------------------------------------- company_contact.rb belongs_to :company ---------------------------------------- companies_controller.rb def new @company = company.new company_contact = @company.build_company_contact respond_to |format| format.html # new.html.erb format.jso

sql - Update table with Left Join -

how update table left join on script. i'm using db2 database. i created select statement , works: ** select t1.estrcd "transaction code", t1.espyno "payer", t1.escuno "customer no", t1.escino "invoice no", t1.esvono "voucher no", t1.escuam "foreign currency amount", coalesce(t2."received_amount",0) "received amount", t1.escuam + coalesce(t2."received_amount",0) "outstanding amount" m3edbedu.fsledg t1 left join (select espyno, escino, sum(escuam) "received_amount" m3edbedu.fsledg estrcd = 20 group espyno, escino) t2 on t2.espyno = t1.espyno , t2.escino = t1.escino t1.esreco = 0 , t1.estrcd = 10 , (t1.escuam + coalesce(t2."received_amount",0)) = 0 order t1.espyno, t1.escino, t1.estrcd; ** but ask me update table , set t1.esreco 9. tried using below script update

can .NET application ask the MS-Windows system to unblock a DRM protected PDF file so it can decode it? -

i know programming framework offer drm management. ask if .net technology suitable unblock drm protected pdf file (adobe drm first of all) application can open , read (it can parse file, wants file unblocked). if you're talking downloading file , blocked, stored in alternate data stream attached file in question name of "zone.identifier". for instance, if downloaded test.pdf, test.pdf:zone.identifier exist. can see file launching notepad command line "notepad test.pdf:zone.identifier". another tool see these files adsspy . another resource talking http://www.flexhex.com/docs/articles/alternate-streams.phtml

javascript - Lua Console For Webdesign? -

i have learned use lua lot of time , use javascript. find javascript harder me read , write. recently started testing web-pages. i don't mind using javascript test pages , of functions (though there libraries, prefer testing commands). is there lua console app/plugin/extension chrome or firefox runs lua , gives access dom? luajs converts lua javascript.

php - responseText not returning HTML markup -

i have web page am using innerhtml , responsetext replace contents of table upon user interaction. replacing contents of <div> {response html goes here} </div> the response html table exists inside of self. so preferred response be: `<div id="replacecontents"><div id="tablecontaner></div></div>` however when make call , have php echo div containing table receive text values, response missing of html markup. is there i'm missing here? if js looks this: document.getelementbyid('container').innerhtml = ajaxrequest.responsetext then html should this: <div id="container"><!-- place loading gif here example -->replace me</div> you want replace contents within container has id of "container".

php - Wordpress comment box not visible -

i trying show comment box under each post in wordpress. have tried <?php comments_template('',true); ?> but comment box still invisible. any please did place in right files? page.php display on pages. , on single.php single posts? single.php overrules index.php

jquery - Passing data in ASP.NET -

i'm coding application jquery mobile , asp.net. have page code: <asp:listview id="accountslistview" runat="server" datasourceid="xmldatasource1"> <layouttemplate> <div id="itemplaceholdercontainer" runat="server"> <ul data-role='listview' data-theme='c' data-inset='true'> <span id="itemplaceholder" runat="server" /> </ul> </div> </layouttemplate> <itemtemplate> <li> <a href='account_details.aspx'><h1><%#xpath("name")%></h1> <p><%#xpath("location")%></p> </a> </li> </itemtemplate> </asp:listview> <asp:xmldatasource id="xmldatasource1" runat="server" datafile="~/accountlist.xml

iis - Strange image generation error in asp.net -

i have asp.net-mvc project need dynamically generate png images. that's easy. create actionresult returns filesreamresult object. generate images used classes system.drawing such bitmap , image. works fine on local machine , on production server. when iis on production server shuts down application pool due inactivity , starts again, image generation starts fail. problem in code tries save image stream: var imagestream = new memorystream(); bmp.save(imagestream, imageformat.png); exception is: system.runtime.interopservices.externalexception (0x80004005): generic error occurred in gdi+ . there no help. tried different solutions , nothing helps. after have found topic alternatives system.drawing use asp.net? the main idea of topic is: classes within system.drawing namespace not supported use within windows or asp.net service. attempting use these classes within 1 of these application types may produce unexpected problems, such diminished service performance , r

java - Apache commons untar: IllegalArgumentException with getNextTarEntry -

i having problem compress apache library . untar archive contains binary files. here code: import java.io.bufferedinputstream; import java.io.bufferedoutputstream; import java.io.file; import java.io.fileinputstream; import java.io.fileoutputstream; import java.io.ioexception; import org.apache.commons.compress.archivers.tar.tararchiveentry; import org.apache.commons.compress.archivers.tar.tararchiveinputstream; public class archivemanager { public static final int buffer_max = 2048; public static void untar(string filename, string targetpath) throws ioexception { file tararchivefile = new file(filename); bufferedoutputstream dest = null; fileinputstream tararchivestream = new fileinputstream(tararchivefile); tararchiveinputstream tis = new tararchiveinputstream(new bufferedinputstream(tararchivestream)); tararchiveentry entry = null; try { while ((entry = tis.getnexttarentry()) != null) { int

Android - Java HashMap keySet suddenly returns null -

i have 2 methods: first 1 iterates on hashmap<string, string> ("mwidgetstartconfig") set values of spinner widgets in fragment. method called in onresume . the second method implements onitemselected callback method of onitemselectedlistener , updates values in hashmap<string, string> ("mwidgetcurrentconfig") according spinner item selected. here methods: protected void configurewidgets() { for(string tag : mwidgetstartconfig.keyset()) { int valueindex = mspinnervalues.indexof(mwidgetstartconfig.get(tag)); ((spinner) mlayout.findviewwithtag(tag)).setselection(valueindex); } } public void onitemselected(adapterview<?> parent, view v, int pos, long id) { string tag = (string) v.gettag(); string value = (string) parent.getitematposition(pos); mwidgetcurrentconfig.put(tag, value); } the weird thing is, first method works fine long don't in second method (i.e. comment out body). in second method,

PHP Mysql installation -

i messed mysql , php installation. following error when try uninstall php, can 1 help? thank :) $ sudo apt-get purge php5 reading package lists... done building dependency tree reading state information... done might want run `apt-get -f install' correct these: following packages have unmet dependencies: phpmyadmin: depends: php5-mysql not going installed or php5-mysqli not installable depends: php5-mcrypt not going installed depends: dbconfig-common not going installed depends: libjs-mootools (>= 1.2.4.0~debian1-1) not going installed recommends: php5-gd not going installed recommends: mysql-client e: unmet dependencies. try 'apt-get -f install' no packages (or specify solution). try: aptitude search php5 to see php packages got installed. then do: sudo aptitude purge php5-package1 php5-package2

xml - Python ElementTree find() not matching within kml file -

i'm trying find element kml file using element trees follows: from xml.etree.elementtree import elementtree tree = elementtree() tree.parse("history-03-02-2012.kml") p = tree.find(".//name") a sufficient subset of file demonstrate problem follows: <?xml version="1.0" encoding="utf-8"?> <kml xmlns="http://www.opengis.net/kml/2.2"> <document> <name>location history 03/03/2012 03/10/2012</name> </document> </kml> a "name" element exists; why search come empty? the name element you're trying match within kml namespace, aren't searching namespace in mind. try: p = tree.find(".//{http://www.opengis.net/kml/2.2}name") if using lxml's xpath instead of standard-library elementtree, you'd instead pass namespace in dictionary: >>> tree = lxml.etree.fromstring('''<kml xmlns="http://www.opengis.net/kml

java - executable jar file not running outside of the folder where I created it -

i created jar file in working folder jar -cfe mrmc.jar mrmc *.class *.jar db statpack and able double click jar file or run using java -jar mrmc.jar but when copy jar file location, can no longer run it. got errors: exception in thread "main" java.lang.nullpointerexeption it seems jar file did not find files in resource folder db above. thank you. i see 2 possible reasons: a) content of db directory not end in jar. unzip jar check inside. note: jar zipfile. b) not referencing files classpath resource, file resource. check methods using, if based on classpath or on file system. see question different ways load file: how should load files java application?

multithreading - Android: Inflating layout takes to long -

found solution! i use viewpager instead of viewflipper. views generated within run() method (which there because fetch data web) , saveed in map. in handler call pageradapter.notifydatasetchanged() pageradapter uses map of views , works smooth , fast. i'm looking away have viewpager scroll endless, thats problem not connected 1 ;) thank of answers , keep support. i'm quite new android development , facing problem while inflating (huge) layout. getting data webservice works fine i'm using handler within activity bring data frontend. here handlemessage: public void handlemessage(message msg) { layoutinflater inflater = getlayoutinflater(); list<integer> gamedays = new arraylist<integer>(games.keyset()); collections.sort(gamedays); (integer gameday : gamedays) { view gamedaytable = inflater.inflate(r.layout.gamedaytable, null); tablelayout table = (tablelayout) gamedaytable

php - Cakephp 2.0 returns empty, but running produced query in DB produces correct results -

so in controller have simply: $this->loadmodel('group'); $this->group->recursive = -1; $group = $this->group->findbyname($joingroup); debug($group); debug($this->group->findbyname('temp')); neither of debugs return empty array. i have in core set configure::write('debug', 2); sql queries produce is: select * `groups` `group` `group`.`name` = 'temp' limit 1 note: changes columns * spare list :) when run query in mysql command shell 1 result expecting. group name of temp. why cake not returning same query? have set make cake not return results? in group model have basically: public $hasmany = array( 'usagehistory' => array( 'classname' => 'usagehistory', 'foreignkey' => 'group_id', 'dependent' => false, 'conditions' => '', 'fields' => '', 'order' => '

ant - How to specify files matching *~? -

i have following ant target: <delete> <fileset dir="${qnaire_dir}" includes="**/*~" /> </delete> it not delete following files: ./details~ ./qnaire/__init__.py~ ./qtest.py~ ./readme~ what correct includes value match these files? i found answer! syntax looking for: <defaultexcludes remove="**/*~" /> <delete> <fileset dir="${qnaire_dir}" includes="**/*~" /> </delete> <defaultexcludes default="true" /> after skimming ant documentation delete task (http://ant.apache.org/manual/tasks/delete.html) half dozen times, noticed statement: if use task delete temporary files created editors , doesn't seem work, read on default exclusion set in directory-based tasks, , see defaultexcludes attribute below. so went , read defaultexludes. turns out default ant excludes set of file expressions directory based tasks. these listed here:

database - How do I create tables in Microsoft SQL Server 2008 R2 Express -

i have installed microsoft sql server 2008 express r2 tools. in windows start menu have option sql server management studio. click on , dialogue window pops asking me connect server. don't know server enter here , want create new database can store simple information in tables. did press cancel on dialogue box , looked around in management studio couldn't find "create new table" option or particularly that. it's looking <%computername%>\sqlexpress if don't know name of compter then... click start right click on computer click properties click computername tab

Programmatically, how does hue blending work in photoshop? -

in photoshop can set layer's blending mode "hue". if layer is, example, filled blue seems take layer below , makes blue wherever non-whiteish color exists. i'm wondering it's doing though. if have background layer pixel aarrggbb , layer on top of set blend mode "hue" , there's pixel aarrggbb on layer, how 2 values combined give result see? it doesn't drop rrggbb layer below. if did it'd color white , black well. wouldn't allow color variations through. if background pixel 0xff00ff00 , corresponding hue layer pixel 0xff0000ff i'm assuming end result 0xff0000ff because ff blue replaces ff green. but, if background pixel 0x55112233 , hue layer pixel 0xff0000ff, how come shade of blue comes with? the reason ask i'd take various images , change hue of image programmatically in app. rather storing 8 different versions of same image different colors, i'd store 1 image , color needed. i found algorithm convert rgb

regex - Alternatives to Regular Expression for HTML -

i've seen on , over, , on , on , on over stack overflow regular expression not fit xhtml. haven't seen alternative. most text editors have built in regex search , replace super easy use. well, except fact doesn't work html. there tool or language meant parsing and replacing xhtml? great if "find paragraph tags have class of "quote" within div class of "monkey", , add h2 tag "monkey quote" inside. another example i'm struggling finding solution find words within paragraph tags , wrap span tag around them (for word-by-word highlighting audio). kind of stuff. is there tool or language meant kind of thing? from last comment, i'm assuming you'd useful command-line. if so, answered pretty here: grep , sed equivalent xml command line processing

Java Regex checking valid chars for a maze -

this check needs ensure lines file begin wall , have @ 1 entrance, @ most, 1 exit, , end wall. split conditions can test them. fails cs = "wwww", "wxw", "wwwwwwwwrwwwwww" /** * check ensure lines composed of walls, * entrance, exit, , space */ protected boolean invalidmazecharacters(charsequence cs) { p = pattern.compile("^w+(r??w*|x??|w*|\\s*w*)w+$"); m = p.matcher(cs); if (!m.matches()) { return true; } return false; } try ^w+(r?w*x?|x?w*r?)w+$ it's not efficient, can work on improving it. :) also, i'm not sure rules spaces are.... addendum ^w[w\s]*(?:r?[w\s]*x?|x?[w\s]*r?)[w\s]*w$ see http://regexr.com?309c6 don't forget, if using java string, double backslashes. also, fact spaces can appear anywhere leads me suspect non-regex-based function fine, too. can iterate through sequence, counting rs , xs, ignoring spaces, making sure first , last characters ws, , returning

simulation - Anyone have an idea about testing wireless connection on wireless access point -

i have wireless access point have 50+ wireless client , connection blow in sometime. think related overload on hardware. there anyway simulate or test wireless access point in heavy connection many client, can manage see configuration best it. i don't know tool can restrict number of clients accessing router router web page. can hit , trial , see how many clients can access without router getting blown up.

Java - Convert Unix epoch time to date -

i need convert epoch time stamps real date , have used of methods found on stack overflow, give wrong answer. as example, 1 date "129732384262470907" in epoch time, "mon, 20 jan 6081 05:24:22 gmt" using http://www.epochconverter.com/ however, code generates: "wed dec 24 14:54:05 cst 19179225" string epochstring = token.substring(0, comma); long epoch = long.parselong(epochstring); date logdate = new date(epoch * 1000); bufferedwriter timewrite = new bufferedwriter(new filewriter(tempfile, true)); timewrite.write(logdate); timewrite.flush(); timewrite.close(); the initial timestamp in miliseconds, in examples saw here supposed multiply 1000. if don't multiply 1000, get: "mon aug 08 01:14:30 cdt 4113025" both of wrong. so have made error? 129732384262470907 in microseconds since epoch if it's meant 6081, need divide 1000 if that's real input. note epochconverter.com doesn't handle value

c++ - Why I can't define inline member function in another file? -

i have 3 files: 1. joy.h class joy { public: void test(); }; 2. joy.cpp #include "joy.h" inline void joy::test() {} 3. main.cpp #include "joy.h" int main() { joy r; r.test(); return 0; } i try compile them using: g++ cpp joy.cpp g++ say: main.cpp:(.text+0x10): undefined reference `joy::test()' who can tell me why... how solve problem if don't want define test() function in .h file , still want inline function? when define inline member function, should prepend member function's definition keyword inline, , put definition header file. when declare function inline telling compiler (if possible)replace code calling function contents of function wherever function called. idea function body is small , calling function more overhead body of function itself. to able compiler needs see definition while compiling code calls function means definition has reside in header because code

How do you pass in an array from the main method to another method in java? -

i have array of person in main method, , have pass in array playgame() method in class game. how do that? public class rolloff { public static void main(string[] args) throws ioexception{ int numpeople; int a; system.out.println("how many people play game?"); bufferedreader br = new bufferedreader(new inputstreamreader(system.in)); string s = br.readline(); numpeople = integer.parseint(s); if ((numpeople >= 2) && (numpeople <= 10)) { person[] p = new person[numpeople]; (a = 0; < numpeople; a++) { p[0] = new person(a); } } } } public class game extends rolloff{ int numpeople; int a; void playgame() { } } you need use parameters that: void playgame(person[] p){ ... } now call public static void main(string[] args){ ... game.playgame(p); } because playgame not static method, you&