Posts

Showing posts from February, 2014

android - Bring task to front on widget click -

i sent task (activity) with: @override protected void onactivityresult(int requestcode, int resultcode, intent data) { super.onactivityresult(requestcode, resultcode, data); movetasktoback(true); } but need bring front setonclickpendingintent in widget. just start main (root) activity of application this: intent intent = new intent(context, mainactivity.class); intent.addflags(intent.flag_activity_new_task); context.startactivity(intent); if activity running in task, bring task foreground (without creating new instances of activity). if activity not running, start new task activity @ root.

Empty order_by field from jqgrid causes failure in tastypie api -

i'm using jqgrid access tastypie api. i've changed sidx "order_by" match default tastypie api. jqgrid passes order_by (formerly sidx) parameter regardless of whether it's ordering or not. if not sorting, passes empty string sort critiera. tastypie freaks out @ empty string saying "there no field named '' " the way see it, there's 2 options solve: have jqgrid stop sending order_by param unless needs to have tastypie ignore empty order_by string... any suggestions on how either of 2 things? i not sure, full understand problem. first of rename sidx order_by 1 can use prmnames: {sort: "order_by"} if never sidx or order_by send can use prmnames: {sort: null} you can implement scenarios in changing prmnames.sort dynamically. can use jqgrid callbacks or events . one more way control list of parameters sent server serializegriddata callback. example serializegriddata: function (postdata) { var mypostdata = $.extend(...

asp.net mvc - MVC Entity Framework Annotation -

say have following code: truck truck = new truck(); truck.id = '12323' return view(truck); note entity truck has number of fields associated such color, note, etc. for note, add annotation maxlength. how go adding , annotation. know done in class in case, not have class getting truck directly entity framework. you want make partial class (aka buddy class) entity class , give metadatatype attribute. check out example validation attributes. section labeled using data annotation validators entity framework . http://www.asp.net/mvc/tutorials/older-versions/models-(data)/validation-with-the-data-annotation-validators-cs

jquery - Animation delay for this snippet? -

i read on jquery delaying, can't seem delay animation mouseover call: $("div#test").mouseover(function () { $("div#test").delay(1000).animate({width:100}, {queue:false}); $("div#test").delay(1000).animate({height:100}, {queue:false}); }); what doing wrong here? the problem queue: false boolean, has effect of starting animation (from api page animate() ): queue : boolean indicating whether place animation in effects queue. if false , animation begin immediately. removing that, , combining effects 1 animate() call seems make things work expected: $("div#test").mouseover(function () { $(this) .delay(1000) .animate({width:100, height: 100}); });​ js fiddle demo . references: animate() . delay() .

java - Running hadoop job: Class not found - org.apache.tools.ant.launch.AntMain -

i have locally installed hadoop on debian linux distribution in vmware , having difficulties running test jobs. i can build create package intellij idea, mrunit tests pass expected. once try run job, following exception: exception in thread "main" java.lang.noclassdeffounderror: org/apache/tools/ant/launch/antmain @ java.lang.classloader.defineclass1(native method) @ java.lang.classloader.defineclass(classloader.java:791) @ java.security.secureclassloader.defineclass(secureclassloader.java:142) @ java.net.urlclassloader.defineclass(urlclassloader.java:449) @ java.net.urlclassloader.access$100(urlclassloader.java:71) @ java.net.urlclassloader$1.run(urlclassloader.java:361) @ java.net.urlclassloader$1.run(urlclassloader.java:355) @ java.security.accesscontroller.doprivileged(native method) @ java.net.urlclassloader.findclass(urlclassloader.java:354) @ java.lang.classloader.loadclass(classloader.java:423) @ java.lang.classloader.loadclass(classloader.java:356) @ java.lang.cl...

django - How to iterate over list of dictionary in python? -

i have list of dictionary in python i.e. listofobs = [{'timestamp': datetime.datetime(2012, 7, 6, 12, 39, 52), 'ip': u'1.4.128.0', 'user': u'lovestone'}, {'timestamp': datetime.datetime(2012, 7, 6, 12, 40, 32), 'ip': u'192.168.21.45', 'user': u'b'}] i want use of keys , value of listofobs variable in django-template. example: for first iteration: timestamp = 7 july 2012, 12:39 ip = 1.4.128.0 user = lovestone and second iteration : timestamp = 7 july 2012, 12:40 ip = 192.168.21.45 user = b and on .. for in listofobs: print str( a['timestamp'] ), a['ip'], a['user'] will iterate on list of dict's, use them in template wrap in needed django syntax , quite similar regular python.

html - Placeholder text in an input field with CSS only (no JavaScript) -

instead of labeling each field in form, preferable (from design standpoint) have placeholder text in each field. example, instead of having this: ---------------------------------- full name: | | ---------------------------------- you have this: ---------------------------------- | full name | ---------------------------------- the when click in field, text disappears , can write whatever want. if skip on field without entering text, placeholder reappears. i've seen done many ways, methods involve javascript. example, twitter decent job on signup page if javascript disabled end typing name on word 'full name'. i'm looking css-only method work javascript disabled. potential solution i've come set background of <input> tag image of desired text , use input:focus pseudo-class clear background image when clicks on text box. seems work nice not have use images. does know of resource on how this? this preferred method, , works in current browsers: ...

Tomcat Not Starting Through Eclipse (Timeout) -

i trying run tomcat through eclipse. have done past several years. working yesterday , not. error is server tomcat v7.0 server @ localhost unable start within 45 seconds. if server requires more time, try increasing timeout in server editor. the output is jul 06, 2012 8:32:26 pm org.apache.catalina.core.aprlifecyclelistener init info: apr based apache tomcat native library allows optimal performance in production environments not found on java.library.path: d:\program files\java\jdk1.7.0_05\bin;c:\windows\sun\java\bin;c:\windows\system32;c:\windows;c:\program files (x86)\nvidia corporation\physx\common;c:\windows\system32;c:\windows;c:\windows\system32\wbem;c:\windows\system32\windowspowershell\v1.0\;c:\program files (x86)\quicktime\qtsystem\;d:\launch;d:\program files\java\jdk1.7.0_05\bin;%programfiles%\internet explorer;c:\program files (x86)\smlnj\bin\;d:\program files\tortoisesvn\bin;c:\ghc\ghc-6.6\bin;d:\program files\mysql\mysql server 5.5\bin;%ant_home%/bin;d:\program files ...

php - Sorting nested arrays via an Element in each Sub Array -

assuming have coming json request looks -- $data = array('0'=> array('name' => 'dr. smith', 'address' => '3002 fake ave.', 'lat' => '34.711158', 'lng' => '-137.803578', 'phone' => '714.939.1324'), '1' => array('name' => 'dr. paul', 'address' => '801 fake st.', 'lat' => '31.749917', 'lng' => '-137.834388')); how order 1 of elements? if wanted sort whole array of arrays lat element? , put in $data element, can keep working it. i've read stuff on php usort , sorting sub-array element, when try work code examples aren't working. the callback function usort receive 2 of array entries (which arrays in themselves) , must answer whether $a comes before or after $b. for example function receive $a = array('lat' => 45, 'name' => 'mickey mouse', ...) $b = ...

asp.net mvc 3 - Deactive row instead of deleting -

i want inactivate rows instead of deleting them. my current code deletes character. instead want set column isactive 0 (false) [httppost, actionname("delete")] public actionresult deleteconfirmed(int id) { character character = db.characters.find(id); db.characters.remove(character); db.savechanges(); return redirecttoaction("index"); } table definition: characterid int isactive bit userid uniqueidentifier public actionresult deleteconfirmed(int id) { character character = db.characters.find(id); character.isactive = false; db.savechanges(); return redirecttoaction("index"); } if used generated .edmx, isactive should set boolean.

internet explorer - jQuery: animating backgroundPosition behaves oddly in IE < 9 -

try hovering on "cancel" button in internet explorer 8: http://jsfiddle.net/hydka/ you'll notice first time hover on it, jumps , can see "ok" button, corrects itself. subsequent hovers function normally, though. please note bug occurs "ok" button; it's more obvious "cancel" button. also, bug present in ie 6 , 7, demo i've provided won't work since image base64 encoded. the code works fine in non-ie browsers, of course. is jquery bug? there can work around besides splitting images up? include stylesheet ie < 9, i'd rather not if don't have to. thanks! old internet explorer versions wont accept css values without 'px'. example= width:10px; so need add + 'px' @ end of animate values. here working jsfiddle $(this).find('.sliding_link_image').animate({ 'backgroundposition': (sliding_link_original_background_position + 10) + 'px'//<--here }, 150); }, function() { $(thi...

php - MySQL how to grab more information with JOIN? -

currently, have 2 mysql tables. first table stores relation between friend , picture. table 1 id | pic_id | friend_id ---------------------------- 0 | 123 | 84589 1 | 290 | 11390 2 | 884 | 84589 3 | 456 | 84589 4 | 123 | 11111 5 | 456 | 22222 table 2 second table stores more information pic... id | pic_id | title | color | detail ---------------------------------------------- 0 | 123 | hello | black | brush 1 | 124 | world | red | paint 2 | 884 | sample | green | star i use join grab information need... but if want use pic_id's matched above sql , find other friend_id's same pic_id? for example, above sql command give me rows 0, 2, , 3 pic_id's 123, 884, 456. sql command should use loop through these pic_id's , grab associated friend_id's? want end 11111 pic_id 123 , 22222 pic_id 456. i have used following code accomplish above. not efficient , slow though. $sql = "select b.title, b.color, b.detail table1 inner join table2 b on a.pic_id = b.pic_id ...

ios - Using Audio Units to play several short audio files with overlap -

i have run through audio units tutorial sine wave generator , done bit of reading, , understand how working. app, play short sound file in response external event. these sounds 1-2 seconds in duration , occur @ rate of about 1-2 per second. basically @ right trying figure out how play actual audio file using audio unit, rather generating sine wave. question is, how audio unit play audio file? do read bytes audio file buffer in render callback? (if class need deal open / convert / decompress / read audio file) or there simpler method maybe hand off entire buffer , tell play? any names of specific classes or apis need @ accomplish helpful. ok, check this: http://developer.apple.com/library/ios/samplecode/mixerhost/introduction/intro.html edit: sample project. page has detailed instructions inline code setup common configurations: http://developer.apple.com/library/ios/ipad/#documentation/musicaudio/conceptual/audiounithostingguide_ios/constructingaudiounitapps/constructingaudio...

javascript - How to make a horizontal scrollbar with mouseover effects? -

helo all, have been searching on web jquery or javascript tutorial or plugin horizontal scrollbar , have found many of plugin asnd tutorial not 1 want. now im using tinyscroll , have found has alot of bugs, can me next effects. mouseover: @ mouseover @ right or left scrolls itself. shadow @ hiding: when image hides @ left or right shadow effect gives "it got in bottom of layer" effect. scrollbar: simple bar has 80% opacity mouse scroll: mouse scroll can used it. i need movie scroller in page: cuevana.tv and know html , css css -webkit styling can't effects. i dont have codes start with, please help. try this one . it has horizontal scrollbar , mouse scroll works. with css 1 in link posted. (positioning left , right carets image container , etc...)

How to test if a string is a substring of any instance of a regex? -

in programming language , library, how can test if string substring of instance of regular expression? for example, instances of regex ra = /^a{1,2}c{1,2}$/ are 'ac', 'acc', 'aac', 'aacc'. the string 'cc' not instance of regex substring of 2 instances of regex. how can test 'c' has such property? equivalently, how can (in general) regex instances substrings of instances of regex. for example above, regex rb = /^a{0,2}c{0,2}$/ has instances '', 'c', 'cc', 'a', 'ac', 'acc', 'aa', 'aac', 'aacc' which substrings of instances of ra. how can calculate such rb ra regex ra? thanks in advance! if mean computer science regular expression, can forming alternation of subsequences of tokens: /^a{1,2}c{1,2}$/ -> /^(a{1,2}|a{1,2}c{1,2}|c{1,2}|)$/ note grow in length o(n 2 ) n number tokens in original expression.

python - How to pass Django variable as javascript method parameter? -

i have following extra_context in views.py. extra_context = { 'user': list_user, 'time': str(list_time), 'latlng': list_latlng } all of above variables datatype of python list . want use these variable in gmap v3 javascript. found following snippet google map: (posting main part) <script type="text/javascript"> var map ; function initialize() { var latlng = new google.maps.latlng(-34.397, 150.644); var myoptions = { zoom: 2, center: latlng, maptypeid: google.maps.maptypeid.terrain }; map = new google.maps.map(document.getelementbyid("map_canvas"), myoptions); var flightplancoordinates = [ {% ip in latlng %}{{ ip }}{% endfor %}]; for(var in flightplancoordinates){ var marker = add_marker(flightplancoordinates[i][0], flightplancoordinates[i][1],"some title!","html info box"); marker.setmap(map); } } function add_marker(lat,lng,title,box_html) { var infowindow = new google.maps.infowindow({ content: box_html }); va...

mongodb - last update in mongoengine -

is there way find last update document in collection? in other way sort collection update somethings this people = person.objects.order_by_update() or must add update time each doc? i use mongodb , mongoengine , flask you must add field such last_updated_time if want able sort in way. also, since you're sorting on it, should index it. the thing mongodb stores default _id , can used created_time timestamp.

mysql - How to multiple join tables? -

i have 2 tables. workers , experience in table workers there row worker_parent (because 1 worker can responsible other). no must connect tables that: select w1.* workers w1 left join workers w2 on (w2.id = w1.worker_parent) and that's ok. have order experience of w2 , try add table experience it's connect w1 , not w2. my question how add table experience (which has row worker_id) w2 , order experience , select data w1. this try. select w1.* workers w1 left join workers w2 on (w2.id = w1.worker_parent) left join experience e on (w2.id = e.worker_id) order e.experience desc thank's help if want child workers have parent experince, need add (or change join type) (for readability renamed w1 , w2 w_child , w_parent) select w_child.*, e_parent.experience workers w_child left join workers w_parent on (w_parent.id = w_child.worker_parent) left join experience e_parent on (w_parent.id = e_parent.worker_id) e_parent.worker_id not null order e_parent.experience desc

performance - Debugging WPF DataGrid Virtualization Issue -

i'm using wpf datagrid (.net or toolkit), unacceptably slow when binding observable collection. contains 3500 rows , 10 columns , takes on minute display contents. points the fact not doing ui virtualization of data. however, can't figure out why case. i not using grouping. have made sure grid's height contained placing in panel fixed height. have set virtualization properties on datagrid. have checked in snoop , these properties set. however, snoop shows after loading there several thousand datagridrows in visual tree. whether caused using snoop have no idea. have tried using aqtime find out going on. slowdown not appear in our code in system code. however, can't find way of seeing wpf to. have stripped down grid , have tried both .net 4 datagrid , toolkit datagrid. both unacceptably slow show initial data. have tried fixing row height , column widths. makes no difference. how can confirm virtualisation on , if is off why off? how can debug happening outside of our ...

How do I use jquery's CSS attribute? -

i'm trying reset css, doesn't seem work although follows same structure detailed here: http://www.w3schools.com/jquery/css_css.asp function labelreset(){ $(".year").css("color" : "#000", "opacity" : "0.5", "size" : "14px"); $(".dot").css("background-color" : "#000", "width" : "7px", "height" : "7px"); }; any thoughts? you forgot use brackets {} : function labelreset(){ $(".year").css({"color" : "#000", "opacity" : "0.5", "size" : "14px"}); $(".dot").css({"background-color" : "#000", "width" : "7px", "height" : "7px"}); }; for single property: .css( propertyname, value ) , multiple properties: .css( map ) , check jquery api css .

content management system - identifying dynamic pages (created by PHP from database) -

in case question has been asked before refer me answer , shall greatful.. it's common problem have not been able find solution form google i developing website in php using codeigniter. have articles /posts. these posts located in database , when ever user demands see article, relevant data pulled database using unique "content_id" , page presented user dynamically. once data dispatched view , html page created page have no way of finding "content_id" used in generating page. in case user comments on page dont know "content_id" save in comments table along comment next time when article displayed relevant comments can displayed. some of solutions thought follows can use session store data? (however not using sessions users not logged in ... can use sessions users ) will using form on page hidden fields viable option... how wordpress or other cms handle problem? to achieve goal, table needs 4 columns: unique row number content post number...

Android AlarmManager fails to work -

according knowledge, should see log "alarm" in logcat after 20 seconds starting application, not happening. missing? public class mainactivity extends activity { private pendingintent pendingintent; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); intent intent = new intent(mainactivity.this, mainactivity.class); pendingintent = pendingintent.getservice(mainactivity.this, 1, intent, 1); alarmmanager manager = (alarmmanager) getsystemservice(context.alarm_service); manager.set(alarmmanager.rtc_wakeup, system.currenttimemillis() + 20000, pendingintent); log.d("alarm", "alarm"); } } seems should use getactivity (context context, int requestcode, intent intent, int flags) as intent specifies activity class, not service. next, last parameter (flags) can have values constants in pendingintent class. , mentioned, second paramter should 0 not used currently. please re...

compress binary data in sql server -

i storing images in database(sql server 2008) in binary formate . table's field datatype image. right i'm having rows above millions in table. want compress binary data. i have searched solutions on form levels means have write code in c# or vb.net , bring binary data on page. compressing them code have update particular record. but due have large number of data inconvenient process on form side because can take plenty of time. so want code sql can create stored procedure in database, using can each row @ time, directly compress binary data , update fetched column perticular row. is there method available process on sql server 2008 . thank in advance. if using sql server 2008 developer or enterprise edition, can enable compression described here on msdn .

datetime - How to convert different date formats into timestamp object in java? -

i have following code convert different string representations of date/datetime timestamp object: public class generalmethods { public static string[] formats = {"dd/mm/yyyy","mm/dd/yyyy hh:mm:ss","e mmm dd hh:mm:ss zzz yyyy"}; /** * method return timestamp object string date in formats * {"dd/mm/yyyy hh:mm:ss","e mmm dd hh:mm:ss zzz yyyy","dd/mm/yyyy"} * @param date: date format in string representation * @return timestamp object */ public static timestamp timestampformat(string date) { date dateobj = new date(); for(string format: formats) { try { dateobj = new simpledateformat(format).parse(date); system.out.println(dateobj.tostring()); // tracking }catch (parseexception e) { } } return new timestamp(dateobj.gettime()); } // testing public static void main (string args[]) { system.out.println(timestampformat("05/31/2011 21:37:35")); } } the output code is: wed jan 05 00:31:00 gmt 2011 mon jan 31 21:37:35 gmt 2...

java - Spring security null pointer exception -

i'm trying map users in database spring security users, without luck. userserviceimpl follows (the autowiring works fine when i'm calling through servlet, throws null pointer when used in spring security... @service("userservice") @transactional public class userserviceimpl implements userservice, userdetailsservice { protected static logger logger = logger.getlogger("service"); @autowired private userdao userdao; public userserviceimpl() { } @transactional public user getbyid(long id) { return userdao.getbyid(id); } @transactional public user getbyusername(string username) { return userdao.getbyusername(username); } @override public userdetails loaduserbyusername(string username) throws usernamenotfoundexception { userdetails user = null; try { system.out.println(username); user dbuser = getbyusername(username); user = new org.springframework.security.core.userdetails.user( dbuser.getusername(), dbuser.getpassword(), true, true, true, true, getauthorities...

html5 - Dropping not working on Chrome Mac version -

i tried work html5 drag&drop api, , works on chrome 20.0.1132 on windows machine, fun - same version of chrome on mac os lion not working. mean dragstart working, drop event, dragleave, dragover not fired. here html: <form id="fake_form" action="#" > <div id="canvas_wrapper" style="overflow: hidden;width: 600px; position: relative;border: 1px solid black; margin-left: 30px;"> <canvas width="600" height="300" > </canvas> </div> </form> here javascript: var canvas = $('canvas')[0]; canvas.addeventlistener('dragenter', function(e){ console.log('dragenter'); }, false); canvas.addeventlistener('dragleave', function(){ console.log('dragleave'); }, false) canvas.addeventlistener('dragover', function(e){ console.log('dragover'); if(e.preventdefault){ e.preventdefault(); } return false; }, false); canvas.ondrop = function(e){ console.lo...

Azure Preview Account Approval -

i signed preview on 24 hours ago , still awaiting account approval. common/expected? or, have missed step in process? how figure out which? what preview? media services? virtual machines? web sites? if of these, @ page. should point out these take time provision, demand these since announcing in june. should see request queued. having said that: isn't programming question.

Virtualizing Windows 7 on linux host for Windows Phone application development -

i asked delvelop windows phone application turns out windows phone sdk works under windows 7 os. @ work have shitty old laptop running windows xp not enough resources run virtual machine. solution problem install vmware workstation on asus 1215b netbook (ubuntu 12.04lts) windows phone emulator runs slowly. i curious if use different gnu/linux host debian/centos/gentoo , more lightweight user enviroment xfce there inprovemant in performance. i considered writing script ask user if wants logon host shell or start virtual machine before loading host system enviroment , services. just dual-boot windows 7 ubuntu on laptop.. nothing can beat performance on bare metal... , making things minimalistic naturally make performance better... not better.