Posts

Showing posts from January, 2012

javascript - Force Masonry/similar to ignore flow and fill gaps instead -

masonry/isotope/freetile , rest great job @ absolute positioning elements in grid/container. however, when element takes full width of grid/container, creates massive gaps not acceptable outcome. here jsfiddle problem: http://jsfiddle.net/qnf3a/1/ there's enough room on top of red div place green one. however, different libraries tend respect flow opposed "leave no gaps" philosophy. does know of alternative js library or similar trick avoid gaps? - code jsfiddle... html: <div id="container"> <div class="block half"></div> <div class="block full"></div> <div class="block half"></div> <div class="block half"></div> <div class="block half"></div> </div> css: #container{ width: 600px; background-color: #eee; } .block{ float: left; } .half{ width: 300px; height: 100px; background-co

python - How can I make folder in AWS S3 bucket with django-storages? -

i tried following: f = default_storage.open('test/', 'w') f.write('') f.close() but returned error: the xml provided not well-formed or did not validate against our published schema there no such thing folder in s3. if save file path 'fake' directory structure. https://stackoverflow.com/a/2141499/682968 add folder in amazon s3 bucket

c# - TeeChart RedCross Error Continued -

this post corresponds answer on previous post... before upload simple project you, let me try else: noticed when swap points series colorgrid series same thing happens, but, when (with colorgrid series) use "mycolorgrid.yvalues[gridposition] = val" instead of mycolorgrid.add(x, y, z) works. there way can use points series in same way, ie, allocate points first time, , use xvalues[idx] = x, , yvalues[idx] = y update points? problem seems happen when use add method, clear method. when update values xvalues , yvalues etc. problem seems solved! thing is, can not work on points series...it easy colorgrid series: (int r = 0; r < 128; r++) { (int d = 0; d < 128; d++) { mycolorgrid.yvalues[d * 128 + r] = some_value; } } mycolorgrid.beginupdate(); mycolorgrid.endupdate(); question 1: how achieve same points series? question 2:

c# - WCF Teseract error: Attempted to read or write protected memory... on exe works fine -

i use teseract v2 ocr image, it's work fine in exe, when try on wcf everythime exception: attempted read or write protected memory. indication other memory has been corrupted. the same code on exe (work) , wcf (exception): var processor = new tesseractprocessor(); processor.setvariable("tessedit_char_whitelist", metadata.textregexpattern); processor.init(@"../../tessdata/" + language + ".traineddata", language, 3); processor.setpagesegmode(_pagesegmentationmode); processor.analyselayout(source); return processor.recognize(image.fromfile(filepath)); // here's problem recognize method

c# - Repeat a listbox that opens files -

hello want listbox playlist repeat after last file played. how reset index repeats start of listbox? shownextimage handles media 1 one show on mediaelement. dispatchertimer shows images 20 seconds , continues. this got. dictionary<string, string> listbox1dict = new dictionary<string, string>(); public static list<string> images = new list<string> { ".jpg", ".jpe", ".bmp", ".gif", ".png" }; // bildtyper som stöds public static list<string> movies = new list<string> { ".wmv", ".wav", ".swf", ".mp4", ".mpg", ".avi" }; list<string> paths = new list<string>(); dispatchertimer dispatchertimer = new dispatchertimer(); dispatchertimer nextimagetimer = new dispatchertimer(); int x = 20; private int currentsongindex = -1; private void shownextimage() { if (currentsongindex == -1)

reflection - Java - How Can I Check If A Class Is Inheriting From Some Class Or Interface? -

i need check: public static boolean check(class<?> c, class<?> d) { if (/* c inherits d */) return true; else return false; } how can ? and possible without c.newinstance() ? title wrong @ first time. it's correct. use isassignablefrom if(d.isassignablefrom(c)){ // d superclass of c // in other words, c inherits d } determines if class or interface represented class object either same as, or superclass or superinterface of, class or interface represented specified class parameter. returns true if so; otherwise returns false. if class object represents primitive type, method returns true if specified class parameter class object; otherwise returns false. source

codeigniter - jQuery autocomplete retrieve with an image -

i need using autocomplete image inside result (similar how facebook's autocomplete works). however, want start basics... great example found here: http://jsfiddle.net/k5q5u/249/ <input id="auto" type="text" /> css: img { width: 25px; height: 25px; padding-right: 10px;} .ui-autocomplete > li { height: 40px; } javascript: $(document).ready(function () { $("#auto").autocomplete({ source: function (request, response) { $.ajax({ url: "http://api.stackoverflow.com/1.1/users", data: { filter: request.term, pagesize: 10 }, jsonp: "jsonp", datatype: "jsonp", success: function(data) { response($.map(data.users, function(el, index) { return { value: el.display_name,

c# - Client datetime vs Server datetime -

i have c# web application has been installed in server , database in server. accessing application india. when user sign up, choose reporting date calender control has current system date time selected default , user creation date inserted background c# code. since using application in local country browser, that's why both dates different. there anyway resolve conflicts. obuser.creationdate = datetime.now instead of datetime.now use: datetime.utcnow . utcnow acording msdn : gets datetime object set current date , time on computer, expressed coordinated universal time (utc).

Android: Error when pressing back button, even after finishing the previous activity -

i getting nullpointer exception somewhere near line using getintent.getextra(). this error log: 04-25 14:19:43.718: e/androidruntime(10031): fatal exception: main 04-25 14:19:43.718: e/androidruntime(10031): java.lang.runtimeexception: unable start activity componentinfo{com.example.attendence/com.example.attendence.userpage}: java.lang.nullpointerexception 04-25 14:19:43.718: e/androidruntime(10031): @ android.app.activitythread.performlaunchactivity(activitythread.java:1651) 04-25 14:19:43.718: e/androidruntime(10031): @ android.app.activitythread.handlelaunchactivity(activitythread.java:1667) 04-25 14:19:43.718: e/androidruntime(10031): @ android.app.activitythread.access$1500(activitythread.java:117) 04-25 14:19:43.718: e/androidruntime(10031): @ android.app.activitythread$h.handlemessage(activitythread.java:935) 04-25 14:19:43.718: e/androidruntime(10031): @ android.os.handler.dispatchmessage(handler.java:99) 04-25 14:19:43.718: e/androidruntime(1003

php - Using die() in functions under CodeIgniter -

i'm writing web application in codeigniter , i'm trying apply user activation. function is_active() { $active_state = $this->my_model->check_active(); if ($active_state == 'no') { $this->load->view('activation_page'); die(); } } above code produce blank page , if remove die(); if print out members_area alongside activation_page so how can force load requested view , exit? obviously not going inside if statement, meaning if user not active, load activation page. still don't have else, load view if user active. try: if ($active_state == 'no') { $this->load->view('activation_page'); } $this->load->view('members_area'); note: might want revert if condition. looks more logical check if user active, otherwise fallback activation page. edit: please refer code: http://paste.laravel.com/pfo note 2: 1 of many possible soluti

css - MVC 4 data validation message increases width of my form -

Image
i creating quite simple form model. have generated scaffolded "edit" view validation. 1 validation "url" type , causing me problems. i have in view: <div class="editor-label"> @html.labelfor(model => model.server) </div> <div class="editor-field"> @html.editorfor(model => model.server) @html.validationmessagefor(model => model.server) </div> this css #content section contains rendered view: #content { border:solid; border-width:thin; position:relative; margin-left: auto ; margin-right: auto ; text-align:center; margin-top: 50px; min-width:480px; max-width:800px; display:table; padding: 30px; } when page loaded, #content 480px wide , elements inside take space possible (editor-field elements , element submit buttons set 100%, nothing else has width set in css). when "required" validation message displayed on fields

jquery - DatePicker in MVC4 -

i using @html.jqueryui().datepickerfor helper method in mvc4 application. showing calender correctly @ first time not showing once form posted. can tell me missing in it? i suspect using ajax submit form , in case of successful submission refreshing contents , date picker no longer bound input field. inside success callback of ajax request need rebind it: success: function(data) { $('#some_id').html(data); $('#id_of_your_input_element').datepicker(); } or if using ajax.beginform subscribe success event in ajaxoptions: @using (ajax.beginform(new ajaxoptions { success = "success", updatetargetid = "someid" })) { ... } and write success callback: function success(data) { $('#id_of_your_input_element').datepicker(); }

c# 4.0 - Not found exception When start the ManagementEventWatcher -

not found exception times while starting maagementeventwatcher my code sample given below : try { string scopepath = @"\\.\root\default"; managementscope managementscope = new managementscope(scopepath); wqleventquery query = new wqleventquery( "select * registrykeychangeevent " + "hive = 'hkey_local_machine'" + @"and keypath = 'hardware\\devicemap\\serialcomm'"); registrywatcher = new managementeventwatcher(managementscope, query); registrywatcher.eventarrived += new eventarrivedeventhandler(serialcommregistryupdated); registrywatcher.start(); } catch (exception ex) { console.writeline(ex.message); if (registrywatcher != null) { registrywatcher.stop(); } } exception: not found @ syste

javascript - Show enter contents of JSON -

question :: i know redundant question, finding little in other similar questions... i have json file. i can load json fine, when try output specific element this div.innerhtml = jsonfromfile[element]; i this... [object object] as output... how entire element display instead of [object object]? more code feel how being done up... var activity; function jsfr() { $.getjson('myjson.json', function(response){ jsonfromfile = response; }) } . . . solution :: francis stalin's answer i added new function... var items; function outty(data) { $.each(data, function(key, val) { items=items+key+","+val+";"; }); } and set depth on json leaving me object send outty... dpth = jsonfromfile["elementone"]["elsubone"]["elsubonesub"]; outty(dpth); div.innerhtml=items; here's html shows div prints to... <div cla

vim - How to call a function that moves the cursor without leaving visual mode? -

i have function moves cursor built-in cursor() function , works fine on normal mode. concreteness suppose function: function! f() call cursor( line('.')+1, 1) endfunction used mappings as: nnoremap <buffer> :call f()<cr> now want reuse function move cursor on visual mode (visual, line visual, , block visual) , without losing previous selection. for example, initial buffer in visual mode ( c means cursor @ line, v means line part of current visual selection): vc 1 2 3 hitting a give: v 1 vc 2 3 and hitting a again give: v 1 v 2 vc 3 so old selection kept. i reuse f() as possible, since in application f() quite large. best way that? up now, best use wrapper function: function! vismove(f) normal! gv call function(a:f)() endfunction and map as: vnoremap <buffer> :call vismove('f')<cr> however not satisfied because this: it requires putting annoying wrapper on every new fgplug

sql server 2008 - Is it possible to Update the table values which contains multiple criteria using single update statement -

table id desc 1 male 2 male 3 male 4 female 5 female 6 female 7 female i need update male female , female male using 1 update statement.kindly advice on this. in advance. try update table set desc = case when desc= 'male' 'female' when desc = 'female' 'male' else desc end out put follow id desc 1 female 2 female 3 female 4 male 5 male 6 male 7 male

java - Generic Exception Handling -

i found below code exception handling handles execptions of thrown application including runtimes. public static void handleexception(string strmethodname, exception ex) throws customexception{ string strmessage = ""; try { throw ex; } catch (nullpointerexception npe){ logger.log(pr, strmethodname, npe.getmessage()); strmessage=err_02; throw new customexception(strmessage); } catch(indexoutofboundsexception iobe) { logger.logmethodexception(strmethodname,iobe.getmessage()); strmessage=err_03; throw new customexception(strmessage); } ... on } below of disadvantages think: to idenitify root cause of exception need check message string. no sepearation of type of exceptions advantage: less code. (code can minimized) can pl

java - LineNumberReader Skips the First Line of the file -

i reading first 6 lines of text file code: file finish = new file("c:/abc statements final/"); file[] finf = finish.listfiles(); string[] filenames1 = finish.list(); linenumberreader br = null; printwriter bw = null; (int k = 0; k < filenames1.length; k++) { try { br = new linenumberreader(new filereader(new file("c:/abc statements final/" + filenames1[k]))); string line = br.readline(); while (line != null && br.getlinenumber() <= 6 ) { line = br.readline(); system.err.println(line); } } catch (exception asd) { system.err.println(asd); } my output not print first line of file. knows doing wrong? that's because you're eating first line read . string line = br.readline(); // first line read here. while (line != null && br.getlinen

java - Use hibernate query with entity field -

i have simple entity : @entity public class university implements serializable { /** constant serialversionuid. */ private static final long serialversionuid = 1l; @id @generatedvalue(strategy = generationtype.auto) private int id; @column string name; @column string address; @column student student; } and entity student : @entity public class student implements serializable { /** constant serialversionuid. */ private static final long serialversionuid = 1l; @id @generatedvalue(strategy = generationtype.auto) private int id; @column string firstname; @column string lastname; @column studentstatus status; } can create @joinformula or create query , take students student entity university entity ? i tried that: @joinformula("select l student l l.id = 1

php - Send canvas with form, create PNG and name it -

i intending send canvas image along form information server. save png named information form. at moment png written can't opened , 0 kb jumbled file. the full site here html - form write info , activate javascript when submitted <form action="phptestupload.php" method="post"> name <input type="text" name="name" value="" style="width:230px; margin-left: -160px; font-size:1em; "/> email <input type="email" name="email" value="" style="width:230px; margin-top: 12px; margin-left: -160px; font-size:1em; "/> <input type="submit" onclick="postimageplusform();" value="submit" style=" opacity:1; -webkit-appearance: none; width:100px; height:50px; margin-left: -50px;"> </form> js // sends image server // serialize canvas var dataurl=document.getelementbyid('colors_sketch').

c++ - error while declaring double array of size 150000? -

this question has answer here: segmentation fault on large array sizes 5 answers i developing code in there need declaring array of double of size 150000 , when 1 array declared code running successfully.if declare 2 arrays while execution terminates throwing exception. code : double a[150000]; double b[150000]; if declare executes perfectly.if declare both , b terminates. can suggest how resolve this? the 2 arrays overflowing stack (assuming local variables). dynamically allocate memory arrays instead, using std::vector manage memory you: std::vector<double> a(150000); std::vector<double> b(150000); even though std::vector instances on stack, std::vector dynamically allocates memory internally data on heap, avoiding stack overflow.

java - Android app navigation | custom navigation -

i think bit difficult. created coordinate system, build game upon it. since able move left , right swiping. possible allow swipe up/down? think annoying swipe time, had idea add system google maps using (move around tap , hold). there listener or similar include this, or know how create that. i've searched around web find something... without success. thanks help. i've got awnser myself, use ontouchlistener , catch motionevent.action_down , .action_move example able current touch position , calculate difference between , start position , animate map values.

iphone - Simulate cursor and click -

i want simulate mouse pointer , click event on object in view. until able simulate mouse pointer i.e. mouse pointer moves dragging on view. want fire tap event on underlying object on simulated mouse pointer clicked. suppose button. concept finger mouse. i got you, 1) add uitapgesturerecognizer mouse pointer. 2) in tapgesture handle method, get finger point, cgpoint fingerlocation = [tap locationinview:self.view]; make fingerrect this, cgrect finderrect = cgrectmake(location.x - 5, location.y - 5, 10, 10); iterate through uiviews in self.view (uiview *view in self.view.subviews) { cgrect frameoftheview = view.frame; if(cgrectintersectsrect(frameoftheview, finderrect)){ nslog(@"clicked on view %@", view); return; } } finally method this, -(void) handletap:(uitapgesturerecognizer *) tap{ //get tapped point cgpoint location = [tap locationinview:self.view]; cgrect finderrect = cgrectmake(location.x -

Reports from SQL Server using Excel -

i've developed intranet system our company uses sql server 2008 backend. stores awful lot of information , i'm asked build reports various managers business. quite these reports variations on theme, whilst they're quite unique. @ moment write sql perform report , have them dump required output via asp.net pages. i'd away that, , thinking along lines of having managers query database using excel can decide fields filter on etc. end wrote couple of views , used excel connect them. problem without filtering end lot of data, wondering best way approach this. i've not had data warehousing/analysis services wondered if route at, or should looking @ reporting services? i've got access full microsoft stack happy use different solutions i'm more happy spend time doing reading/research i'm bit unsure begin pointers gratefully received. thanks in advance

Working with Hadoop with two datasets -

i'm working hadoop , try make interection function 2 datasets what's best scenario. can load 1 memory , intersect in map function other dataset if dataset large ram memory not solution, thoughts? thanks answers, i'll try out these see what's best solution. it's tough maneuver intersection in mapred compared other family of platforms around hadoop api. mentioned hive (super easy intersections if have sql background), may consider: pig cascading (specifically cogroup if memory concern , hashjoin if isn't)

android - How to Set animation in manifetst file to an activity -

i able set animation using overridependingtransition() method activities through code. need set animation activity in manifest file. tried using themes, it's not working. can 1 me. in advance. manifest file not designed save animation. animation should done in xml file stored drawable rep. , call

dojo - javascript contents are not getting loaded,if i create a tab/contentPane dymaically with .xhtml as input -

i creating dynamic tab/contentpane below in home.xhtml file , trying call function display present in order.xhtml,its not getting called. ever java script there in order.xhtml not getting loaded. in home.xhtml if(dijit.byid('ordersummary')!=null){ dijit.byid('ordersummary').destroy(); } newtab= new dijit.layout.contentpane({ id : 'ordersummary', title : 'order summary', href : 'order.xhtml', closable : true }); dijit.byid('tabcontainer').addchild(newtab); dijit.byid('tabcontainer').selectchild(dijit.byid("ordersummary")); javascript in order.xhtml <script type="text/javascript"> //<![cdata[ function display(){ alert(" m being called"); } </script> there 2 ways this, either make script type dojo/method. or use extended dojox/layout/contentpane. http://livedocs.dojot

c# - Image saving into database from a folder and get back into the UI -

i have field in app (c#) save image database. written following code save image folder , save path database. image not getting saved folder. string imgname = fileupload1.filename.tostring(); string imgpath = null; if (imgname == "") { //int taxiid = convert.toint32(hiddenfield1.value); taxi t = null; t = taxi.owner_getbyid(tx.taxi_id, usm.orgid); imgpath = t.carimage; } else { imgpath = "imagestorage/" + imgname; } fileupload1.saveas(server.mappath(imgpath)); tx.carimage = imgpath; i think problem add name path try , me works fine if save this: fileupload1.saveas(server.mappath("imagestorage") + imgname); and @rahul mentioned add try catch prevent errors. and check if (imgname == "") according understanding it's not posible imgname "" anyway better add check if fileuploa

codeigniter - Undefined property: my_controller::$db -

severity: notice message: undefined property: my_controller::$db filename: libraries/session.php line number: 88 use $this->load->database(); before database operation. or open application/config/autoload.php , search $autoload['libraries'] = array(); replace to $autoload['libraries'] = array('database','session');

c# - ASP button to open new window to SSRS report with parameter -

i'm building page simple asp.net form c# codebehind. need button (or kind of control) open link new window, , have found code using javascript, , have found code can use make button open ssrs report parameter passed aspx page dynamically. have not found handle both. my asp form starts simple text box looking npi (type of id). npi used searching database , populating form. want have button on page grab npi entered user , pass new window opening ssrs report. i've researched , know can use javascript open new window, great, don't know how include user input npi js version. know can't use codebehind open new window, can use response.redirect send npi url ssrs report. can't find combination of two. thank in advance. first time posting on stackoverflow, though use daily answers. apologize screw-ups i'm making. the textbox: <asp:textbox id="npi" runat="server" width="144px"></asp:textbox> the button opens ssrs

javascript - Why is it common practice in JS libraries to duplicate variable name and adding 'or object' -

i trying better grip on js syntax , wondering why common practice in many libraries repeat object name after variable same name has been declared. please see below: var backbone = backbone || {}; // <= why duplication? or var listeners = this._listeners || (this._listeners = {}); update: after further research have found written article evaluates many idiomatic expressions. the article explains use behind invoked function expressions (iife), i.e wrapping of function within function, such: (function() { console.log('hello!'); })(); which 1 of js brainteasers newbies me can't quite understand. var backbone = backbone || {}; means if backbone undefined or null or false , set {} longer explanation: the assignment operator evaluates right left , logical operators (even though javascript doesn't have real logical operators work on non-boolean operands well) evaluate left right . an expression a || b returns b if a und

java - Timeout for a method -

my program looks below main program (thread 1) create multiple simple java threads (thead 1.1, 1.2...) in each thread(1.1 or 1.2..) i'm doing processing calling 1 method not responding(corba calls). want define timer method , thread(1.1 or 1.2 whoever calling) should wait there till response or timer expired. i have written following sample program. don't think right approach. there better approach? in prg i'm not sure when interupt method invoked. public class methodtimeout implements runnable{ /** * @param args */ public thread t1 = null; public int threadnum = 0; public static void main(string[] args) { (int i=0; i<3; i++){ methodtimeout mt =new methodtimeout(); thread t = new thread(mt,"thread "+(i+1)); mt.t1 = t; mt.threadnum = (i+1); t.start(); } system.out.println("stmt after execution"); } public object testtimeout(){ long starttime = system.currenttimemillis();

c++ - Why SO_RCVTIMEO is inherited from listening socket to accepted socket? -

i couldn't find documentation on except python documentation 18.1.4.2. timeouts , accept method if getdefaulttimeout() not none , sockets returned accept() method inherit timeout. otherwise, behaviour depends on settings of listening socket: if listening socket in blocking mode or in timeout mode, socket returned accept() in blocking mode; if listening socket in non-blocking mode, whether socket returned accept() in blocking or non-blocking mode operating system-dependent. if want ensure cross-platform behaviour, recommended manually override setting. i have read [question]: are socket options inherited across accept() listening socket? , think in end verdict still implementation defined. guess testing on platform easier reading sources each kernel. here says timeout option inherited. on manpage of accept(2), there's no mention of this. found quite shocking when debugged c++ code on 1 of box ( embedded linux box). expected accepted socket no

jquery - What is wrong in this javascript dropdown select function? -

i calling reusable function sets selected value dropdown. missing here?? function setdropdownvalue(dropdownid,selectedvalue){ $(dropdownid 'option').each(function(){ if ($(this).val().tolowercase()==selectedvalue.tolowercase()){ //found option looking for, want $(this).val(selectedvalue); } }); } and calling like, function setselectedsport(selsport,tempcount){ setdropdownvalue($("#sportid2"),selsport); } i getting undefined error in $(dropdownid 'option').each(function(){ .. missing here?? edit: after changing $('#'+dropdownid+' option').each(function(){ ecah() function doesnt seem executed. looks you're missing concatenation operator , hash tag id. try: $('#'+dropdownid+' option')

SQL Relationship Cardinality in Logical Design -

i have following issue. working on system shuttle service company. now, part of entities in database system include numerous lookup tables (such vehicle_type, employee_status, etc), other tables, such vehicle , vehicle_service log. now issue team having cannot agree on logical relationship cardinalities between entities should be. 2 main problem relationships include tables defined follows: create table if not exists `user_type` ( `type_id` tinyint(4) not null auto_increment, `description` varchar(200) not null, primary key (`type_id`) ) engine=innodb default charset=latin1 comment='store user types - employee or consultant' auto_increment=1 ; which linked create table if not exists `user` ( `user_id` int(11) not null auto_increment, `username` varchar(100) not null, `password` varchar(100) not null, `user_type` tinyint(4) not null, primary key (`user_id`), key `user_type` (`user_type`), key `username` (`username`), key `login` (`username`,`p

javascript - Switching from GridView to ListView when Windows Store app is snapped -

i trying change layout of listview control "gridview" "listview" when application gets snapped. of course, should return "gridview" in other state. wrote code, doesn't work, wonder why... this code i've written: var viewstate = windows.ui.viewmanagement.applicationview; var list = document.getelementbyid("messagedisplay").wincontrol; if (viewstate == windows.ui.viewmanagement.applicationviewstate.snapped) { list.layout = new winjs.ui.listlayout(); } else { list.layout = new winjs.ui.gridlayout(); } as taken here listen resize event , make changes listview's layout property. i can't tell wher ein code calling similar code, here entire method you'll need window.addeventlistener("resize", function (e) { var currentviewstate = windows.ui.viewmanagement.applicationview.value; var snapped = windows.ui.viewmanagement.applicationviewstate.snapped; if (currentviewstate === snapped)

cordova - phonegap access origin for images only in listview -

i'm wondering if it's possible use specific access origin. example, in database have url pictures displayed in listview. in text content have link url of original article. if use access origin="*", link in text content opens in webview , crashes ajax page loading. if allow access server, image doesn't displayed in listview. my question whether can whitelist specific url. example, image links www.example.com/res/images/ , original page url www.example.com/news/. possible add example.com/res/images access images load original article opens in browser? i've tried many different combinations , haven't been able desired output. here's answer problem...and don't have use workarounds inappbrowser or childbrowser android. i learned in config.xml access origin="...", have specify website urls. if website doesn't use www uses http://example.com , have put exact url in origin...and can add http://example.com/res/images/ allow

php - How do I update the value from a checkbox into MySQL -

my form form method="post"> input type="checkbox" name="facebook" value="yes"> submit so, want is: a) if checkbox checked, want update appropriate field yes b) if checkbox unchecked, want update field no $_post['chk_ans'] return when being checked, if (isset($_post['chk_ans'])) { ..update query here .. }

android - AsyncTask called a lot from many places -

i'm using simple asynctask download sourcecode of web page string. far works fine. however, don't want same thing result string, want fill gui it, want parse it, want call more functions parameter. actually, have more 1 activity , more 1 class need download sourcecode of page. of course, onpostexecute() has handle result of task, since called many places , many different reasons i'm @ loss. what can do? i don't want write 20 asynctasks same thing in doinbackground(...) different onpostexecute, nor want code 20 different classes/activity end in single onpostexecute, code complicated maintain. any suggestion? thanks i resolve use of interfaces. make async task right stuff in doinbackground , takes parameter know in onpostexecute , pass parameter , result down onpostexecute. then make interface method handlesourcecodestring(string source); , implement 1 class every action want do. put classes in map in init function. map<string, class> mya

python - Avoid retrieving object to delete in many to many rel SQLAlchemy -

is there way avoid retrieving object delete in many-to-many relationship? assign = table('manytomany', base.metadata, column('pid', string(...), foreignkey('parent.pid')), column('cid', string(...), foreignkey('child.cid')) ) class parent(): .... childs = relationship("child", secondary = assign, backref = 'parent') i know can this: obj = session.query(table).get(pk_id) session.delete(obj) but have 1 database access, like: session.query(table).filter_by(id = pk_id).delete() i got error because of many-to-many rel: 'cannot delete or update parent row: foreign key constraint fails...' is possible? thx lot using session.query() retrieve object's data database first. avoid have use table object associated orm object directly. session.execute(parent.__table__.delete().where(parent.id==pk_id)) this issue single delete sql statement database removing parent record. ( pa

ios - UITableView never calls tableView:shouldShowMenuForRowAtIndexPath: on its delegate -

i'm creating , displaying instance of uitableview . delegate (which subclass of uitableview ) never receives of following selectors: tableview:shouldshowmenuforrowatindexpath: tableview:canperformaction:forrowatindexpath:withsender: tableview:performaction:forrowatindexpath:withsender: even though documentation states, example, under discussion of tableview:shouldshowmenuforrowatindexpath: if user tap-holds row in table view, method (if implemented) invoked first. return no if editing menu shouldn’t shown—for example, cell corresponding row contains content shouldn’t copied or pasted over. other tutorials document shortcut displaying uimenucontroller in table views. why isn't working documented? although isn't documented (i'm submitting documentation update, knows when/if posted), uitableviewdelegate methods: tableview:shouldshowmenuforrowatindexpath: tableview:canperformaction:forrowatindexpath:withsender: tableview:performact

php - How can i sort this list by "date modified"? -

i have been trying mp3 player order songs " date modified" can't seem work properly. there way can output results " date modified"? can me out this? /* reads mp3's local directory, returns array of uri's */ function grab_local_folder_mp3s( $folder ) { $items = array_multisort( array_map( 'filemtime', $items ), sort_numeric, sort_desc, $items ); if ( ($lp = strpos($folder, $this->rooturl)) || preg_match("!^/!", $folder) ) { if ( $lp !== false ) { $fp = str_replace($this->rooturl, "", $folder); $fp = str_replace("www.", "", $fp); $fp = str_replace("http://", "", $fp); $fp = str_replace("https://", "", $fp); } else { $fp = $folder; } $path = $_server['document_root'

javascript - window.location issue with <base> meta tag in IE10 -

i have used window.location.href in js scripts, go page of website, since ever. now, ie10 not working correctly. , ok in previous ie versions. the specific thing use <base href="someurl" target="_blank"> in <head> of our websites. this used work on browsers use, in ie older versions, notice ie10 doesn't support this. instead, ie10 adds uri url of current page in browser. is there other solution here adding full address of page in window.location.href ? thanks

oracle - dynamic pl/sql syntax package proc -

syntax trouble simple dyanamic pl/sql insert statement. code follows. sql_stmt varchar2(500); sql_stmt := 'pkg_collection.collection_ins_01(:1,:2,:3,:4,:5,:6)'; execute immediate sql_stmt using in out v_p1, in out v_p2, in out v_p3, in out v_p4, in out v_p5, in out v_p6; (error: ora-00900: invalid sql statement) what should actual syntax like? you need change part make pl/sql instead of sql: sql_stmt := 'begin pkg_collection.collection_ins_01(:1,:2,:3,:4,:5,:6); end;';

tomcat - Which is the best way to emulate a balancer locally? -

enviroment: so: windows app server: 2 x tomcat 7.0.32 (both run locally) my application deployed on 2 tomcats, each 1 configured unique port (8081 , 8082). i need way configure new port (8080) , load balance between 2 tomcats automatically. currently using functionality tcp/ip monitor provides eclipse , allows me manually routing. i need configuration reproduce error occurs in prod cluster. i'm considering using tomcat balancer, i'm not sure best option. has better idea? thanks! nginx upstream should best option you. here . configuration straightforward , can use either round-robin or ip_hash (useful sticky sessions), whichever scenario suits best.

javascript - can't include js file in pyramid project -

Image
i'm trying use external js file use in pyramid project. found solution can't seem work. js files want include in c:\env\uza\uza\static\js project name = uza. in template use call script: <script type="text/js" src="${request.static_url('uza:static/js/fabtabulous.js')}" /> <script type="text/js" src="${request.static_url('uza:static/js/tablekit.js')}" /> my init.py looks this: config.add_static_view('static', 'static', cache_max_age=3600) when navigate page in browser gives me pyramid sidebar in raw html code. know it's stupid mistake made somewhere can't seem find it. annyone able me this. edit: uploaded pdf give better understanding of problem i'm having. ps: there no errors in console. https://dl.dropboxusercontent.com/u/6752022/problem.pdf edit: made new project using sqlalchemy scaffold. changes made are: - include line in mytemplate.pt <script type=&q

How do I define an int64 in OCaml? -

let = 32 give me int32 . what if want define int64 ? let = 32l (postfix l int64 literals introduced in objective caml 3.07) and use module int64: http://caml.inria.fr/pub/docs/manual-ocaml/libref/int64.html should use google well...

html - IE9 Bug ? Mysteriously growing DIV -

i have following little sample: <!doctype html> <html> <head> <meta charset="utf-8" /> <title>test</title> <style type="text/css"> table.sample { width: 600px; table-layout: fixed; } table.sample col { width: 60px; } table.sample td { height: 20px; line-height: 20px; padding: 0px; } table.sample input { width: 55px; height: 17px; padding: 0px; margin: 0px; border-width: 1px; } </style> </head> <body> <div id="scrolldiv" style="width: 400px; overflow: auto; background-color: #cccccc;"> <table class="sample"> <colgroup><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /></colgroup> <tr><td>0</td><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td>&

Grails Security-UI Missing Menu -

i have installed spring-security-core , spring-security-ui , , spring-security-acl plugins , of functionality seems work, except when view user controller, base menu drop downs blank. when hover mouse on blank menu items, dropdowns populated correctly, need able see base menu items. these plugins have installed: runtime ":hibernate:$grailsversion" runtime ":jquery:1.8.3" runtime ":resources:1.1.6" build ":tomcat:$grailsversion" runtime ":database-migration:1.1" compile ':cache:1.0.0' compile ':mail:1.0.1' compile ":spring-security-ui:0.2" compile ":famfamfam:1.0.1" compile ":jquery-ui:1.8.24" compile ':spring-security-core:1.2.7.3' compile ":spring-security-acl:1.1.1" i have looked @ user guide , re-installed of dependencies needed plugin (jquery, jquery-ui, , famfamfam). have tried refreshed dependencies. while resea

objective c - Preprocessor target checking -

i want use preprocessor commands test target i'm compiling for. every example read told : add preprocessor macro in target. do : #ifdef target_name_macro nslog(@"target_name"); #else nslog(@"another_target"); #endif however, isn't working. condition passes whenever in target_name's file never passes when doing in target's file. need test in target's file if i'm running in test mode. i've tried few things, none worked out. any ideas?

php - Zend throw 404 headers in development mode -

so i'm working on application , ajax calls controller, , in case of no data throws 404. throw new zend_controller_action_exception('this page not exist', 404); the problem have $this->frontcontroller->throwexceptions(true); in development mode throws error, doesn't set 404 header, , need header because in ajax call based on header know what's next. is there way throw 404 header in dev mode throwexceptions set true ? you should use errorhandler plugin , register errorcontroller indicate 404 page, described here: http://framework.zend.com/manual/1.12/en/zend.controller.plugins.html#zend.controller.plugins.standard.errorhandler

MongoDB PHP OOP - Error Property of non-object -

this question has answer here: call member function on non-object [duplicate] 8 answers i trying use oop php access mongodb collection. yet on page returns nothing, when in apache error log states php notice: trying property of non-object in main.php on line 22 here code i'm using: db.php class db { static $db = null; static function getmongocon() { if (self::$db === null) { try { $m = new mongo('mongodb://{user}:{password}@{host}:{port}/{database}'); } catch (mongoconnectionexception $e) { die('failed connect mongodb '.$e->getmessage()); } self::$db = $m; } else { return self::$db; } } } main.php //load db files require_once('db.php'); class test{ public

Git rebase change author? -

this question has answer here: change author , committer name , e-mail of multiple commits in git 28 answers so stupidly made 3 commits on machine not configured git (no author or email) , want change 3 commits (have not been pushed) authors suppose be. i know git commit --amend can change author, how can 3? know rebase can change message. there way change author? you can use interactive rebase. answer post gives example: change commit author @ 1 specific commit . the author asks changing author @ specific commit, interactive rebasing can used change authors of multiple commits if edit commits wish change. other potential useful techniques related interactive rebasing found in pro git book http://git-scm.com/book/en/git-tools-rewriting-history , including squashing, redordering, editing messages, etc.

iphone - How can I detect next page number of UIScrollView which is 'scrollView.pagingEnabled' = YES? in 'scrollViewDidEndDragging'? -

i searched several stuffs on stackoverflow cgfloat pagewidth = scrollview.frame.size.width; int pagenumbertobescrolled = floor((scrollview.contentoffset.x - pagewidth / 2) / pagewidth) + 1; if (pagenumbertobescrolled != 1) { // want } in - (void)scrollviewdidenddragging:(uiscrollview *)scrollview willdecelerate:(bool)decelerate; but works if scrolled scrolling page moved on half of it. doesn't work if scrolled fast swipe. scrolled 30% of scrolling page, doesn't satisfy situation on there, scrolled next page, , want detect it. how can detect or catch scroll-to-next-page situations? please give me :) edit i working on because want play effect sound when scroll-to-next-page happens. should detect right after finger off screen , next page scrolling. think if handle on scrollviewdidenddragging , it'll best me :) i'm using code detect if currentpage changed, doesn't matter scroll fast or slow. - (void)scrollviewdidscroll:(uiscrollview *)s

javascript - How can I use jQuery to create a left and right sliding effect? -

i have following jquery code snippet: var target1 = $('.div1'); var target2 = $('.div2'); target1.delay(1500).fadein(); target2.delay(3000).fadein(); // want use slide left here instead of .fadein() similar .fadein() there slide left/right option? i found this i'm not sure how implement or if it's right one. use code link posted. include needed libraries (or use local copies): <script src="http://code.jquery.com/jquery-latest.js"></script> <script src="http://jquery-ui.googlecode.com/svn/tags/latest/ui/jquery.effects.core.js"></script> <script src="http://jquery-ui.googlecode.com/svn/tags/latest/ui/jquery.effects.slide.js"></script> add javascript page: jquery.fn.extend({ sliderightshow: function(speed) { return this.each(function() { $(this).show('slide', {direction: 'right'}, +speed || 1000); }); }, slidelefthide: function(speed)

python - How to find which numpy array contains the maximum value on an element by element basis? -

given list of numpy arrays, each same dimensions, how can find array contains maximum value on element-by-element basis? e.g. import numpy np def find_index_where_max_occurs(my_list): # d = ... goes here ... return d a=np.array([1,1,3,1]) b=np.array([3,1,1,1]) c=np.array([1,3,1,1]) my_list=[a,b,c] array_of_indices_where_max_occurs = find_index_where_max_occurs(my_list) # want: # >>> print array_of_indices_where_max_occurs # array([1,2,0,0]) # i.e. first element, maximum value occurs in array b @ index 1 in my_list. any appreciated... thanks! another option if want array: >>> np.array((a, b, c)).argmax(axis=0) array([1, 2, 0, 0]) so: def f(my_list): return np.array(my_list).argmax(axis=0) this works multidimensional arrays, too.

c# - How to put textblock inside scrollviewer by coding behide ? (wpf) -

i have xaml code <grid> <... grid row , column definitions .../> <scrollviewer grid.column="1" verticalscrollbarvisibility="auto"> <textblock "some attribute" /> </scrollviewer> </grid> i don't know how tie textblock scrollviewer in c# . want use textblock scrollviewer . if have idea, please tell me. many help. :d just use content property var myscrollviewer = new scrollviewer(); myscrollviewer.content= new textblock(); edit or in combination xaml xaml <scrollviewer name="myscrollviewer " grid.column="1" verticalscrollbarvisibility="auto"/> code behind myscrollviewer.content= new textblock(); // or ever want add :-)