Posts

Showing posts from August, 2014

android - List View With Sliding Menu Fragemnt -

update: just know, when try importing project end more errors can count why i'm here trying figure out. sliding working fine, adding listmenu throwing me off. thank being patient me. i didn't change main here anyways: package com.projectcaruso.nfp; import android.os.bundle; import android.app.activity; import android.view.menu; public class mainactivity extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.main, menu); return true; } } i tired import code mine menufragment.java package com.projectcaruso.nfp; import android.content.context; import android.os.bundle; import android.support.v4.app.listfragment; import android.view.layoutinflater; import a

.net - How to test deserialization in ASP.NET Web API -

what's right way write unit test deserializing json object in web api? in application noticed looking @ trace information web api trying deserialize object parameter comes request body calling jsonmeadiatypeformatter.readfromasync. i'm trying isolate problem wrote these test. readtestitem fails. other example readint passes, seems i'm on right track i'm not sure if web api doing. edit: code fixed , formatterconfig added class testclass { public string type { get; set; } public string value { get; set; } } [testclass] public class formattertest { [testmethod] public void readtestitem() { mediatypeformattercollection formatters = new mediatypeformattercollection(); formatterconfig.registerglobalformatters(formatters); jsonmediatypeformatter formatter = formatters[0] jsonmediatypeformatter; stream s = generatestreamfromstring("{ type: \"equal\", value: \"1\" }"); var co

c# - DateTime.Parse always throws exception in a specific culture -

i have old log files have parse - apparently date time saved like: 18/12/2012 11:09:39 p.m. - attempts parse these have failed. lost on - or direction great! cultureinfo cultureinfo = new cultureinfo( "es-mx" , true ); string date = "18/12/2012 11:09:39 p.m."; datetime dt = new datetime( 2012 , 12 , 18 , 11 , 9 , 39 ).addhours( 12 ); this.richtextbox1.text += date + environment.newline; this.richtextbox1.text += dt.tostring( cultureinfo ) + environment.newline; this.richtextbox1.text += dt.tostring() + environment.newline; foreach ( var item in richtextbox1.lines ) { try { datetime d= datetime.parse( item ); this.richtextbox1.text += d.tostring() + environment.newline ; } catch ( exception ee) { this.richtextbox1.text += ee.message + environment.newline ; } } some d

java - Update tab title in accordion -

i have primefaces 3.5 accordionpanel one: <p:accordionpanel cache="false"> <p:ajax event="tabchange" listener="#{pprbean.onchangetab}" /> <p:tab title="item"> <h:outputtext value="#{pprbean.counter}"/> </p:tab> <p:tab title="item"> <h:outputtext value="#{pprbean.counter}"/> </p:tab> <p:tab title="item"> <h:outputtext value="#{pprbean.counter}"/> </p:tab> <p:tab title="item"> <h:outputtext value="#{pprbean.counter}"/> </p:tab> </p:accordionpanel> and backing bean one: package com.gecolsa.test.view; import javax.ejb.stateless; import javax.faces.bean.managedbean; import javax.faces.bean.requestscoped; import org.primefaces.component.tabview.tab; import org.primefaces.event.tabchangeevent; @stateless @managedbean

PHP FFmpeg conversion issues for mp4 files -

i want images out of mp4 file using ffmpeg-php . i have $str_command= '/usr/bin/ffmpeg -i /test/ts.mp4 -r 1 -ss 00:00:10 -t 00:00:01 -s 300x300 -f image2 /test/images/'; shell_exec($str_command); however, got error message saying buffering several frames not supported. please consume available frames before adding new one. i have spent hours on web couldn't find answer this. can me this? much! have checked out ffmpeg library php? i've worked before , abstracts away of complicated command line calls 1 you're trying run. can use $movie->getframe($n) frame object, , $frame->togdimage() output image. for example, $movie = new ffmpeg('/path/to/movie.mp4'); $frame10 = $movie->getframe(10); $image = $frame10->togdimage(); // display image header('content-type: image/jpeg'); imagejpeg($image); // or save file $saved = imagejpeg($image, '/path/to/new/file.jpg'); check out documentation @ http://ffmpeg-php

html parsing - Android, Proper HTMLCleaner Usage -

Image
i know should try our own stuff here, , not place make requests hate having read stuff html, don't understand it's ways. so, awarding bounty of 150 points (not i'm cheap, can't more :( ) if can help, or @ least being pointed in right direction sample code. what trying accomplish? i trying latest news following nasa page . i plan displays news on listview, of course, listview has little content displayed begin with, data available through page above, here's quick mock-up . that's it, when user clicks link, taken different fragment shows full article , , i'll figure out how later, once can done. so, tried using htmlcleaner following bit: private class cleanurltask extends asynctask<void, void, void> { @override protected void doinbackground(void... params) { try { //try cleaning nasa page. mnode = mcleaner.clean(murl); } catch (exception e) { constants.logmessage("erro

email - IMAP, PHP returns no messeges -

i have connection server username , password. connects resource id of 2. displays status correctly, listing amount of unread emails in inbox, recent mail etc. when comes imap_num_msg() function, pass in correct argument returns 0. doing wrong return 0? <?php $mbox = imap_open("{imap.gmail.com:993/imap/ssl}inbox", "xxxxx", "xxxxxx", op_halfopen) or die("can't connect: " . imap_last_error()); $list = imap_list($mbox, "{imap.gmail.com:993/imap/ssl}inbox", "*"); if (is_array($list)) { foreach ($list $val) { echo imap_utf7_decode($val) . "\n"; } } else { echo "imap_list failed: " . imap_last_error() . "\n"; } $status = imap_status($mbox, "{imap.gmail.com:993/imap/ssl}inbox", sa_all); if ($status) { echo "messages: " . $status->messages . "<br />\n"; echo "recent: " . $status->recent . &

calling Java EE web service from Android Application -

i have never work web services , have establish web service between java ee server application , android client application. my question is: best way consume java ee web service android application? i suggest implementing rest based web service in java ee server. can use jsonobject consume restful service. an example using jsonobject rest can found in post: android rest client or video google: http://www.google.com/events/io/2010/sessions/developing-restful-android-apps.html

Extending Bounds For Polygons -- Google Maps V3 Javascript API -

my goal detect if marker within oddly shaped polygon object (think 25 different points). have noticed latlngbounds property, contains 2 sets of latlngs, after using .extend function, example: ((34.347971491244955, -122.40966796875), (34.829586636768205, -120.9649658203125)) is normal behavior? the code below tiny snippet of program building, contains relevant information how using extend function. have idea how detect if marker within oddly shaped polygon, if can't use combination of .extend() , .contains()? var coordinates = (polygon.getpath().getarray()); //get var bounds = new google.maps.latlngbounds(); function extendbounds(bounds, coordinates) { (b in coordinates) { bounds.extend(coordinates[b]); }; console.log(bounds.tostring()); }; the bounds of polygon rectangle. if want detect if marker in polygon use containslocation function in google.maps.geometry.poly namespace , passing polygon , position of ma

c# - Draw Circle Inside a Polygon -

Image
i need algorithm that, given array of points representing polygon (which rectangle-ish shape, nonregular polygon), , given point click location within polygon, fit circle touching 3 sides of polygon closest clicked location, maximizing overall coverage of circle without leaving boundary it's easy touching 2 sides (find centroid, find shortest distance edge, etc) - touching 3 sides challenge. see attached hand drawing. i need answer soon..thanks! problem related medial axis . points centers of circles touching 3 or more sides branching points of medial axis. enough make medial axis, find branching points , given click position find closest one.

java - Window Size is smaller than it should be -

Image
alright i've got jframe screen on it. i've set size 800 800. window created smaller that. it's not problem taskbar because it's not fullsize. package sharph; import java.awt.dimension; import javax.swing.jframe; public class main extends jframe { public static string title = "game 1"; public static dimension screensize = new dimension(800,800); public static void main(string[] args) { jframe frame = new jframe(); frame.settitle(title); frame.setsize(screensize); frame.setlocationrelativeto(null); frame.setresizable(true); frame.setdefaultcloseoperation(exit_on_close); screen screen = new screen(); screen.setsize(screensize); frame.add(screen); frame.setvisible(true); } } in screen class paint method draws box around border should be: //draw border g.setcolor(color.red); g.drawrect(1, 1, 799, 799); when run it, window smaller box , bottom

oauth - How do I configure omniauth use memcached as a backing store with google in classic sinatra app? -

i attempting debug issue doing oauth google when there multiple app servers behind ec2 elb failing. believe issue related fact oauth backing store not being shared. solution had in place worked fine 2+ years, started fail 2 days ago , don't know if configuration issue on end or google changed something. i believe fix things must use shared store such memcached. here attempt in classic style sinatra app: sinatra::application.use ::omniauth::strategies::openid openid::store::memcache.new(memcached.new('my_memcached_machine')) end unfortunately still has not resolved issue. far can tell, omniauth never doing or set requests memcached. is correct way omniauth use memcached while attempting authenticate google in classic-style sinatra app? here 1 approach have discovered works, i'm sure there better way... module rack class openid def initialize(app, store = nil) @app = app @store = ::openid::store::memcache.new(openidmemcachedman

javascript - Scroll without calling scroll event -

this web has layout: section1 section2 section3 section4 section5 each section covers entire screen height. need web scroll middle (section3) while i'm preloading images, that, use: var targetoffset = $('#home-nav-bar').offset().top - 183; $("html, body").animate({ scrolltop: targetoffset }, 100); this effect not visible user, because trigger while preloader loads images. but web uses parallax effect, i'm achieving stellar.js . problem have .animate fires scroll event on page, , triggers stellar code, moves elements away should after preloading finishes. there way can "scroll" section3 without using .animate triggers stellar.js ?

validation - Java processing multiple possibly unknown date/time formats -

i trying create can check date/time of many formats see if valid date/time can process it. processing consists of converting date/time normalized software work with. problem have check in different ways try , detect date simpledateformat has been hard every variety. project related parsing csv files potentially user-specified date formats in date column. there better way? here doing right now: public static boolean isdatevalid(string datestring) { arraylist<simpledateformat> dateformats = new arraylist<simpledateformat>(); dateformats.add(new simpledateformat("m/dd/yyyy")); dateformats.add(new simpledateformat("dd.m.yyyy")); dateformats.add(new simpledateformat("m/dd/yyyy hh:mm:ss")); dateformats.add(new simpledateformat("dd.m.yyyy hh:mm:ss")); dateformats.add(new simpledateformat("dd-m-yyyy hh:mm:ss")); dateformats.add(new simpledateformat("m-dd-yyyy hh:mm:ss")); dateforma

c - Finding all possible words from inputted phone number -

this question has answer here: generating possible combinations 11 answers i have problem need in figuring out. hoping few pointers on better way approach i'm doing. main issue few lines below (//this whats hanging me up) , described @ bottom of page. i need permutate possible outcomes of phone number: (not dictionary words) i.e. 222-2222 should output list 3^7 long possible permutations of a,b,c i.e. aaaaaaa aaaaaab aaaaaac aaaaaba // whats hanging me aaaaabb aaaaabc aaaaaca // here , on my code (purposely shortened testing) gives me: aaaa aaab aaac aabc aacc abcc accc bccc cccc i'm beginning programming student knowledge goes far using for, while, if, statements , grabbing individual chars array. here's code looks far: (this part of function. code missing) char alphafunc(char n[]){ int d1=n[0]-48; int d2=n[1]-48; int d3=n[2]-48

Basic Python List Excercise -

how make graph print vertically rather horizontally? please try use same concept(loops, lists) used in code understand changes. thank help! here code: sign='x' test_list=[500000,5000000,7000000] test_calc_list=[] test_sum=sum(test_list) test_string_list=['test1','test2','test3'] signs_list=[] x in test_list: test_calc=round((x/float(test_sum)*10)) test_calc_list.append(test_calc) y in test_calc_list: y=int(y) signs=y*sign signs_list.append(signs) z in range(len(test_string_list)): print "%8s: %-6s %7i"% (test_string_list[z],signs_list[z],test_list[z]) this output get: test1: 500000 test2: xxxx 5000000 test3: xxxxxx 7000000 this output want: x x x x x x x x x test1 test2 test3 500000 5000000 7000000 assuming isn't homework (you know there software

How to filter a date column based on month in MySQL -

i'm trying filter date column based on month: select id, nama, lahir_tanggal `alumni_db.alumni_tb` date("f", strtotime('lahir_tanggal') = "august"; lahir_tanggal in date format how make query work? select id, nama, lahir_tanggal alumni_db.alumni_tb monthname(lahir_tanggal) ="august" or select id, nama, lahir_tanggal alumni_db.alumni_tb month(lahir_tanggal) =8 see here

php - JQuery post not working on dynamic jQuery elements -

note: question split post: jquery not working on elements created jquery i dynamically adding list items list in jquery through ajax call called every second. below code ajax call. $.ajax({ url: 'php/update_group_list.php', data: '', datatype: 'json', success: function(data) { var id = data.instructor_id; group_cnt = data.group_cnt, group_name = data.group_name, group_code = data.group_code; (i = current_row; < group_cnt; i++) { //setinterval(function() { $('#group-list-div').load('php/group_list.php'); }, 5000); $('#group-list').append("<li><a href='#' data-role='button' class='view-group-btns' id='"+group_code[i]+"' value='"+id+"' text='"+group_name[i]+"'>"+group_name[i]+"</a></li>");

System.IO.File.Copy Throws IOException -

i trying copy files: private void docopy() { string[] files = directory.getfiles(application.startuppath + "\\app_data", "*.*", searchoption.alldirectories); string sftptoreadfilefrom = "ftp://<user>:<pass>@mysite.tk/updates/app_data/"; string spathtowritefileto = application.startuppath + "\\app_data"; webclient webclient = new webclient(); webclient.credentials = new networkcredential("user", "pass"); foreach (string s in files) { string filename = path.getfilename(s); string destfile = path.combine(spathtowritefileto, filename); byte[] filedata = webclient.downloaddata(sftptoreadfilefrom + filename); //shows correct bytes file.copy(s, destfile, true); } } the exact error is: process cannot access file 'c:\applauncher\applauncher\bin\debug\app_data\firstfile' because being used process. i followed 'msdn how to' here: htt

C++ cannot convert 'classname<int>' to 'int' in return -

i'm trying apply template original class program. got error of cannot covert 'move' 'int' in return. please help.... this template. error on line 40 #ifndef move0_h_ #define move0_h_ template <typename type> class move { private: double x; double y; public: move(double = 0, double b = 0); // sets x, y a, b void showmove() const; // shows current x, y values int add(const move & m) const; // function adds x of m x of invoking object new x, // adds y of m y of invoking object new y, creates new // move object initialized new x, y values , returns void reset(double = 0, double b = 0); // resets x,y a, b }; template<typename type> move<type>::move(double a, double b) { x = a; y = b; } template<typename type> void move<type>::showmove() const { std::cout << "x = " << x << ", y = " << y; } t

php - how to create text type writer effect with jQuery/javascript? -

how create text type writer effect jquery /javascript ? i have tried google,and found jtypewritter, demo page given on jquery plugin jtypewriter not working / opening. link : http://archive.plugins.jquery.com/project/jtypewriter project's home page not working. questions : how can create text type writer effect jquery or java script ? is there way have same effects via other tricks ? i assume text type writer effect , mean 1 in microsoft powerpoint presentation slideshow animations :) i.e. random colored text appear left right little delay. you can create own. see (and ugly) demonstration me: var data="this data shown in effect"; var index=0; var cursor="<span id='cursor'>_</span>"; $('.content').append(cursor); function test(){ //clear interval once entire characters processed if(index>=data.length-1){ clearinterval(t); } //generate random color var hue = 'rgb(

determine whether an acocunt is expired PHP -

how determine account expired. the expiry date of account stored in format "dd/mm/yyyy" for example user has expiry date of "12/8/2012" how can compare today's date , find out expired account using php? i tried $expiry = strtotime("12/8/2012"); $now = new datetime(); echo ($now < $expiry ? 'active' : 'expired'); it shows me error where object of class datetime not converted int yuo can use date function , strtotime function $today = date('y-m-d h:i:s'); $expiry = date('y-m-d h:i:s', strtotime("12/8/2012")); if($today >= $expiry) { echo 'account expired'; } else { echo 'account still valid.'; } this output account expired

html5 - Razor object in a href tag -

i new on area of mvc 4 , razor. trying build gallarary "css3 lightbox". looks ok problem cant work razor , links. cant understand wrong links of pre , next url. hope can help, thins maybe wrong. code looks that: @for (var = 1; < viewbag.gallaryitems.length; i++) { <li> <a href="#image-@i"> <img src="@viewbag.gallaryitems[i].path" /> <!-- <img src"~/images/gallary/pic1.jpg" alt="image01"/> --> <span>pointe</span> </a> <div class="lb-overlay" id="image-@i"> <img src="@url.content(viewbag.gallaryitems[i].path)" /> <div> <h3>@viewbag.gallaryitems[i].title<span>/point/</span></h3> <p>@viewbag.gallaryitems[i].description</p> <a href="#image-@i--" class="lb-prev">prev</a>

c# - Displaying a dialog on unhandled exception -

i want able display dialog when xamarin android application crashes. 'sorry application has crashed. send error report developer?". i've hooked thread.defaultuncaughtexceptionhandler calls uncaughtexception when exception caught. when exception caught try start new activity display dialog - dialog created blank dialog title shown. oncreate never called , dialog seems hang. if call code display dialog when application running displays , runs correctly doesn't seem wrong dialog code. anyone know how solve problem? currently there no supported , recommended way catch , identify unhandled exception in xamarin.android. hope gonna fix asap. see http://mono-for-android.1047100.n5.nabble.com/catch-all-the-exceptions-td5165993.html see jonathan pryor-2 post.

c# - DateTime + Timer Tick? -

i want, when click on button, start "elapsed time". i've written far: private void timer_tick(object sender, eventargs e) { timecounter++; labeltimer.text = "elapsed time: " + timecounter.tostring(); } with timer interval @ 1000 (1 second). what want format time this: hh:mm:ss and auto increment minutes when seconds reach 60, , on hours. should use datetime , add second every 1 second? you may use timespan : timespan _elapsed = new timespan(); private void timer_tick(object sender, eventargs e) { _elapsed = _elapsed.add(timespan.fromminutes(1)); labeltimer.text = "elapsed time: " + _elapsed.tostring(); }

Eclipse Android Application project compile with google API 17 -

i see android api 17 in selection follow instruction on https://developers.google.com/drive/quickstart-android when create new-->android application project in compile with: can select api17 android 4.2 video(at 11:02)has google api 17!! can help? you need go android sdk manager , select google api under android 4.2.2 , install package.

optimization - mongoDB references fetching takes time -

i use mongoengine object-document mapper. here brief description of collections causing problem. each document in collection a, can have list of references documents in collection b. class a(document): list_b = listfield(embeddeddocumentfield(eb)) #other fields not mentioned. class eb(embeddeddocument): b_reference = referencefield('b') loc = geopointfield() class b(document): name = stringfield() #other fields not mentioned. when try access list objects of particular document document_of_a.list_b the execution time of above line depends on no.of references present in list. eg. takes 100ms 100 references in list. is there better way fetch references?, execution time of above mentioned line reduced. you should use select_related flag when querying if want references quickly. please note reference lookups cost queries , select_related() designed reduce number of round trips mongodb. # single document lookup document_of_a.sele

actionscript 3 - URLLoader is not working in flex 4.6 Mobile Project for Android -

urlloader not dispatching event.complete event on android mobile, although working in flash builder mobile debugging. code snippet given below: private function loadalbumdata():void { var request:urlrequest = new urlrequest("https://picasaweb.google.com/data/feed/api/user/default"); var urlloader:urlloader = new urlloader(); urlloader.addeventlistener(event.complete, onloadcomplete); urlloader.load(request); } private function onloadcomplete(evt:event):void { trace(evt.currenttarget.data); } here requesting album xml google's picasa service. from looks of xml page, pulling in data relevant me. best guess relies on being signed google determine user is. if user doesn't have google cookie (tested signing out of google), returns "authorization required", might returned http status error rather actual page. because apps sandboxed, cookies not shared between apps or system without explicitly asking them (which require ane) in ca

ios - Draw UIImage on a custom color canvas -

i want draw image example on black canvas, the result white, here code -(uiimage*) renderimage { uigraphicsbeginimagecontext(cgsizemake(300, 300)); [[uicolor blackcolor] setfill]; uiimage*resultimage = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext(); return resultimage; } for future draw image inside canvas, right want black filled canvas. why code not working you need using cgcontextsetfillcolorwithcolor() fill current context color. try sample code, give color , size , return uiimage meeting criteria. - (uiimage *)renderimagewithcolor:(uicolor *)color insize:(cgsize)size { cgrect rect = cgrectmake(0.0f, 0.0f, size.width, size.height); uigraphicsbeginimagecontext(rect.size); cgcontextref context = uigraphicsgetcurrentcontext(); cgcontextsetfillcolorwithcolor(context, [color cgcolor]); cgcontextfillrect(context, rect); uiimage *image = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsen

Is there a bug with min="0" in jquery validation? Or am I overlooking something? -

Image
jquery validation seems work fine min="1" , min="-1" , not min="0" . consider jsfiddle . appropriately objects value of -5 in first input element , in third, accepts -5 in second one, min="0" . is bug in jquery validation or overlooking something? <form id="myform"> <input type="text" name="negativeone" min="-1"/> <br/> <input type="text" name="zero" min="0"/> <br/> <input type="text" name="one" min="1" /> </form> <button id="event2">test</button> <a href="http://docs.jquery.com/plugins/validation" target="_blank">validation documentation</a> javascript $(document).ready(function () { $('#myform').validate({ }); $('#event2').on('click', function () { $('#myform').valid();

mysql - Order results in which it was read in. Using in() -

this query in mysql: select school_id, first_name, last_name, email, blog_username, comment_username table user_id in (100, 3,72) ; the results show 2 user_id's in ascending order. how can make ordered in received? so instead of 3, 72, 100 want results 100, 3, 72 . select school_id, first_name, last_name, email, blog_username, comment_username table user_id in ( 100, 3, 72 ) order case when user_id = 100 1 when user_id = 3 2 when user_id = 72 3 end asc addition explanation: what being sought ability order rows in custom manner. said way, need add custom cardinality set of values not conform standard cardinality. case expression can used that. way accomplish same thing be: select school_id, first_name, last_name, email, blog_username, comment_username table join ( select 100 user_id, 1 sort union select 3, 2 union select 72, 3 ) seq on seq.user_id = table

java - Different Enter and mouse click event -

i have button call method, in method call method connect db , return results, if results positive, change labels , make button enabled, , if results negative, button still disabled the problem is, have set in tf keytyped event, if type new in it, disable btneditar: public void keytyped(keyevent e) { btneditar.setenabled(false); btndeletar.setenabled(false); } i dont want event "capture" enter disable button there way or have think logic way? as others have pointed out, there other ways besides using keylistener . respond original attempt below. keylistener functional , easy tool use job. use keypressed instead of keytyped , , you'll have valid key code can use ignore enter presses: public void keypressed(keyevent e) { // not keytyped! if (e.getkeycode() != keyevent.vk_enter) { btneditar.setenabled(false); btndeletar.setenabled(false); } } if

Using a loop with xargs in one line -

i using tcsh. want output: mkdir dir1 dir2 dir3 dir4 where of course maximum number of dirs variable. point contain incrementing variable loop in names. have feeling should use xargs. want able use simple loop, , in 1 line if possible. possible? feeling like: loop here | xargs mkdir but not able make syntax work. edit: figured out how multiple lines of input. know how make following single line input? for in {1..5} echo -n " dir$i" done \ | xargs mkdir code: foreach ( `seq 1 1 10` ) mkdir dir$a end or seq -f 'dir%.0f' -s ' ' 1 1 10 | xargs mkdir

jdbc - Java prepareStatement setting -

i have prepare statement this: where trade_date >= trunc(add_months(current_date,-12)) but want have this: where trade_date >= trunc(?) and set value later this: query.setstring(1,"add_months(current_date,-12)"); or query.setstring(1,"trunc(sysdate, 'year')"); however, got error saying inconsistent datatypes: expected date got number how can that? i think you'll have build template statement using string concatenation etc, , record parameters wish insert alongside (in array of objects?). then iterate through each 1 , perform setstring() etc. can't insert arbitrary sql using preparedstatement (it defeat 1 of preparedstatement 's benefits, restrict sql construction customising parameters)

javascript - Uncaught TypeError: Object [object Window] has no method 'each' function -

hey guys here js file , taking error message each function @ line:24 , not know why couldnt find whats wrong. trying see list of items on console.log panel not give me list on html page. (function() { window.app = { models: {}, collections: {}, views: {} }; window.template = function(id){ return _.template( $('#' + id).html() ); }; app.models.task = backbone.model.extend({}); app.collections.task = backbone.collection.extend({ model: app.models.task }); app.views.tasks = backbone.view.extend({ tagname: 'ul', render: function(){ this.collection.each( this.addone, this); return this; }, addone: function(task){ //creating new child view var taskview = new app.views.task({ model: task }); //append root element this.$el.append(taskview.render().el); } }); app.views.task = backbone.view.extend({ tagname: 'li', template: tem

c++ - Insert multiple values into vector -

i have std::vector<t> variable. have 2 variables of type t, first of represents value in vector after insert, while second represents value insert. so lets have container: 1,2,1,1,2,2 and 2 values 2 , 3 respect definitions above. wish write function update container instead contain: 1,2,3,1,1,2,3,2,3 i using c++98 , boost. std or boost functions might use implement function? iterating on vector , using std::insert 1 way, gets messy when 1 realizes need remember hop on value inserted. this do: vector<t> copy; (vector<t>::iterator i=original.begin(); i!=original.end(); ++i) { copy.push_back(*i); if (*i == first) copy.push_back(second); } original.swap(copy); put call reserve in there if want. know need room @ least original.size() elements. initial iteraton on vector (or use std::count ) determine exact amount of elements reserve, without testing, don't know whether improve performance.

sql server 2008 - Casting a String in SQL Query -

i have query extracts numeric value of date programmed in database long time ago , displays 19930215.202300000. 3 different columns i've done far cast string date , time existing query: select serialnum [serial number],ts_sitename site,(case m.scratched when 0 'live' when 1 'free' end) status, note comment, (case destroyed when 0 'no' when 1 'yes' end) [destroyed], substring(cast(effectivedate char), 1, 8) [effective date added], substring(cast(effectivedate char), 10, 6) [effective time added], substring(cast(scratcheddate char), 1, 8) [scratched date], substring(cast(scratcheddate char), 10, 6) [scratched time], substring(cast(changedpurgedate char), 1, 8) [purge date], substring(cast(changedpurgedate char), 10, 6) [purge time], (select fl_filename thefiles_tab mg_filenum = fl_filenum) [dataset], (select hs_hostname thehosts_tab mg_hostnum = hs_hostnum) [host], (select usercode [user] mg_usernum = userid) [usercode]

c# - Merge two DataTables with LINQ -

my question similar this i have 2 datatables: datatable 1: column 1: date column 2: requests 1 datatable 2: column 1: date column 2: requests 2 i need bellow result: new datatable: column 1: date column 2: requests 1 column 3: requests 2 expected result: date requests 1 requests 2 total 15/08/2013 25 40 60 14/08/2013 40 60 100 13/08/2013 40 0 25 12/08/2013 0 80 80 what did until now: datatable lista_1 = ds.tables[0]; datatable lista_2 = ds.tables[1]; var mylinq = l1 in lista_1.asenumerable() join l2 in lista_2.asenumerable() on l1.field<datetime>("date") equals l2.field<datetime>("date") select new { daterelatorio = l1.field<datetime>("date"), request1relatorio = l1.field<int>("total"),

angularjs - TypeError: 'undefined' is not a function when using spyOn with Karma -

i've been using yeoman setup projects, , trying build angular module project apply feature toggles. i'm getting hung jasmine testing @ unit level, here 1 of tests: var scope, rules; var elm; // load controller's module beforeeach(function() { module('featuretoggle.directives', function($provide) { $provide.decorator('rules', function($delegate) { $delegate.resolvebyname = jasmine.createspy(); return $delegate; }); }); inject(function(_rules_) { rules = _rules_; }); }); beforeeach(inject(function($rootscope, $compile) { scope = $rootscope.$new(); elm = angular.element( '<h1 feature-toggle feature-name="hello">' + 'hello world' + '</h1>'); scope = $rootscope; $compile(elm)(scope); scope.$digest(); })); it('should render content when feature enabled', function() { jasmine.spyon(rules, 'resolvebyname').andreturn(false); var content

python - How do I get IPython autoreload magic to load automatcially when using an embedded shell? -

i have following in ipython_config.py : print "test autoreload" #confirm gets loaded c = get_config() c.interactiveshellapp.extensions = ['autoreload'] c.interactiveshellapp.exec_lines = ['%autoreload 2'] and seems work normal ipython sessions: $ ipython test autoreload in [1]: %autoreload 2 in [2]: however, when using embedded shell script uses ipython.embed(), autoreload magic no longer works. for example, in shell.py : from ipython import embed embed() this still loads ipython_config.py, evidenced "test autoreload" printing out, autoreload extension not loaded (no %autoreload magic): $ python shell.py test autoreload in [1]: %autoreload 2 error: line magic function `%autoreload` not found. as far can tell, (known) bug. extensions loaded if there application, when using embed, won't loaded (although config read). there open issue on github fix this, has never been implemented.

iphone - UICollectionView for Grid Layout with Xamarin.iOS (MonoTouch)? -

Image
i wondering if there uicollectionview implementation around displaying views (images) in grid shown below. i started build uitableview, getting complicated if item doesn't fit in same row predecessor/successor. i came across other day, similar want , may work out: http://pierceboggan.com/post/56951869926/pinterest-style-uicollectionviews-in-xamarin-ios it modification of uicollectionview made work waterfall layout pinterest uses.

Replacing characters in C++ Pointer Character string? -

this question has answer here: why segmentation fault when writing string initialized “char *s” not “char s[]”? 16 answers suppose have in c++: char *p = "apple"; i can't this: p[1] = 'w'; but why can this? p = "orangetorange"; as p points constant string literal if do: p[1] = 'w'; trying modifying string literal read constant , illegal operation (undefined behavior). whereas in expression p = "orangetorange"; modify value of p variable pointer char. , assigning new address value p valid operation, p start pointing new string literal. to add further, suppose if p points array p[1] = 'w'; not invalid operation consider below example code: char str[] = "apple"; char* p = str; // p points array p[1] = 'w'; // valid expression, not str[1] = 'w' va

Alter table for a datediff (MySQL) -

i trying alter table change 1 of column values datediff() keep getting error , don't see issue is. here code alter table bids modify column 'timeleft' datediff(curdate(),'duedate'); if trying change values should not using alter table should using update

bash - Ping Tool to check if server is online -

is tool created various sof threads valid? work? want have ping test done server every minute. if fails 5 times in row sends email out. flushes , resets script pretty check again. #!/bin/bash # ping checker tool numoffails=0 incrememnt=1 emailmessage="/tmp/emailmessage.txt" while true; if ! ping -c 1 google.com ; #if ping exits nonzero... numoffails=$(($num + $increment)) else numoffails=0 fi if ((numoffails > 4)); numoffails=0 echo "san offline!" > $emailmessage mail -s "san offline" "test@test.com" < $emailmessage fi sleep 60 #check again in 1 minute done your code won't work @ all, revised version: #!/bin/bash # ping checker tool fails=0 email_address="example@example.com" server="192.168.1.1" sleep=60 while true; ping -c 1 $server >/dev/null 2>&1 if [ $? -ne 0 ] ; #if ping exits nonzero... fails=$

mysql - sql more than one keys in one field -

i guess, name of question strange, don't know how state correctly, i'll try describe problem. say, have 2 tables: 1) id | unit_name | strength | health 1 | private | 10 | 10 2 | general | 5 | 5 n | | 123 | 321 2) id | rules | who_has_this_rule 1 | rule1 | 1 2 | rule2 | 2 3 | rule3 | 1 4 | rule4 | 1 the field "who_has_this_rule" correspondes id of first table. can't figure out if unit should have more 1 rule in profile. example, private should have rule1 , rule4. how this? what need join table. a third table join rule , units unit_rules id | unit_id | rule_id 1 | 1 | 1 2 | 1 | 4 3 | 2 | 1 you can have primary key(id) or compound key(unit_id , rule_id)

crystal reports - Pass Formula Field into Parameter Field -

is possible pass formula field parameter field in crystal reports? example parameter {?jobnumber} string discrete , allow multiple values user inputs job number 33882 , there associated jobs job number. (ie. 33882, 33768) so want pass associated jobs parameter field (as array?). instead of record selection selecting 1 input (masterid = {?jobnumber})(33882), record selection selects associated jobs (masterid = {?jobnumber})(33882, 33768).

regex - Python function that corrects a email domain -

okay, have function construct_email(name, domain): def construct_email(name, domain): if domain == true: print 'true' else: print'none' return name + "@" + domain this function isn't big or anything, it's suppose output email address. have other function correct_domain(domain): suppose check domain name that's been input in construct_email(name, domain): import re def correct_domain(domain): if re.search(r'^\.|\.$', domain) or re.search(r'\.\.', domain): return false elif re.search(r'\.', domain): return true else: return false my question is, how do this? if i'm understanding correctly: import re def construct_email(name, domain): if not check_domain(domain): return false return name + "@" + domain def check_domain(domain): dots = re.findall(r"\.", domain) if (len(dots) != 1) or domain.s

eclipse - build error related to g++ -c flag -

i dont understand g++ -c flag . based on definition:compile or assemble source files, not link. linking stage not done. ultimate output in form of object file each source file. need understand cause error following build process. thanks i try compile sample helloworld program in eclipse. #include <iostream> using namespace std; int main () { cout << "hello world!"; return 0; } without -c. eclipse gives me error: make building file: ../app.cpp invoking: gcc c++ compiler g++ -o0 -g3 -wall -fmessage-length=0 -fpic -mmd -mp -mf"app.d" -mt"app.d" -o "app.o" "../app.cpp" finished building: ../app.cpp building target: app.so invoking: gcc c++ linker g++ -shared -o "app.so" ./app.o ./app.o: in function `_fini': (.fini+0x0): multiple definition of `_fini' /usr/lib/gcc/x86_64-redhat-linux/4.6.3/../../../../lib64/crti.o:(.fini+0x0): first defined here ./app.o: in function `_init': (.init+0x0

c# - How can I add a HyperLinkField to GridView databound to a file directory? -

i trying add hyperlinkfield column gridview pulls filenames file directory on server. i'm using code below, it's not working. it's showing path , filename, it's not clickable hyperlinkfield. i'm not sure i'm doing wrong, can me out? public void getfilesandfolders() { using (irepentities dbcontext = new irepentities()) { string vchartempfilelocation = (from in dbcontext.tbl_applicationsetting a.vcharkey == "vchartempfilelocation" select a).single().vcharvalue; datatable gridviewsource = displayfilesingridview(); datarow gridviewrow; //get folders or directories , add in table directoryinfo directory = new directoryinfo(vchartempfilelocation); directoryinfo[] subdirectories = directory.getdirectories(); foreach (directoryinfo dirinfo in subdirectories

c# - SQL Connection Limit and managing Entities -

so, manage large web application , set unique method of handling entity framework data context caching across different events on page. had seen before there 2 methods managing context across pages in entity framework: create static context shared connections. use connection disposable within events. because our data changes rapidly me want use static context started disposable connections within each event. became problematic since our pages robust , led lot of overhead opening , closing contexts. also, limited amount of caching within page since have bring data in fresh every event. decided go new had never seen done open 1 context each request , hold open entire request. gave best flexibility between both methods , code included below: public class frontendpage : system.web.ui.page { private pagecontext _context; public database.databaseentities context { { if (_context == null) _context = new pagecontext()