Posts

Showing posts from August, 2012

Adding a checkbox symbol using OOo API VB.NET and UNO -

i've been searching solution quite time no luck. i have pdf generating using vb.net, openoffice api , uno. generating text document , need able insert checkbox in code. one possible solution change font wingdings , type 'o' solution neither elegant nor easy implement given environment (using company created code text document creation , manipulation, have write command write document (strings)). if it's possible add checkbox string of text perfect. have tried use image of checkbox (one checked , other unchecked) , inject pdf, this: caveat - have worked itextsharp following code relevant itextsharp , concept should translate whatever pdf generating library/framework using method #1 - put checkbox image table cell dim imgcheckboxchecked image = image.getinstance(httpcontext.current.server.mappath("checkbox_checked.gif")) dim imgcheckboxunchecked image = image.getinstance(httpcontext.current.server.mappath("checkbox_unchecked.gif...

jquery - Removing part of an image src -

using jquery, i've created simple lightbox loads image upon clicking thumbnail. i'm trying lightbox work storing thumbnail src variable load main gallery image. variable however, needs '/thumbs' part of src removing find larger gallery image. i've followed numerous answers given variants of question, none of attempts emulate results seem work. i've gotten far this: $("#attractions-dave li a").live("click", function showattraction(e){ var example = $(this).children('img').attr('src', $(this).children('img').attr('src').replace('/thumbs','')); }); for reference, associated html is: <ul id="attractions-dave"> <li> <a href="../attractions/attractions.php"> <img src="../images/photos/bouncy-castles/thumbs/happyclown.jpg" alt="happy clown castle" /> </a> </li> </ul> once have got varia...

appstore approval - When ios7 releases, will apps with iOS 6 and older style UI be rejected? -

i have developed app customer live on app store. app should support ios v4.3 , later. when build app in xcode 4.5 ios sdk 6, , install on device running ios 7 beta 3, app works without issues. appearence of app pre-ios7 opaque status bar. question how strict ios 7 ui guideline.. app in existing state rejected app store after ios7 release?? regards maybe, maybe not. no 1 knows except of people @ apple , won't tell you. answer definite: maybe.

json - Multi level dictionary error in c# -

im using following code make json filtermodel f = new filtermodel(); f.filtername = "educationlevel"; f.filtervalue = new list<string>(); f.filtervalue.add("be"); f.groupname="education"; filterdictionary d = new filterdictionary(); d.filtervaluse = new dictionary<string, list<string>>(); d.filtervaluse.add(f.filtername, f.filtervalue); filterselectmodel ff = new filterselectmodel(); ff.filters = new dictionary<string, dictionary<string, list<string>>>(); ff.filters[f.groupname].add(f.filtername, f.filtervalue); var json = new javascriptserializer().serialize(ff); response.write(json); but shows exception in bellow line ff.filters[f.groupname].add(f.filtername, f.filtervalue); it shows following error the given key not present in dictionary what went wrong ? 1 can me change code: ...

c# - How to force camelcase with JavaScriptSerializer? -

is possible? i have class this: public class abc { [key] [scriptignore] public int id { get; set; } public string name { get; set; } public string anotherfield { get; set; } [scriptignore] public virtual user user { get; set; } } but serialize { "name":"foo", "anotherfield":"bar" } instead of { "name":"foo", "anotherfield":"bar" } . this how use: return request.createresponse(httpstatuscode.ok, new javascriptserializer().serialize(obj)); you can use camel case resolver newtonsoft.json.serialization; on global.asax register on application start using newtonsoft.json.serialization; protected void application_start() { config.formatters.jsonformatter.serializersettings.contractresolver = new camelcasepropertynamescontractresolver(); }

php - Yii TbButtonGroup wont work -

<?php $this->widget('bootstrap.widgets.tbbuttongroup', array( 'type'=>'success', 'buttons'=>array( array('label'=>'action', 'url'=>'#'), array('items'=>array( array( 'label'=>'set approved', 'url'=>$this->createurl('controller/dostuff'), 'buttontype'=>'ajaxbutton', 'ajaxoptions'=>array( 'beforesend' => 'function( request ) { alert(request); }' , 'success' => 'function( data ) { alert(data); }' , ), ), array('label'=>'set blocked', '...

replace - iOS: copying an object from oldArray to newArray -

i have oldarray consists of many small arrays. want take 1 of these objects (one small array), modify it, , (if user hits button) replace it. that: step 1 - made new array initialized newarray 1 small object. openedcartproduct = nil; openedcartproduct = [nsmutablearray array]; [openedcartproduct addobjectsfromarray: [sharedappdelegate.myengine.shoppingcart objectatindex:indexpath.row]]; step 2 - modify array. [[openedcartproduct objectatindex:0] setobject:[nsnumber numberwithfloat:[inputrabatlabel.text floatvalue]] forkey:krabat_key]; step 3 - replace object in oldarray. in step 2, modification happening in oldarray before replacing object. missing here? thanks in advance guys! :) edit: object modified small array consisting of nsmutabledictionary @ index 0 modifying. edit seems need deep copy here. found solution of hack, works fine, , simple enough: openedcartproduct = [nskeyedunarchiver unarchiveobjectwithdata:[nskeyedarchiver archiveddatawithrootobject...

ruby - Searching txt / excel files in an ftp server with rails? -

searching google , stackoverflow hasn't given me information need, i'm wondering if can me regarding general structure of app i'd build. basically, possible build rails app downloads files ftp server each day (the files uploaded each morning ftp) users can go app , choose file search , search file without having download anything. pull full line of results (excel formatted text document) , display in browser. is there gem this? haven't started coding because i'm not sure possible. depend on hosting platform? example, possible on heroku? i'm new rails, , don't want start if above isn't possible, or alternative (possibly better) way of searching files exists. can rails search files if they're downloaded local machine has excel installed? it possible thats work do: use net::ftp download files server start script imports files in indexing database thinkingsphinx, solr,... can find video of how deal excel files here create interfa...

javascript - Switching data models in AngularJS for dynamic select menus -

what trying have 3 different <select> menus tied same data. changing first select menu, change menus 2 , 3's data. this inside of controller: $scope.data = [ { "id" : "0", "site" : "brands hatch", "buildings" : [ { "building" : "building #1" }, { "building" : "building #2" }, { "building" : "building #3" } ], "floors" : [ { "floor" : "floor #1" }, { "floor" : "floor #2" }, { "floor" : "floor #3" } ] },{ "id" : "1", "site" : "silverstone", "buildings" : [ { "building" : "building #4" }, ...

java - Id search in elasticsearch -

now want search id in field. builder.startobject().startobject(type_series).startobject("properties"); builder.startobject(id) .field("type", "long") .field("store", "yes") .field("index", "analyzed") .field("analyzer", "test_analyzer") .endobject(); builder.startobject(title) .field("type", "string") .field("store", "yes") .field("index", "analyzed") .field("analyzer", "test_analyzer") .field("boost", "10") .endobject(); i tried search id this: .setquery(querybuilders.multimatchquery(query, id, title)) btw, can result id, instead cannot search title. search id getting results. so changed this. used multisearchresponse t...

php - Autopopulate textarea from database based on dropdown selection -

i trying autopopulate textarea values (wordpress) database based on value selected in select menu. select menu contains list of teams , wish populate textarea names of players selected team. the problem need convert selected text php variable in order use query database. so: php $usergroups = $mingleforum->get_usergroups(); $team_title = $_get['usergroup']; $team_id = get_page_by_title( $team_title ); $players = get_users( array ( 'meta_key' => 'team-meta', 'meta_value' => $team_id )); js jquery(function(jquery){ jquery('#usergroup').change(function() { jquery.ajax({ type: "get", url: "http://localhost:8888/dev_wordpress/wp-admin/admin.php?page=mfgroups&mingleforum_action=usergroups&do=add_user_togroup", data: { usergroup: jquery(this).find(':selected').text() } }).done(function( msg ) { alert( "data saved: ...

c# - How to call the Class destructor when the process is killed with TaskManager? -

this question has answer here: what message receive when kill program task manager 1 answer as object says: how call class destructor when process killed taskmanager? the class destructor called upon gc, said in msdn , meaning called program. when close application task manager, forcibly close program, meaning don't let gc go through object, , if did, gc wouldn't know release object, , if did, there no meaning because release memory after

Syntax Error during cypher query neo4j -

neo4j-sh start person=node(*) match person-[:has_stored]-> contact-[:has_number]-> (p{tn:"455"}) return contact; ==> syntaxexception: properties on pattern elements not allowed in match. ==> ==> think should have better error message here? sending query cypher@neo4j.org . ==> thank you, neo4j team. ==> ==> "start person=node(*) match person-[:has_stored]-> contact-[:has_number]->(phone{tn:"455"}) return contact" ==> ^ what error means? what other way this?? are trying do: start person=node(*) match person-[:has_stored]->contact-[:has_number]->(p) p.tn="455" return contact; if you're looking speed, index lookup in start : start p=node:node_auto_index(tn="455") match person-[:has_stored]->contact-[:has_number]->p return contact;

linux - Customize AWStats Downloads -

this seems ridiculous me, awstats not configured count exe or dmg files downloads. config file or setting can change? tried looking through documentation found no mention of pertaining downloads. i did find out add download section containing file types here http://antezeta.com/news/awstats , neither hits or bandwidth calculations close being correct. add section end of awstats.config file. following example counts *.dmg files: extrasectionname1="disk image downloads" extrasectioncodefilter1="200 304" extrasectioncondition1="url,\.dmg" extrasectionfirstcolumntitle1="file" extrasectionfirstcolumnvalues1="url,(.*)" extrasectionfirstcolumnformat1="%s" extrasectionstattypes1=hb extrasectionaddaveragerow1=0 extrasectionaddsumrow1=1 maxnbofextra1=100 minhitextra1=1 bandwidth counted unlikely match file size times download count. many downloads not complete or interrupted.

AngularJS configure a child window (Directive not working) -

ok, have child window own app.js. first, best way handle child windows, separate out logic? the issue have while controller in child works fine, directive not. have same directive defined in separate module parent, , works great. child html: <!doctype html> <html lang="en" data-ng-app="evidentia-child"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <link type="text/css" rel="stylesheet" href="css/app.css"/> <title>evidentia claims editor</title> </head> <body> <div style='width:100%' data-ng-controller='minieditorcontroller'> <textarea data-ng-model='data.editortext' data-on-keyup="handlekeyup" style='height:4em;width:24.5em;'>{{data.editortext}}</textarea> <button type='button' style=...

Android ffmpeg - 3gp to mp4(or avi) videos - not playing -

i doing android application used merge 2 videos , after merge completed play result video. using ffmpeg. when record 2 mpeg or mp4 videos, result merged video playing fine. record videos 3gp , convert mp4(or avi) , merged it. result video not playing. can me may problem? i using following code: string args[] = {"ffmpeg","-i",""+filename[i]+"", "-qscale","1", ""+environment.getexternalstoragedirectory().getpath()+"/movies/i"+(i + 1)+".mp4(or avi)"}; to merge videos: string args[] = {"ffmpeg","-i","concat:"+concatpath.tostring()+"", "-vcodec", "copy" , "-acodec" ,"copy", "-vbsf", "aac_adtstoasc", ""+env...

java - The copy constructor creates dependent copy -

i implemented copy constructor described here . still problem when update route_copy , same update applied route . so, don't understand wrong in code? public class route implements comparable<route> { private list<site> sites; public route() { sites = new arraylist<site>(); } public route(list<site> sites) { this.sites = sites; } /** * copy constructor */ public route(route r) { this(r.sites); } public void deletesite(site s) { this.sites.remove(s); } } public processdata(route route) { route route_copy = new route(route); site s = selectsite(route_copy); route_copy.deletesite(s); // !!! 'route' not contain element 's' } in copy constructor, doing shallow copy, while need deep copy: public route(route r) { this(r.sites); } here, still copying reference of list , still points same arraylist . should modify create copy of...

ios - How to stop cocos2d accumulating animation delta -

i have weird situation if app goes background , comes foreground animations accumulated somehow , applied super fast. e.g. ccrotateby catches time app in background , spins sprites fast. my app delegate has correct application state handling think.. - (void)applicationwillresignactive:(uiapplication *)application { [[ccdirector shareddirector] pause]; } - (void)applicationdidbecomeactive:(uiapplication *)application { [[ccdirector shareddirector] resume]; [[oalaudiosession sharedinstance] forceendinterruption]; } - (void)applicationdidreceivememorywarning:(uiapplication *)application { [[ccdirector shareddirector] purgecacheddata]; } -(void) applicationdidenterbackground:(uiapplication*)application { [[ccdirector shareddirector] stopanimation]; } -(void) applicationwillenterforeground:(uiapplication*)application { [[ccdirector shareddirector] startanimation]; [[oalaudiosession sharedinstance] forceendinterruption]; } - (void)applicationwilltermi...

Android Google Maps V2 Caused by: java.lang.ClassCastException: com.google.android.gms.maps.SupportMapFragment cannot be cast to android.app.Fragment -

i have in class import android.os.bundle; import android.support.v4.app.fragmentactivity; import com.coffeeandcookies.ushuaiamovil.r; public class laymapa2 extends fragmentactivity { @override protected void oncreate(bundle arg0) { setcontentview(r.layout.lay_mapa2); super.oncreate(arg0); } } this in xml <?xml version="1.0" encoding="utf-8"?> <fragment xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent" android:name="com.google.android.gms.maps.supportmapfragment" /> this in manifiest <uses-sdk android:minsdkversion="8" android:targetsdkversion="17" /> <uses-feature android:glesversion="0x00020000" android:required="true"/> <permission andr...

Why don't we use the .class extension with "java" command? -

why don't give filename.class file after java command, instead of filename ? suppose want compile test.java program, run javac test.java . ok! after produce test.class file run program run java test instead of java test.class . reason this? because not describing file run. telling java class contains main method - , class' name (in case) filename , not filename.class . the fact bytecode contained in files on filesystem implementation detail. classpath pass java command tells where classes, , main class argument tells class use. (it's different javac , because program take source files , compiles them bytecode.)

javascript - Weird Assignment IDE Warning -

i'm developing html5 canvas application. it's required work on mobile devices. 1 of features bmi calculation this: javascript code: bmi = refweight / ((refheight/ 100)*(refheight/ 100)) ; netbeans (7.3) gives me warning, saying: "weird assingnment" i know can use math.pow(); here, alteratinos code breaks code on mobile devices. is there proper way that? btw, formula bmi is: http://i.stack.imgur.com/n4ooa.gif it's bug (which believe fixed in version 8). a weird assignment hint appears when developer writes code looks this: x = x; as can see, code unnecessary , doesn't change anything.

boolean - youtube not operator isn't working via gnip -

i'm trying youtube not operator work via gnip, not having luck. i've tried searching for: ("dallas")-("dallas") ... should returning 0 results, isntead results "dallas". when search ("black") | ("white") -("multiplayer"), should lot of results call of duty black opps don't mention multiplayer, not case. both queries seem ignore not operator. if has working, can please provide example snippet. thanks try getting rid of parentheses , " characters like: black | white -multiplayer after quick test, looks give right matching.

How to use context.cube and request in Cubism.js? -

i trying learn cubism(but not find tutorials) . have few basic questions: how use context.cube locally in cubism. running cube's evaluator locally on port 1081. tried using "localhost" , no luck. how use request.eq(key,'value') . key request_events collection or request_metrics? any appreciated. [edit]: turns out there problem cube installation. have fixed , connect evaluator using "localhost:1081". however, still can't correct values using metric expressions. here data looks in mongodb('request_events' collection name): some({ "_id" : { "$oid" : "51e4347f44aee763f87a1214"} , "t" : { "$date" : "2013-07-15t17:42:18.000z"} , "d" : { "received" : { "$date" : "2013-07-15t17:42:23.817z"} , "urlbase" : "egauge2962.egaug.es" , "all" : 14837.0 , "low voltage" : 2883.0 , "lights" : 4...

How to remove potentially bad data from PHP and PDO MySql -

i'm using mysql executing queries: public function query($query, $params = array(), $format = array()) { if ( !is_array( $params ) ) return false; $dbh = parent::$dbh; if ( empty($dbh) ) return false; $stmt = $dbh->prepare($query); if ( !empty($format)) { $values = array_values($params); foreach ( $format $key => $bind ) { switch ($bind) { case '%d': $stmt->bindvalue($key + 1, $values[$key], pdo::param_int); break; case '%s': $stmt->bindvalue($key + 1, $values[$key], pdo::param_str); break; default: $stmt->bindvalue($key + 1, $values[$key], pdo::param_str); break; } } } $stmt->execute($params); return $stmt; } how can safely remove invalid characters search uses like: for instance: $...

android - Loading an activity before launch -

i have activity contains button, when press button loads second activity. second activity has listview , bunch of other stuff , on devices takes few seconds load want display progressdialog let user know activity in fact loading. have following: edit: public void rewardfirstnext(view view){ asynctask<void, void, void> progress = new asynctask<void, void, void>() { private progressdialog progressdialog; protected void onpreexecute(){ progressdialog = new progressdialog(getapplicationcontext()); progressdialog.settitle("loading installed applications"); progressdialog.setmessage("please wait."); progressdialog.setcancelable(false); progressdialog.setindeterminate(true); progressdialog.show(); } protected void doinbackground(void... voids) { packagemanager mpackagemanager = getpackagemanager(); list<applications...

symfony - Symfony2 : doctrine orm ignore if I change table name -

i made new entity called comment using command : php app/console doctrine:generate:entity i changed name in comment.php file : /** * comment * * @orm\table(name="blog_comment") * @orm\entity(repositoryclass="mysite\blogbundle\entity\commentrepository") */ class comment { /** * @orm\manytoone(targetentity="mysite\blogbundle\entity\article") * @orm\joincolumn(nullable=false) */ private $article; when try command php app/console doctrine:schema:update --dump-sql , returns me "create table comment ...". ignores changes ? i cleared cache , tried again, nothing changes... idea ? if used app/console cache:clear recommend trying rm -rf app/cache/* instead , see if fixes issue. run problem , works.

java - Camel: stop the route when the jdbc connection loss is detected -

i have application following route: from("netty:tcp://localhost:5150?sync=false&keepalive=true") .routeid("tcp.input") .transform() .simple("insert tamponems (avis) values (\"${in.body}\");") .to("jdbc:mydb"); this route receives new message every 59 millisecondes. want stop route when connection database lost, before second message arrives . , mainly, want never lose message . i proceeded way: i added errorhandler : errorhandler(deadletterchannel("direct:backup") .redeliverydelay(5l) .maximumredeliveries(1) .retryattemptedloglevel(logginglevel.warn) .logexhausted(false)); my errorhandler tries redeliver message , if fails again, redirects message deadletterchannel . the following deadletterchannel stop tcp.input route , try redeliver message database: routepolicy policy = new stoproutepolicy(); from("direct:backup") .routepolicy(policy) .errorhandler( defaulterrorhandler() .redeliver...

android - UnityPlayer as a SubView with Transparent Background? (Unity Game Engine) -

i trying following on android (then possibly on ios) , advices appreciated: overlaying unityplayer view on top of native android view 3d objects being drawn , no camera background (transparent background) my current progress: so far managed use unity3d project library android project , assign unityplayer view framelayout on top of android view camera background color showing... tried changing clear flag option depth didn't work. i managed use separate glsurfaceview assigned class extending unityplayer , implementing glsurfaceview.renderer renderer still getting opaque background. my code follows: // class extending player class customunityplayer extends unityplayer implements glsurfaceview.renderer { public customunityplayer(contextwrapper context) { super(context); } public void ondrawframe(gl10 gl) { super.ondrawframe(gl); } } // inside oncreate function: m_unityplayer = new customunityplayer(this); int glesmode = ...

python - convert to datetime64 format with to_datetime() -

i'm trying convert date time data in pandas.to_datetime() format. not working , type of df['time'] object . wrong? please note have attached time file. my code import pandas pd import numpy np datetime import datetime f = open('time','r') lines = f.readlines() t = [] line in lines: time = line.split()[1][-20:] time2 = time[:11] + ' ' +time[12:21] t.append(time2) df = pd.dataframe(t) df.columns = ['time'] df['time'] = pd.to_datetime(df['time']) print df['time'] name: time, length: 16136, dtype: object please find attach time data file here the file time contain invalid data. for example, line 8323 contain 8322 "5/jul/2013::8:25:18 0530" , different normal lines 8321 "15/jul/2013:18:25:18 +0530" . 8321 "15/jul/2013:18:25:18 +0530" 8322 "5/jul/2013::8:25:18 0530" for normal line, time2 become 15/jul/2013 18:25:18 , invalid line ...

Ensuring compatibility between both ends of a JSON-based web service -

with xml-based web-services, clunky are, there's wsdl, schemas, dtds , other mechanisms describe data format , various tools various languages not handle marshalling , unmarshalling generate corresponding classes. with json-based web services, marshalling , unmarshalling seem handled pretty well, when comes enforcing interface contracts can code , pray (or test , pray). if you're developing both ends of web service in 2 different languages -- ruby , javascript, -- , domain complicated enough you're not willing deal lot of raw hashes, want code completion , error checking , whatnot -- seems option write necessary classes, hand, in both languages, , test hell out of make sure they're consistent both each other , json representations each 1 sending on wire. are there tools make easier? of them worth using? or approach we're talking (i.e., matching class libraries on both sides) wrong begin with?

android - Webview orientation change webview loses headers -

when rotate screen webpage reloads, without original headers. i restoring webview state using: @override public void onactivitycreated(bundle savedinstancestate) { super.onactivitycreated(savedinstancestate); if (savedinstancestate == null) { // restore state of webview // webview.getrefreshableview().restorestate(savedinstancestate); webview.loadurl("my_url"); } else { webview.restorestate(savedinstancestate); } } @override public void onsaveinstancestate(bundle outstate) { super.onsaveinstancestate(outstate); webview.savestate(outstate); } any ideas on solution? restore state, contains webhistory, need headers when page reloaded! i fixed using solution: http://www.devahead.com/blog/2012/01/preserving-the-state-of-an-android-webview-on-screen-orientation-change/ it doen'st reload page, re-renders headers , included, web history intact. suggested here i modified work fragments, snippets her...

check status every time a login required view is accessed in django -

i have status delinquent users. if user has status type number of reasons, not want them access views login required. how implemented in django? override login_required annotation? can point me in right direction? in case make decorator @login_required in django. send great question shows how this. here link.

android - YouTube Video not playing in WebView -

youtube video not playing in webview. it first app ,i want webview. when open youtube video not playing, loading not playing. loading time. thank helping. java: public class mainactivity extends activity { private webview mwebview; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); mwebview = (webview) findviewbyid(r.id.webview); mwebview.getsettings().setjavascriptenabled(true); mwebview.loadurl("http://www.google.com"); mwebview.setwebviewclient(new hellowebviewclient()); } private class hellowebviewclient extends webviewclient { @override public boolean shouldoverrideurlloading(webview webview, string url) { webview.loadurl(url); return true; }} @override public boolean onkeydown(int keycode, keyevent event) { if ((keycode == keyevent.keycode_...

Header not working PHP -

hey guys need id dont understand problem . redirect , not work. , script good: <?php require_once 'php/db_connect.php';//db connect require_once 'php/functions.php';// function if(!isset($_get['pid'])){//getting page id return page $page_id = 1; } else{ $page_id = preg_replace('#[^0-9]#i', '', $_get['pid']); } $user = $_post['user_reg']; $password = $_post['pass_reg']; $result = add_user($user , $password); if(!$result){ return false; } else{ header('location:index.php?pid='.$page_id.''); die(); } ?> try capitalizing location . http://www.php.net/manual/en/function.header.php#79028 the first element of header (i.e. "location") case sensitive depending on browser.

perl - OTRS ITSM Change State -

in otrs itsm change management have changes different status , , can change state of change either workorders or manually editing change . want know possible change manager can change state pending approval approved state manually editing change , rest of states can change changer builder or change manager. can done? well, can done, not without development. you're asking on developer's forum, assume no problem. you should modify occurrences of if ( $self->{config}->{changestate} ) in agentitsmchangeedit.pm add new conditions - should refactor little.

MySQL query to JOIN tables based on column values -

i've got 2 tables. 1 part numbers, hardware names, , type , other locations of hardware has locations of specific bins contain hardware. bins don't have specific number have unique names. second table has location of hardware , bin may change on time. , i'm trying create mysql query combine data in new table outputted comma separated file. table 1 contents part number | name | type ------------+---------------+--------------- 0 | none | not applicable 25 | name1 | type1 150 | name2 | type2 table 2 contents date | bin | part number | event | location | location ---------+------+--------------+----------+-------------+--------------- 1/1/2013 | bin1 | 0 | arrive | location1 | none 1/2/2013 | none | 25 | arrive | location2 | none 1/2/2013 | none | 150 | relocate | location3 | location2 the final output of query should like: date | bin | part number...

Format javascript variable to be used by Rails -

i sending post request rails server. the server executing code : list.create!(params[:list]) here javascript (coffeescript) call : createlist: (list) -> $$.post 'http://localhost:3000/lists.json', data, null, 'json' i trying pass data formatted in way rails able read it. tried creating var params = { "list":list } , error nomethoderror (undefined method `stringify_keys' "[object object]":string) how can correctly format data passed rails? createlist: (list) -> $$.post 'http://localhost:3000/lists.json', json.stringify(data), null, 'json'

CHECK constraint in MySQL is not working -

first created table like create table customer ( sd integer check (sd > 0), last_name varchar (30), first_name varchar(30) ); and inserted values in table insert customer values ('-2','abc','zz'); mysql doesn't show error, accepted values. the mysql reference manual says: the check clause parsed ignored storage engines. try trigger... mysql> delimiter // mysql> create trigger trig_sd_check before insert on customer -> each row -> begin -> if new.sd<0 -> set new.sd=0; -> end if; -> end -> // mysql> delimiter ; hope helps.

ruby - How do I map number ranges to each other? -

how can map 2 opposing numbers ranges each other? i have 1 range 3 numbers: 1, 2, 3 (and potential decimals). i'd map on range of 1000 0. so, 1 = 1000 , 2 = 500 , 3 = 0 . ultimately, want take number 1.68 , figure out on 1000-0 scale it'd match up. using math ! assuming want linear mapping first range (1-3) second (1000-0, descending), function: y = (3 - x) / 2 * 1000 where x input ( 1 <= x <= 3 ) , y output ( 0 <= y <= 1000 ). this can generalized different ranges needed. patent pending.

php - SQLSTATE[42S02]: Base table or view not found in cakephp -

i using cakephp 2.3.6. works fine on localhost, when upload server, custom query in controller's function throws error saying "table not found". however, table exist. the database created in such manner don't have other way using custom query. appreciated. database error error: sqlstate[42s02]: base table or view not found: 1146 table 'kidzo_v3.children' doesn't exist query: insert children(birthdate,gender,user_id) values('1997-11-16','male','14121'); turns out problem used upper case name in custom query :(

Making a folder/files and writing to them in scala? -

this question has answer here: how write file in scala? 13 answers how can make files , folders in scala , write them? understand how works in other languages, scala bit trickier :/ this different other question because asks how make directories , files in scala. paul phillips mentioned parenthetically on ml, "i wrote library bunch of wrapping of java.nio.file.path", should wait see came with. in meantime, previous work on java.io has wandered restless spirit haunts: scala> import reflect.io._ import reflect.io._ scala> val f = file("my-test.txt") f: scala.reflect.io.file = my-test.txt scala> f writeall ("hello", ",", " ", "world", "\n") scala> :q apm@mara:~/tmp$ cat my-test.txt hello, world there abstractions path , directory . scala> val d = directory("....

python - Function offloaded to PyQt QThread is 2x slower -

i've been trying optimize application, , although made function run on average 10.06 seconds when profiled itself, when put on qthread , takes around 17-22 seconds. it's 2x slower in qthread . how fix that? the function initializing class called docxdocument , document read word file , parsed needs. i have qthread creates class , uses qt signals send progress information gui. here code class: class docximporterthread(qthread): ''' thread used import .docx document, report progress, , return document parsed. ''' reportprogress = pyqtsignal(int) reporterror = pyqtsignal(exception, str) reporttext = pyqtsignal(str) def __init__(self, filepath): qthread.__init__(self) self.setpriority(qthread.highestpriority) self._filepath = filepath self._docx = none self._html = '' self._bookmarks = none self._pages = none self._stop = false def run(self): def myprogresshook(percentage): self.reportprogr...

facebook - python csv write string into 1 cell -

Image
i using facebook api time, convert different format, , write csv file. works except when string gets written, separates string 2 different cells so: help me 1 cell please. thanks. my code: import csv datetime import * time import * facepy import * token = 'caaerzazahdbyaba............' graph = graphapi(token) g = graph.get('apple/posts?limit=4') mytime = g['data'][0]['created_time'] ctime = datetime(*strptime(mytime, "%y-%m-%dt%h:%m:%s+0000")[0:6]).strftime("%b %d, %y %i:%m %p") open('csvtest.csv', 'a') csvfile: spamwriter = csv.writer(csvfile, delimiter=',', quotechar='|', quoting=csv.quote_minimal) spamwriter.writerow([ctime]) the problem you're using quotechar='|' , spreadsheet program isn't understanding quote character. you can see pretty output. 2 cells not july 17 , 2013 03:53 pm ; they're |july...

WCF : Error when adding a New netNamedPipeBinding Endpoint -

friends, i have iis hosted web service ( http://localhost/directory.server/services/v2/directory.svc/ws ) works wshttpbinding. consumed webapp. need additional endpoint same service named pipe can access service project running on same machine. i made changes in web.config expose namedpipe endpoint. but, before test new namedpipe endpoint, existing wshttpbinding endpoint started throwing error change. error consuming webapp - requested service, '' not activated. see server's diagnostic trace logs more information. there no doubt addition of namedpipe endpoint causing issue. if fix namedpipe issue, both endpoints work. here web.config changes - <system.servicemodel> <servicehostingenvironment aspnetcompatibilityenabled="true" multiplesitebindingsenabled="true" /> <bindings> <wshttpbinding> <binding name="wshttp" maxbufferpoolsize="524288" maxreceivedmessagesize="10485760"...

c# - In WPF, Apply different DataTemplate to the same Item at a different level of TreeView -

kind of odd problem have here. i have pretty basic recursive tree structure: public class treenode { public string name { get; set; } public ienumerable<treenode> children { get; set; } } and displaying data in treeview using hierarchicaldatatemplate, so: <treeview name="_tree"> <treeview.itemtemplate> <hierarchicaldatatemplate itemssource="{binding children}"> <stackpanel orientation="horizontal" > <checkbox/> <textblock text="{binding path=name}"/> </stackpanel> </hierarchicaldatatemplate> </treeview.itemtemplate> </treeview> i populate tree code behind: //alltreenodes list of existing tree objects public void populatetree(list<treenode> alltreenodes) { foreach (var node in alltreenodes) { _tree.items.add(node); } } the result treeview each existing ...

dynamic - php dynamically create multi dimensional array -

Image
i writing php script extract data mysql db, want take data , store 2 dimensional array. thinking of normally, if use code this $test = array(); $test[0]=array(); $test[0]['hello']='hello'; $test[1]=array(); $test[1]['hello']='hello'; $test[2]=array(); $test[2]['hello']='hello'; print_r($test); the output be: array ( [0] => array ( [hello] => hello ) [1] => array ( [hello] => hello ) [2] => array ( [hello] => hello ) ) which how want output be so in script so in database have table standings women's league , columns are team_name, played, won, drawn, lost, for, against, points all connections have been taken care of successfully, below query $get_ladies_query = "select `team_name`, `played`, `won`, `drawn`, `lost`, `for`, `against`, `points` `standings_ladies` order pos"; an important point not before show next code that, there 2 other standings tables, men_senior , men_intermediate...