Posts

Showing posts from May, 2013

sql - Check date value in Netezza -

in netezza , trying check if date value valid or not ; isdate function in sql server. i getting dates 11/31/2013 not valid, how in netezza can check if date valid exclude them process. thanks i don't believe there built-in netezza function check if date valid. may able write lua function this, or try joining "date" lookup table, so: create table 2 columns: date_value date date_string varchar(10) load data table valid dates (generate file in favorite tool, excel, unix, whatever). there can more 1 row per date_value (different "valid" formats) if use this check. if fill in from, say, 1900 2100, long data within range, you'll fine. , it's small table, too, ~200 years ~7300 rows. add more if needed. heck, since nz date datatype goes ad1 ad 9999, fill 3.4 million rows (small nz). then, isolate rows have invalid dates, use join or exists / not exists table, on date_string. since table small, netezza broadcast spus, making performanc

c# - Clearing image and draw information on it -

hi want draw information on image in c#. wrote code , works: bitmap bmp = new bitmap(@"g:\cert_template.png"); graphics g = graphics.fromimage(bmp); g.drawstring(cert_id, new font("b zar", 3,system.drawing.fontstyle.bold), brushes.black, new point(85, 95)); g.drawstring(date_cert, new font("b zar", 3, system.drawing.fontstyle.bold), brushes.black, new point(85, 135)); g.drawstring(s1 + s3, new font("b zar", 4, system.drawing.fontstyle.bold), brushes.black, new point(90, 290)); g.drawstring(s4, new font("b zar", 3, system.drawing.fontstyle.bold), brushes.black, new point(480, 360)); g.drawstring(date_exam, new font("b zar", 3, system.drawing.fontstyle.bold), brushes.black, new point(170, 515)); g.drawstring(convert.tostring(mark), new font("b zar", 3, system.drawing.fontstyle.bold), brushes.black, new point(520, 600)); g.drawstring(lvl, new font("b zar", 3, system.drawing.fontstyle.bold), brushe

user interface - Python, PySide sleep without stalling the whole program? -

i have piece of code: self.connect(self.yes_button,signal('clicked()'),self.yes_pressed) self.connect(self.no_button,signal('clicked()'),self.no_pressed) def yes_pressed(self): self.box.append("hello") time.sleep(2) self.box.append("text2") what when yes button pressed waits 2 seconds first appends both hello , text2(box qtextbrowser() object)how make appending one, wait 2 seconds , append other 1 instead? there simple solution this? you can this, using pyqt's qtimer . more singleshot setup : qtimer.singleshot (int msec, qobject receiver, slot()slot() member) qtcore.qtimer.singleshot(1000, lambda: self.box.append("text2")) #1000 milliseconds = 1 second or can event try implementation: self.timerscreen = qtimer() self.timerscreen.setinterval(1000) #1000 milliseconds = 1 second self.timerscreen.setsingleshot(true) self.timerscreen.timeout.connect(self.box.append("text2"))

perl - Compare size of change rather than number -

i need compare values list represent log magnitudes of change: '1.3118 2.07985', '1.18887 0.990066', '2.63964 2.31757', '0.828566 1.03155', '-0.895715 -0.993696', '1.24353 1.35931', '1.2916 1.03409', '-0.747429 -1.18246', '1.30936 1.20244', '1.40537 1.27763', '-1.07762 -0.978337', '0.755268 0.837232', '0.919512 1.09517', for each row, want make comparison , store value greatest magnitude of change. example have (thanks on question regex value comparison ) comparison: if ($condition1_match > $condition2_match) { push @largest_change, $condition1_match; } would rightly value -0.895715 smaller -0.993696 . want write comparison recognises -0.993696 higher fold change -0.895715 you use absolute values: if (abs $condition1_match > abs $condition2_match) { push

fixupKeys() function in breeze.debug.js -

function fixupkeys(em, keymappings) { keymappings.foreach(function (km) { var group = em._entitygroupmap[km.entitytypename]; group._fixupkey(km.tempvalue, km.realvalue); }); } for 1 of entities, seeing group return undefined, , throws error group._fixupkey(). it looks me km.entitytypename stores short name of entity, em._entitygroupmap stores concatenated name of entity it's namespace. anyone know if breezejs bug? or doing wrong in model responsible mismatched key? it issue implementation of custom breeze dataservice adapter. looking @ me.

python - Plot array content in grid -

now have 24*20 array below: in [748]: zb_mean out[748]: array([[ nan, 20.68575654, 14.11937546, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan], [ nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, ... ... ... ... ... ... in [749]: zb_mean.shape out[749]: (24, 20) then creat grid according lat/lon below: xi = np.arange(-66,-72,-0.25) yi = np.arange(40.5,45.5,0.25) in [755]: len(xi),len(yi) out[755]: (24, 20) xxb,yyb = np.meshgrid(xi, yi) now grid , array have same dimension,i want plot grid(xxb,yyb) correspond value of array(zb_mean) in center of each small grid, how should do?thank much! if u

c# - Disabling other tabs when clicked on a button -

i disable tab selection when clicking on button. using following code: foreach (tabpage page in scenarioselectiontab.tabpages) { if (scenarioselectiontab.selectedtab != page) page.enabled = false; } the problem is, when use code above, disables current tab well. how can prevent it? try variant: foreach (tabpage page in scenarioselectiontab.tabpages) { ((control)page).enabled = scenarioselectiontab.selectedtab == page; } tabpage class don't have working enabled property. read msdn. if don't work, try variant selected event: private void tabcontrol1_selecting(object sender, tabcontrolcanceleventargs e) { if (e.tabpage != scenarioselectiontab.selectedtab) e.cancel = true; }

java - JNI %1 is not a valid Win32 application -

i'm running netbeans on 64-bit windows 8, jdk 1.7_25 (64-bit), following instructions beginning jni netbeans ( https://netbeans.org/kb/docs/cnd/beginning-jni-linux.html ) the instructions linux, principle same windows believe (generating .dll file instead of .so, using win32 includes in jdk, etc) i have cygwin64 installed cygwin32. using cygwin64, i'm able generate 64-bit dll c/c++ dynamic library project. however, when call system.load("path/to/jnitest.dll"), get: exception in thread "main" java.lang.unsatisfiedlinkerror: c:\users\andrew\documents\netbeansprojects\jnitestlib\dist\jnitest.dll: %1 not valid win32 application @ java.lang.classloader$nativelibrary.load(native method) @ java.lang.classloader.loadlibrary1(classloader.java:1957) @ java.lang.classloader.loadlibrary0(classloader.java:1882) @ java.lang.classloader.loadlibrary(classloader.java:1843) @ java.lang.runtime.load0(runtime.java:795) @ java.lang.system.load(syste

Merging a dataframe and a series on 2 columns using Pandas/Python -

i using python/pandas , have dataframe (1) below. have grouped id, , taken max of revision number in each group of revisions against each id produce series (2) below. i want merge (1) (2) in such way match first 2 columns of (1) corresponding columns of (2), pulling in other column in (2) appropriately [in data set of (1), 'id', 'revision' , 'colour' not consecutive columns, , there other columns]. i treating (2) key , pulling in appropriate data (1). how do using pandas? thanks in advance. max. (1) dataframe id revision colour 14446 0 red 14446 0 red 14446 0 red 14466 1 red 14466 1 red 14466 0 red 14466 1 red 14466 1 red 14466 0 red 14466 2 red 14466 0 red 14466 1 red 14466 0 red 14471 0 green 14471 0 green 14471 0 green 14471 0 green 14473 0 blue 14473 1 blue 14473 0 blue (2) series id revision 13125 1 13213

dll - Why does my code throw an Invalid Cast Exception? (C#)? -

error info: system.invalidcastexception: unable cast object of type 'classlibrary1.plugin' type 'plugininterface.iplugin'. what i'm trying program access assembly , run whatever may have. loads .dll private void addplugin(string filename) { assembly pluginassembly = assembly.loadfrom(filename); foreach (type plugintype in pluginassembly.gettypes()) { if (plugintype.ispublic) { if (!plugintype.isabstract) { type typeinterface = plugintype.getinterface("plugininterface… true); if (typeinterface != null) { types.availableplugin newplugin = new types.availableplugin(); newplugin.assemblypath = filename; newplugin.instance = (iplugin)activator.createinstance(plugin… // above line throws exception. newplugin.instance.initialize(); this.colavailableplugins.add(newplugin); newplugin = null; } typeinterface = null; } } } pluginassembly = null; } both program , assembly have these 2 interfaces: using system; namespace plugininterface { public interface iplu

javascript - Put Grunt in a subdirectory -

is possible put grunt config files in sub directory of project? want keep things more organised. e.g. myproject/grunt/gruntfile.js myproject/grunt/package.json myproject/grunt/node_modules/ i'm having problems running commands gruntfile.js under configuration. can grunt handle looking parent directory? or maybe i'm doing wrong sass: { dev: { files: { "../style.css": "../scss/style.scss" } } } when run grunt seems shrug, not understanding want in parent directory… source file "scss/style.scss" not found. yes, should possible, want use grunt.file.setbase method or --base command-line option make tasks work had put gruntfile in root of project. otherwise, run various issues tasks that, default, not write paths outside working directory. example, force option on grunt-contrib-clean plugin. here example modifies sample gruntfile getting started page use method: module.exports = functi

android - Why Application shuts down as soon as it's launched even if there's no error caution? -

i have 3 xml files layouts such as activity_behind_left_simple.xml activity_behind_right_simple.xml activity_main.xml i implemented textviews activity_behind_left_simple.xml , shows list of menu. works fine. so did same on activity_behind_right_simple.xml , too. however, application shuts down it's launched:( why that? what's wrong right side? activity_behind_left_simple.xml <scrollview xmlns:android="http://schemas.android.com/apk/res/android" style="@style/leftbehindmenuscroll" > <linearlayout style="@style/behindmenuscrollcontent" android:paddingtop="25dp" > <textview style="@style/behindmenuitemtitle" android:text="people" /> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" > <jp.fureco.iconview andr

windows - Determine if process is running -

in tcl script running process can rerun after test completes. however, there 40 second wait period allow enough time program start up. if program running not want have 40 second waiting period. there anyway search , read tasklist determine if program running? thinking pid changes everytime run program because it's being placed in different area of memory. i have batch file written process need pass result tcl. there way can accomplished? if don't have twapi, here alternative: use tasklist.exe : package require csv proc getpids {imagename} { set notaskmessage "info: no tasks running match specified criteria." set output [exec tasklist.exe /fi "imagename eq $imagename" /fo csv /nh] set pidlist {} if {$output != $notaskmessage} { foreach line [split $output \n] { set tokens [::csv::split $line] lappend pidlist [lindex $tokens 1] } } return $pidlist } # try out set imagename

javascript - jquery accordion formatting differently -

<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js" language="javascript"></script> <script type="text/javascript" src="http://www.compactcourse.com/js/accordionnew.js" language="javascript"></script> <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" /> <h1>toggle panels</h1> <div id="notaccordion"> <h3><a href="#">section 1</a></h3> <div> mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. integer ut neque. vivamus nisi metus, molestie vel, gravida in, condimentum sit amet, nunc. nam nibh. donec suscipit eros. nam mi. proin viverra leo ut odio. curabitur malesuada. vestibulum velit eu ante scelerisque vulputate. </div> <h3><a href="#">section 2</a&g

javascript - The jQuery addClass function quits my script -

uhm, i've got this script not work. it's line: document.getelementbyid('thetest').addclass('superspecial'); as class should added (but isn't) whole script quits... know why? should be: jquery('#thetest').addclass('superspecial'); or document.getelementbyid('thetest').classname += ' superspecial'; document.getelementbyid doesn't return jquery element. that's why has no method error.

locking - Why do we need a java lock for just reading? -

w.r.t readwritelock, why need lock while trying read something? locking in knowledge used if mutating variable, not reading avoid concurrent threads trying mutate variable. why need lock reading? the point of readerwriterlock make sure no other thread mutates while read it. the read portion of lock not exclusive (there can multiple concurrent readers), except regard write portion (readers wait writer , vice-versa).

python - How to conditionally update DataFrame column in Pandas -

with dataframe, how can conditionally set rating 0 when line_race equal zero? line_track line_race rating foreign 25 mth 10 84 false 26 mth 6 88 false 27 tam 5 87 false 28 gp 2 86 false 29 gp 7 59 false 30 lch 0 103 true 31 leo 0 125 true 32 yor 0 126 true 33 asc 0 124 true in other words, proper way on dataframe if columna = x columnb = y else columnb = columnb df.loc[df['line_race'] == 0, 'rating'] = 0

activerecord - Rails: Creating models from existing tables? -

i have tables created different project. names formatted aaa_bbb_ccc_ddd (all non plural , parts aren't convention word). have created schema database reading this . have make actual models. i've looked @ rmre , enforce activerecord convention on tables , change names, don't want because other apps depend on tables. what best way automatically create models , schema existing tables? just theory , not sure how work in real app: create models named activerecord convention requires, example table aaa_bbb_ccc_ddd you'll create model aaabbb , map model table: class aaabbb < activerecord::base self.table_name = "aaa_bbb_ccc_ddd" end or more human example: class adminuser < activerecord::base self.table_name = "my_wonderfull_admin_users" end now you'll have aaabbb resource in routes meaning you'll have url like: .../aaa_bbb/... and if want use table name name in url guess rewrite route: get 'aaa

reflection - get all fields and datatypes of a c# class iteratively -

i have huge c# classes defined many fields/variables. each variable simple datatype or list or class .... i want dump variables , datatype iteratively going thru child classes well. there simple c# function/code this? ps: not looking @ run time object values. extract of name , datatype enough. rk you try create following setup. getdata class take single parameter assembly, want scan different types. class take classes , child classes can find, fields , create structured xml file hold data. class getdata { public getdata(assembly assembly) { var xml = new xdocument(new xelement("root")); foreach (var type in assembly.gettypes()) { var typeelement = new xelement("class", new xelement("name", type.name)); foreach (var field in type.getfields()) { typeelement.add(new xelement("field", new xelement("name", field.nam

google apps script - Exceeding maximum subject length using message.forward -

i have searched site, , web, have had no joy. i have google apps script attached spreadsheet (among other things) forwards emails given label given email address. sent email long subject line, , script has started failing on following line of code: msgstostore[l].forward(emailaddress); the error receive "argument large: subject" the subject of original email 283 characters. forwarding message within gmail web interface works without difficulty, adding "fwd: " beginning expect. subject contains ampersand, otherwise not unusual. i need can use other .forward, or way of modifying message object before forwarding it, can't find documentation maximum size is. any appreciated. trim subject: trimmed_subject = msgstostore[l].getsubject().substring(0, 250) msgstostore[l].forward(emailadress, { subject: trimmed_subject, }); more details: https://developers.google.com/apps-script/reference/gmail/gmail-message#forward(string,object)

javascript - How to clear a textarea with jquery? -

i have following: <div class="tab-pane" id="message"> <textarea rows="4" cols="50" id="send_message" placeholder="enter text ..."> </textarea> <a href="#message" class="btn btn-large btn-info" data-toggle="tab">ok</a> <a href="#message" class="btn btn-large btn-info" data-toggle="tab">cancel</a> </div> i want clear textarea contents when click cancel button. have: $('#message').on("click", "a", function(){ if($(this).is(":contains(cancel)")) { $("#send_message")( function(){ $(this).val(''); } ); } else if($(this).is(":contains(ok)")) { ...... } }); but doesn't anything. how can fix this. you can use

error in uploading file into mysql database in php -

i'm getting error when upload file mysql: "error! file not sent!". here php code please , let me know error in code. <!doctype html> <head> <title>mysql file upload example</title> <meta http-equiv="content-type" content="text/html; charset=utf-8"> </head> <body> <form action="add_file.php" method="post" enctype="multipart/form-data"> <input type="file" name="uploaded_file"><br> <input type="submit" value="upload file"> </form> <p> <a href="list_files.php">see files</a> </p> </body> </html> add_file.php <?php // check if file has been uploaded if(isset($_files['uploaded_file'])) { // make sure file sent without errors if($_files['uploaded_file']['error'] == 0) { // connect database $dblink = ne

cocoa - Retina @2x high-resolution graphics wrongly used on standard display -

it appears images incorrectly drawn, using high-resolution equivalent, while others fine. why ? nsimage seems forcefully choose @2x high-res images when drawn images stretched to avoid this, can either choose use nsdrawthreepartimage or nsdrawninepartimage these functions avoid stretching tiling-up patterns. and if can’t use above want avoid 2x representation being used: [nsimage setmatchesonlyonbestfittingaxis:yes]

SQL Server : unsure how to retrieve selected records -

in example, can retrieve rows bb, dd, , ff using t-sql syntax , single select statement? c1 | c2 | c3 | c4 ----------------- aa | kk | 11 | 99 bb | kk | 11 | 99 cc | kk | 22 | 99 dd | kk | 22 | 99 ee | kk | 33 | 99 ff | kk | 33 | 99 ok, ended solve problem: select distinct [c4], [c1], [c2], [c3] [table] [c4] = 'myvalue' order [c3] desc. give shot: select c1, c2, c3, c4 mytable c1 in ('bb', 'dd', 'ff') if want unique c3 column query should be: select max(c1), c2, c3, c4 mytable group c2, c3, c4

android - How to update ListFragment on Runtime -

i developing app in there 3 pan layout fragments , each fragments listfragment . communicating between them via interface not able update listview new items. here code of listview need updated: public class subchapterslistfragment extends sherlocklistfragment { public interface onsubchapterselectlistener { public void onsubchapterselected(int position); } @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); madapter = null; } @override public void onstart() { super.onstart(); if (getfragmentmanager().findfragmentbyid( r.id.sub_sub_category_fragment) != null) { getlistview().setchoicemode(listview.choice_mode_single); } } // function invoked fragment (succesffully invoked) public void updatelist(int position) { log.d("success", "" + position); // position passed int layout = build.version.s

ruby on rails - Cannot deploy my application on Heroku -

i cant deploy application on heroku tried alot no luck ! , have tried bundle update not working application error error occurred in application , page not served. please try again in few moments. if application owner, check logs details. in gemfile added gem 'devise' , gem 'cancan' under gem 'rails' , ruby '1.9.3' above gem 'rails' application.rb require file.expand_path('../boot', __file__) require 'rails/all' require 'devise' config.assets.initialize_on_precompile = false when git push heroku master , see following during pushing preparing app rails asset pipeline running: rake assets:precompile rake aborted! not connect server: connection refused server running on host "127.0.0.1" , accepting tcp/ip connections on port 5432? /tmp/build_2avqf4cxqc1b9/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.12/lib/active_record/connection_adapters/pos

php - How to parse diffrent resolution m3u8 urls from m3u8 variable? -

i got following m3u8 php variable($returned_content). want replace proxy-63.somesite.com part of m3u8 video2.de.secondsite.net create hyperlink each resolution , place hyperlinks in textarea.(for each resolution hyperlink want place resolution of m3u8 in bracket after hyperlink title). could 1 tell me how can achieve task? in advance #extm3u #ext-x-stream-inf:program-id=1,bandwidth=836280,codecs="mp4a.40.2,avc1.64001f",resolution=768x432 http://proxy-63.somesite.com/sec(42341234k32jlkjk234lkwerwlk32432)/video/600/500/12345678_mp4_h264_aac_hq_2.m3u8 #ext-x-stream-inf:program-id=1,bandwidth=246440,codecs="mp4a.40.2,avc1.42000d",resolution=320x180 http://proxy-63.somesite.com/sec(45432kjkhjkj4535lkj34543454lkj43)/video/600/500/12345678_mp4_h264_aac_ld_2.m3u8 #ext-x-stream-inf:program-id=1,bandwidth=460560,codecs="mp4a.40.2,avc1.42001e",resolution=512x288 http://proxy-63.somesite.com/sec(dfgghdfdgd987435392429324343241k)/video/600/500/12345678_mp4_h2

google maps - Create a perimeter from an array of latitude and longitude arrays in Javascript -

i'm building google map application , have large array of many latitude , longitude positions. wish create perimeter these points programmatically. can please point me in right directions? thanks! here points example: var points = [[-37.81398385040291,145.22083640098572],[-37.813970000000005,145.22084],[-37.81398,145.22050000000002],[-37.814060000000005,145.22045],[-37.814910000000005,145.22047],[-37.814910000000005,145.22047],[-37.81506,145.22048],[-37.815070000000006,145.22404],[-37.815070000000006,145.22404],[-37.81401,145.22409000000002],[-37.81401,145.22409000000002],[-37.81398,145.22109],[-37.81398,145.22088000000002],[-37.815899365036444,145.2239316701889],[-37.815900000000006,145.22393000000002],[-37.816190000000006,145.22287],[-37.81626,145.22258000000002],[-37.81627,145.22230000000002],[-37.816230000000004,145.22192],[-37.81618,145.22156],[-37.8162,145.22143],[-37.81624,145.22137],[-37.81631,145.22133000000002],[-37.8164,145.22135],[-37.816810000000004,145.221

syntax - Why does Python not allow my comments to be indented at the proper level? -

i have python code looks this: ''' a) comments ''' try: do_stuff() ''' b) comments ''' except error: do_stuff() but complains (b) comments syntax error - forces me indent this: ''' a) comments ''' try: do_stuff() ''' b) comments ''' except error: do_stuff() why this, , how around it? want (b) comments @ same level "except" statement describe. thanks normally, triple quotes used multiline strings or docstrings , appear @ beginning of function/class/module documenting. when not writing docstrings, recommend use normal comment syntax: # comment also, if want have docstrings, convention dictates use triple double quotes: """ , not '''

c# - Why am I getting this error sometimes : Location Is Not Available? -

using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; using system.io; namespace diagnostic_tool_blue_screen { public static class createdirectories { static string outputfiles; static string photofilesdir; static string photofilesdir1; static string photofilesdir2; static string photofilesdir3; static string temptxt; static string tempphotos; static string outputtext; static string outputphotos; public static void createdirectories() { outputfiles = path.combine(environment.getfolderpath(environment.specialfolder.localapplicationdata), "outputfiles"); if (!directory.exists(outputfiles)) { directory.createdirectory(outputfiles); } else { directory.delete(outputfiles, true); directory.createdire