Posts

Showing posts from August, 2013

javascript - FullCalendar refetchEvents not reloading calendar -

if ajax call create new event succeeds, reload pages fullcalendar. however, calling refetchevents seems have absolutely no effect - , watching network traffic in chrome shows no call being made url fullcalendar queries events. missing? function submitnewevent(event) { event.preventdefault(); dnnevent = dnneventwithformdata(); $.ajax({ type: 'post', url: urlcreateevent, data: dnnevent }).success(function (response) { dialog.dialog('close'); $("#userevents").load(urluserevents); $("#calendar").fullcalendar('refetchevents'); }).error(function (response) { console.log(response); alert('failed'); }); } try: var mycal = $("#calendar)....init... then in .success : mycal.fullcalendar('refetchevents');

c++ - "Overload" function template based on function object operator() signature -

consider example of function template takes function reference first argument. overloaded based on function signature of first argument. body of each overload feeds 1st argument function appropriately it's signature. template<typename t> struct mapttot { typedef t (type)(const t); }; template<typename t> std::vector<t> map_vec( const typename mapttot<t>::type& fnc, const std::vector<t>& source) { std::vector<t> dest; dest.reserve(source.size()); (const auto : source) { dest.emplace_back(fnc(i)); } return dest; } template<typename t> struct maptandvectot { typedef t (type)(const t, const std::vector<t>&); }; template<typename t> std::vector<t> map_vec( const typename maptandvectot<t>::type& fnc, const std::vector<t>& source) { std::vector<t> dest; dest.reserve(source.size()); (const auto : source) {

.htaccess - How to make Apache rewrite blog URLs? -

i've installed wamp, made alias, , put folder ".htaccess" file. goal have url such "foo.com/blog/bar-baz" internally call "display.php?name=bar-baz". among various things tried following: rewriterule ^blog/(.+)$ display.php?$1 however, gives "the requested url /users/.../public/display.php not found on server". playing around able work: rewriterule ^blog.php$ /personal/display.php advice appreciated. you can try rule root .htaccess: rewriteengine on rewriterule ^blog/(.+)$ /personal/display.php?name=$1 [l,qsa,nc]

Java Reverse a linked list pairwise -

i trying reverse linked list pairwise i.e follows 1->2->3->4->5 changed 2->1->4->3->5 i have been able recursively. however, getting confused while doing iteratively. public class fastlist<item> { private node<item> first; private static class node<item> { item item; node<item> next; } public void swappairwiseiterative() // not working { if(first == null || first.next==null) return; node 1 = first, two; first= first.next; while ( 1 != null || one.next != null ) { 2 = one.next; one.next = two.next; two.next = one; 1 = one.next.next; } } } on debugging, noticed able swap 2 nodes correctly, not able assign first instance variable, points first element of list. how do ? also, line first= first.next; looks bit hacky. please suggest more natural way of doing it.

Handling "Authentication Required" alert box with Python 2.7 + Selenium Webdriver -

i having issue secure url: opening url creates "authentication required" alert box username , password fields. i new selenium webdriver , python. not familiar handling alerts , manually typing in credentials until can figured out. i have tried adding username/password url. not work me. could please point me in direction of entering keys username , password fields in alertbox? in case of such authentication, need pass username , password server while accessing page avoid authentication window(which out of reach of selenium) suppose url you're trying access is: http://example.com you'll have access url credentials following: driver.get('http://username:password@example.com') where username username , password password site.

ios - Swift Casting on Pre iPhone 6 Devices -

Image
for reason line of code crashing on pre iphone 6 devices: var friendmatch = newdict.objectforkey("is_match") int the dictionary generated json receive endpoint. json looks this: "is_match" = 1; i've tried: var friendmatch: nsnumber = newdict.objectforkey("is_match") nsnumber and app still crashes on line. crash log unhelpful. any thoughts on why working on iphone 6 , 6+, not on older devices? var friendmatch = newdict.objectforkey("is_match") int you should not casting unconditionally. cast conditionally instead: if let friendmatch = newdict.objectforkey("is_match") as? int { // ... } now if cast fails won't crash.

java - Function returning a result but gives an error that it doesnt -

this question has answer here: this method must return result of type boolean, java 4 answers i try make function checks if number prime or not , eclips gives me error have return result thought do. public static boolean isprime (int x){ for(int i=2;i<x;i++){ if(x%i==0){ return false; } } } your logic incomplete: public static boolean isprime (int x){ for(int i=2;i<x;i++){ if(x%i==0){ return false; } } return true; }

R: Convert COO format matrix to regular matrix format -

i have square matrix in coo (coordinate list) format. for example: from value 1 1 1 1 2 1 2 1 0 2 2 1 i want convert regular r matrix format. this: [,1] [,2] [1,] 1 1 [2,] 0 1 please advise how it. here way found: using matrix package. first, table example: > coo_mat <- rbind(c(1,1,1), c(1,2,1), c(2,1,0), c(2,2,1)) > coo_mat [,1] [,2] [,3] [1,] 1 1 1 [2,] 1 2 1 [3,] 2 1 0 [4,] 2 2 1 now, make regular format matrix: > as.matrix(matrix::sparsematrix(i=coo_mat[,1], j=coo_mat[,2], x=coo_mat[,3])) [,1] [,2] [1,] 1 1 [2,] 0 1

Django collecstatic with crontab -

i have django website scrapper every day download images, want automate collectstatic crontab tried add crontab.cr yes | python2.7 manage.py collectstatic but error : you have requested collect static files @ destination location specified in settings: /home/mojbutik/webapps/webshop/myproject/static this overwrite existing files! sure want this? commanderror: collecting static files cancelled. can tell me how it... did try command? python manage.py collectstatic --noinput

java - Problems loading data into combobox -

public void muestraregistro(jtextfield t1 ,jtextfield t2 , jtextfield t3 , jtextfield t4 , jtextfield t5,jtextfield t6 , jcombobox cmb) { try { int row = productogui.tbldetalle.getselectedrow(); string muestra = productogui.tbldetalle.getmodel().getvalueat(row, 0).tostring(); //string muestra = productogui.tbldetalle.getvalueat(productogui.tbldetalle.getselectedrow(), 0).tostring(); rs = cargaregistro(); while (rs.next()) { t1.settext(rs.getstring(1)); t2.settext(rs.getstring(2)); cmb.setselecteditem(rs.getstring(3)); system.out.print(cmb); t3.settext(rs.getstring(4)); t4.settext(rs.getstring(5)); t5.settext(rs.getstring(6)); t6.settext(rs.getstring(7)); habilitatexto(false, t2, t3, t4, t5, t6); } } catch (sqlexception | headlessexc

javascript - jquery load and working off local hard drive -

in pinch, we're trying convert bunch of production ui files can zip , send else view locally via local hard drive. we're trying avoid messing current jquery as can. right now, pages using js includes of sorts such as: #('idhere').load('some/local/htmlfile.html') this, alas, triggers console error of: cross origin requests supported protocol schemes: http, data, chrome-extension, https, chrome-extension-resource. is there way around cross origin issue when requesting files local drive (ie, file: protocol?) you can start chrome --disable-web-security parameter it. here full explanation disable same origin policy in chrome

javascript - Passing data to server using JSON in Codeigniter -

i'm trying pass data stored in javascript array server database processings. i'm using codeignier. javascript array (unitdata_set):- [{"unit_id":"13","unit_title":"testsdsdf","unit_max_occupancy":"3","unit_no":"1","unit_no_adults":"1","unit_no_children":"1","unit_no_extrabed":0,"unit_mealtype":"full board","unit_fullboard_adult":"6000.00","unit_fullboard_child":"4000.00","unit_halfboard_adult":"1800.00","unit_halfboard_child":"1200.00","room_total":"81600.00","all_room_price":"81600.00","extra_bed_price":"4.00","meal_price":22000,"saving_amount":16320,"discounted_bedroom_price":65280},{"unit_id":"14","unit_title":"res2&qu

c - How to write a blank line to a text file? -

i'm writing program keep inventory of books, reads list of books text file , writes additional books file. got add new books file, have blank line between each book entry. how can that? other info might useful or needed: i'm using structure hold title, author, , isbn in character strings. here's part collects new data: it's put linked list. puts("enter first book title."); while(fgets(input, 80, stdin) != null && input[0] != '\n') { current = (struct book *)malloc(sizeof(struct book)); if(head == null) head = current; else prev->next = current; current->next = null; strcpy(current->title, input); puts("enter author."); fgets(current->author, 80, stdin); puts("enter isbn."); fgets(current->isbn, 80, stdin); puts("enter next book title (empty line quit)"); prev = current; } here's part writes file: input_file = fopen("library.txt", "w"); printf("printin

How can I determine what the current stable version of Ruby is? -

i want write ruby method 2 things: determine current stable version of ruby is. first thought response https://www.ruby-lang.org/en/downloads/ , use regex isolate phrase the current stable version [x] . there api i'm not aware of? get url download .tar.gz of release. thinking same thing, output of site url. i'm looking advice best way go it, or direction if there's in place might use determine desired results. ruby code fetch download page, parse current version , link url: html = net::http.get(uri("https://www.ruby-lang.org/en/downloads/")) vers = html[/http.*ruby-(.*).tar.gz/,1] link = html[/http.*ruby-.*.tar.gz/] github code: ruby-stable-version.rb shell code: ruby-stable-version

Take a text line in an image file to create a new image file MATLAB -

Image
i need take each line of text image file , create new separate image each of lines. have way count how many lines in image file. if has suggestions huge because i'm not images. im not allowed use image processing toolbox. this code: function out = countlines( imgfile ) % count number of lines in image file im = imread(imgfile); im = 255 - im; imbw = uint8(0.33*im(:,:,1) + 0.34*im(:,:,2) + 0.33*im(:,:,3)) > 127; imwrite(imbw, 'temp.jpg'); rvec = sum(imbw'); rvec1 = [0 rvec 0]; svec = [rvec 0 0]; out = sum(rvec1 == 0 & svec ~= 0); i tried method on test image found on internet , seemed work alright provided text straight. entries in rvec vector neighbouring entries both smaller them. local maximum entries (first image). after group clusters of lines decide split image (second image). clear; clc; im = imread('text.png'); % load image [nrows,ncols,~] = size(im); % size imgray = rgb2gray(im); % convert grayscale

java - Converting character inputs into numerical variables -

consider following input example: user_input> x which read following code: scanner scan= new scanner(system.in); string s = scan.nextline(); is possible declare numerical variable has same name of string read? in order convert string integer, use integer.parseint() method. for long types, long.parselong(). , on.

lua table - `__call` doesn't work in my Lua code -

i think simple dummy example file explains more long words t = {} t.__call = print t.__call(1) t(2) according documentation , since t table, call t , t(2) , should redirected call t.__call , t.__call(2) . t.__call works fine, no problem, "syntaxic sugar" doesn't. here output of above code : 1 lua: test.lua:4: attempt call global 't' (a table value) stack traceback: test.lua:4: in main chunk [c]: in ? what missing ? why isn't t(2) converted t.__call(2) ? __call metamethod , should set on table`s metatable , not table itself. t = {} m = {} m.__call = print setmetatable(t, m) t(2) check out here. see @deduplicator excellent comment more concise way of doing same thing.

sql server - SQL - Using CTE and effectively select rows at a specific row_number() -

in scenario select top necessary within cte (micro optimization, know...). declare @pagesize int, @currentpage int, @top int set @pagesize = 10 set @currentpage = 150 set @top = @pagesize * @currentpage + @pagesize t ( select top(***@top***) id, name row_number() on (order id) _row, dbo.user ) select top(@pagesize) * t t._row > (@top-@pagesize) order t.id the above returns 10 (@pagesize) rows start number (@top-@pagesize) in specific order row number column. cte statement know "select top" outside of cte , where-clause, outside cte, come, hence cte never returns more rows in specific order needed? basically talking row_number function, not count row number rows not returned (if have millions of rows...), , if select top 100 in cte, row_number still calculated million rows within table selected? i have tried , without "select top(@top)" in cte-statement, inside loop 10.000 runs, without seeing difference in time usage. though, have 38.000

web services - Eclipse how to add new webservice runtime in Eclipse -

i add new webservice runtime environment in eclipse (kepler,luna ..) currently default there 3 options axis, axis2,apache cfx. but want use either metro /weblogic etc. is there option can in eclipse. search plugins in eclipse can you. metro , found 1 here https://metro.java.net/2.1/guide/developing_with_eclipse.html

Node.js singlethreading concept -

if have long running process in node, how run process while still remaining responsive new user requests? in other languages, such java, start daemon (background) thread , run process on that. node, if it's singlethreaded, how work? there's concept of event-loop. when node process i/o operation (ie. reading db etc.), puts current request event-loop, , thread moves onto next request. when i/o done, thread picks callback event-loop, , responds user. because of paradigm, node.js able handle many requests in 1 thread, opposed of creating thread per requests.

java - Performe nested select statement with Spring JDBC -

i have problem executing nested select statement. here sql : select count(*) posts p p.id in (select u.postid users u) ; i'm using mysql , working when try mysql workbench when try in application in i'm using spring jdbc, throws me "org.springframework.jdbc.uncategorizedsqlexception." here how i'm using in app: getjdbctemplate().queryforobject(sql, integer.class); i had tried , : getjdbctemplate().query(sql, new rowcountcallbackhandler()); both ways not working , error. is there configuration options or allowed me execute such nested select statements ? edit the error trace is: [3d000]; error code [1046]; no database selected; nested exception java.sql.sqlexception: no data base selected @ org.springframework.jdbc.support.abstractfallbacksqlexceptiontranslator.translate(abstrac tfallbacksqlexceptiontranslator.java:84) @ org.springframework.jdbc.support.abstractfallbacksqlexceptiontranslator.translate(abstrac tfallbacksqle

Fullcalendar doesn't show correctly event in month mode -

Image
i have problem fullcalendar, have event occurs on day 3 , day 4, when event ends before 9am, month mode shown 1 day, look: week: (ending before 9am) month: week: (ending after 9am) month: how fix it? want show event in month on both days. you need change nextdaythreshold properties hour event display according needs. from docs: when event's end time spans day, minimum time must in order render if on day. duration, default: "09:00:00" (9am) only affects timed events appear on whole-days. whole-day cells occur in month view, basicday, basicweek , all-day slots in agenda views. example (docs) { start: '2014-02-04t20:00:00', end: '2014-02-05t02:00:00' } // goes 8pm 2am next day more info at: http://fullcalendar.io/docs/event_rendering/nextdaythreshold/

Google Earth client kml html link with command line argument -

i trying create placemark open radio station in google earth client using vlc player , stream url. if leave out stream, vlc player opens ok. when add stream argument, vlc not open @ all. (i have allowed ge open local files) a href="file:///c:/program files/videolan/vlc/vlc.exe http://www.somestream ">mylink i think quote marks may need nested somehow or space after exe causing problems. help. after research have found it's not possible pass parameters in href link. made vbs file placemark , open href link.

c++ - Can't figure out Shaders for DirectX11? -

so, have no idea how use shaders. coding them easy, not using them . msdn useless me, meaning have worst tutorials out there. reading frank luna's direct3d 11 book, , part draw stuff. exciting, except fact doesn't work. boxdemo - i'm sure worked 3 years ago when book made, of new directx stuff - omitting directx sdk , using "windows sdk", fx being deprecated, no more d3dx libraries... frustrating. went ahead , downgraded directx 2010 sdk - can use tutorial. every d3d tutorial out there uses d3dx libraries. anyway... question. visual studio has option make .hlsl files. but, has ability make .fx files (if type .fx @ end of file name creates .fx file). so, use deprecated .fx way , learn how use of tutorials teaching - or can learn new hlsl way, , have hardest, frustrating time trying learn no tutorials. i know both use hlsl language. both used in program differently. (createeffectfrommemory, compilefromfile, etc). kind of hope learn new way, if don't

c# - Execute couple command in cmd. Executed only one command -

hellp. in 'plumbing' have 3 command should performed sequentially, , each request must wait until end of previous command. have done 1st request, 2nd , 3rd skips... please suggest how change 'plumbing'? string strcmdtext = s1; var startinfo = new processstartinfo { filename = "cmd.exe", redirectstandardinput = true, redirectstandardoutput = true, useshellexecute = false, createnowindow = true }; var process = new process { startinfo = startinfo }; process.start(); process.standardinput.writeline(strcmdtext); process.waitforexit(); string strcmdtext1 = s2; process.standardinput.writeline(strcmdtext1); process.waitforexit(); string strcmdtext2 = s3; process.standardinput.writeline(strcmdtext2); process.standardinput.writeline("exit"); thank you. let's go through code: you start instance of cmd.exe : var process = new process { startinfo = startinfo }; process.start(); you write command standard input:

ios - Parse.com IAP: How to switch between production and sandbox mode? -

i using parse.com pfpurchase iap library, doesn't how switch between sandbox , production modes. i using sandbox test account , popup dialog shows environment sandbox. however, don't know if behave published app in app store. anyone else know answer? thanks alas, i'm 1 of devs answers own question. (shame) it seems apple changed app knows whether using sandbox or production based on how app deployed. wasn't way before. https://developer.apple.com/library/ios/technotes/tn2259/_index.html "store kit connects sandbox environment when launch application xcode, test device (ios), or finder (os x). connects production environment applications downloaded app store."

ios8 - What is the SKPaymentTransactionStateDeferred flow of alert messages by Apple? -

Image
with ios8, apple introduced new skpaymenttransactionstatedeferred state iap transactions. (e.g., see https://developer.apple.com/library/ios/technotes/tn2259/_index.html ). amongst various issues (like, how test this!?), don't know flow of apple alerts looks state. example, when app gets skpaymenttransactionstatepurchased state, apple has given message "thank you. purchase successful." deferred state? apple give user (e.g., child) alert message? if so, it? if apple doesn't give alert, want this. i guess create new apple id fake child, , set me being parent of fake child. anyone seen how deferred state works in production environment? it seems i've found answer, looking in docs ask buy ( http://support.apple.com/en-us/ht201089 ). apple explicitly includes in-app purchases in docs, , user (a child) given alert: so seem clear don't have put put alert of own! presumably wording of alert differs iap's-- i'd still see specific message

log4j2 - Log4j version 2 set root logging level from Java? -

in log4j version 2, how 1 accomplish previous versions of log4j did when called java code thus: logger.getrootlogger().setlevel( level.trace ); i want, depending on utility's command-line option, turn on tracing. try this loggercontext ctx = (loggercontext) logmanager.getcontext(false); configuration config = ctx.getconfiguration(); loggerconfig loggerconfig = config.getloggerconfig(logmanager.root_logger_name); loggerconfig.setlevel(level); ctx.updateloggers();

Create Jquery array from ajax response -

i trying add or remove classes divs. these divs should assigned different classes depending on value of html. i'm not sure i'm doing wrong code isn't working. this code: $.ajax({ type: 'post', url: 'loc/bcheck.php', success: function(data){ tarrx = new array(data); }, complete: function(){ $('.bhr').each(function(){ curelm = $(this); var btm = curelm.html(); if ($.inarray(btm, tarrx) !== -1){ curelm.addclass('disabled'); curelm.removeclass('available'); } else{ curelm.addclass('available'); curelm.removeclass('disabled'); } }); } }); <div class="bhr">1</div> <div class="bhr">5</div> all values of divs' html caught correctly. , function runs without errors. allways same result, val

c++ - Reading strings and integers into arrays from .txt file -

i novice programmer , i'm having trouble 1 of exercises. need create program reads student information (ssn, first & last name, test score) .txt file called "students.txt", , uses 4 global parallel arrays store student information. i'm required use int array store ssn, string array store first names, string array store last names, , double array store scores. operations include listing students' info how appears: ssn last-name first-name score 628130189 james, paul 92.0 237698211 cook , daniel 86.0 201895367 garza, melessa 78.0 491066285 barbara, jessica 62.0 168606868 bruce, elizabeth 90.0 378205732 lee, sarah 91.5 118453900 brian, david 87.0 583192186 garza, cody 92.0 226665118 lewis, gage 78.0 175382843 collins, james 69.5 816231095 white, ann 88.5 376651608 jackson, mark 72.0 508234567 freeman, mark 86.0 7632

objective c - Trying to use Swift with Obj C header for Coda2 plugin. Getting error: Undefined symbols for architecture x86_64 -

trying build plugin coda 2.5 swift.i'm getting error: undefined symbols architecture x86_64: "_objc_class_$_codapluginscontroller", referenced from: _get_field_types_powpluginviewcontroller in powpluginviewcontroller.o _get_field_types_powplugin in powplugin.o ld: symbol(s) not found architecture x86_64 clang: error: linker command failed exit code 1 (use -v see invocation) i have cleaned build folder. have created , added import statements project name-bridging-swift.h . here @ project. codapluginscontroller.h you can find file here. https://github.com/panicinc/codapluginkit/tree/master/cocoa%20plug-ins discription: this header provides protocols , facilities implement coda text-based, syntax validator , sidebar plug-in. codapow-bridging-header.h // // use file import target's public headers expose swift. // #import "codapluginscontroller.h" powplugin.swift import foundation class powplugin: nsobject, codaplugin, cod

S3 and Paperclip with Heroku for a Rails app - migrations not running on production -

i set app upload pictures directly s3 user class. locally, working fine. added attribute user class called avatar . in rails console, when call user.last.avatar.url s3 url picture uploaded. when pushed changes heroku, though, tried running migrations nothing happened, , obviously, in heroku console, method error when run user.last.avatar.url not sure or happened. have 1 bucket don't think that's why migrations aren't running. edit : here's migration class addavatartousers < activerecord::migration def self.up add_attachment :users, :avatar end def self.down remove_attachment :users, :avatar end end

Twilio voicemail - Get a call back if caller hangs up before recording starts -

question implementing voicemail in twilio. how can call if caller hangs before recording starts? more info after incoming call's <dial> times out, call url responds this: <response> <say>please leave message.</say> <record playbeep="true" action="http://..." /> </response> the issue seem having if caller hangs while <say> verb executing, <record> verb never executes , application never receives call back. is possible receive call under circumstance? if so, how make happen? twilio evangelist here. one idea might separate twiml response 2 separate responses , track last step in workflow sent call was. first send say: <response> <say>please leave message.</say> <redirect>http://example.com/record</redirect> </response> then redirect record: <response> <record playbeep="true" action="http://..." /&g

java - how to stop a running async task? -

this question has answer here: stop asynctask doinbackground method 1 answer i running async task in android ping t particular url problem when url not valid or not reachable exception occurs sockettimeoutexception on exception want stop running task. iagve tried using cancel() method causes app crash. i using following code. private class urldataprovider3 extends asynctask<string, void, string> { string ret=""; int checkstatus; boolean exception=false; @override protected string doinbackground(string... url) { httpurlconnection con = null; try { log.i("rae", "urldata"+url[0]); httpurlconnection.setfollowredirects(true); con = (httpurlconnection) new url(url[0]).openconnection(); con.setrequestmethod("post")

angularjs - Angular Unit Testing - Mocking methods/closures in same service -

Image
i'm trying unit test angular service using sinonjs , have been running issue , hoping possibly shed light on why occurring. have reconstructed current project illustrate problem @ hand. i have provided demo i have service, peopleservice : (function (){ angular.module('myapp') .factory('peopleservice', peopleservice); peopleservice.$inject = ['$q']; function peopleservice ($q){ var people = ['homer', 'marge', 'bart', 'lisa', 'maggie']; // in actual project, makes http request function getfamily () { return people; } function getadults (){ var family = getfamily(); return family.filter(function (person){ return person === 'homer' || person === 'marge'; }); } return { getfamily: getfamily, getadults: getadults } } }()); in service, method getadults uses getfamily

php - How do I merge data into Multidimentional array based on a value in current/previous array -

i building phone statistics , have output below need merge same src , add duration together. example array index 0 through 6 merge 1 array following: [0] => array ( [calldate] => 2014-12-01 08:31:47 [src] => 1234 [duration] => 190 ) you're thinking shouldn't index 0 through 8 because index 6 10 seconds signifies call answered. can assumed if call duration 30 seconds has not been answered. it's not simple finding src match in array , adding durations though see in index 11 9123 calls , answered within 12 seconds call around 30 minutes later , second call @ 9:55:31 answered within 15 seconds, need to separate items in final array. the src's fictional , not numbers in real world. array ( [0] => array ( [calldate] => 2014-12-01 08:31:47 [src] => 1234 [duration] => 30 ) [1] => array ( [calldate] => 2014-12-01 08:32:22 [src] => 1234 [duration] => 30 ) [2] => array ( [calldate] => 2014-12-01 08:32:57 [s

c - How to determine if a dictionary contains a value? -

i'm working abstract data types in c , hoping me. how go figuring out if dictionary contains value? know how find key using containskey(), how same looking value? thanks~~ since value can in dictionary, way detect whether value in dictionary iterate on entries of dictionary until find or reach end of dictionary.

ios - view controller initilization -

usually view controller initialized in application delegate this: - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { self.window = [[uiwindow alloc] initwithframe:[[uiscreen mainscreen] bounds]]; // override point customization after application launch testviewcontroller *vc = [[testviewcontroller alloc] **init**]; self.window.rootviewcontroller = vc; return yes; } but vc implement initialization method - (instancetype)initwithnibname: . how init call initwithnibname: ? call sequence? if @ default implementation, calls superclass's version: - (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil { self = [super initwithnibname:nibnameornil bundle:nibbundleornil]; if (self) { // custom initialization } return self; } implementing initwithnibname not required, since default init method call super implementation of initwit

Upload and download file to Amazon from android application -

i want upload file amazon android application. have downloaded aws sdk , added build path of project. want upload file bucket.which created. how can upload file, not getting proper solution it. please , provide suggestions. in advance i suggest taking @ our getting started guide s3 , looking transfermanager meant high level utility handling uploads/downloads http://docs.aws.amazon.com/mobile/sdkforandroid/developerguide/s3transfermanager.html

json - change structure of an object javascript -

i want change structure of object javascript, example: i have structure : obj = { "email": "abc@site.com", "societe.name": "xyz" } and want change : obj = { "email": "abc@site.com", "societe": { "name": "xyz" } } thank's help. try this: var obj = { "email": "abc@site.com", "societe.name": "xyz" }; var newobj = {}; var keys = object.keys(obj); (var = 0; < keys.length ; i++) { var key = keys[i]; // can change '.name' if want specific if (key.indexof('.') > -1) { var splitted = key.split('.'); var innerobj = {}; innerobj[splitted[1]] = obj[key]; newobj[splitted[0]] = innerobj; } else { newobj[key] = obj[key]; } } console.log(newobj); jsfiddle .

java - sockettimeoutexception causing app hang -

i trying ping server in asynk task getting sockettimeout exception when enter invalid port number causes app hang. post method of asynk task never called & app not respond may know why happening. using following code purpose. private class urldataprovider3 extends asynctask<string, void, string> { string ret=""; int checkstatus; boolean exception=false; @override protected string doinbackground(string... url) { httpurlconnection con = null; try { log.i("rae", "urldata"+url[0]); httpurlconnection.setfollowredirects(true); con = (httpurlconnection) new url(url[0]).openconnection(); con.setrequestmethod("post"); con.setconnecttimeout(20000); } catch (ioexception e) { if(e.tostring().contains("java.net.sockettimeoutexception:")) {

android - Merging two listviews one above another with a common scroll -

Image
i working on application in have taken account 2 listviews 1 above , common scroll. know not best practice, instead should have taken single listview problem layouts doesn't seem possible sinlge listview. first listview contain list of friend requests can accept or ignore , not static , can vary no limit , second list contain friends may vary i.e not static. if have show these 2 things, should have preferred single listview , can done actual problem arises when have add alphabetical sorting of second list i.e friends list using side bar , applicable second list not first one. 1 screenshot without side bar but alphabetical side bar there new connections. don't think, can possible single list since alphabetical side bar added whole list not part of list. right trying save myself using scrollview 2 listviews since expensive. need best way how go type of structure. should take 2 listview inside scrollview or can done single listview more preferred. please pour suggestions

blackberry and android apps -

i'm curious know how blackberry company let's blackberry os install apk package , app runs built run on blackberry. i've been looking information on how can't find relevant. maybe there kind of compatibility layer built in os let android apps run? i thought i'd ask think it's pretty neat how works. the compatability layer built os. qnx , android on arm use same system call syemantics. bb10 system calls able distinquish origin of call (qnx or android) , provide appropriate service. introduced in 10.2.

ruby on rails - Listing user gender options in a view -

i seeking populate select list in form options user gender. have learning rails book uses similar approach credit card options creating array in model , referencing in view. unfortunayely when use approach receive error referencing line in view stating: "uninitialized constant gender_options" class user < activerecord::base # include default devise modules. others available are: # :confirmable, :lockable, :timeoutable , :omniauthable devise :database_authenticatable, :registerable, :confirmable, :recoverable, :rememberable, :trackable, :validatable gender_options = { "male" => :true, "female" => :false, "unspecified" => :nil} has_many :discussions has_many :comments end <div> <%= f.label :gender %><br /> <%= f.select :gender, user::gender_options​ %> </div> try using helper , locale. # app/helpers/application_helper.rb def gender_lists i18n.t(:gender_lists

Java - Jackson nested arrays -

given following data { "version" : 1, "data" : [ [1,2,3], [4.5,6]] } i tried following definitions , used objectmapper.readvalue(jsonstring, outer.class) class outer { public int version; public list<inner> data } class inner { public list<integer> intlist; } i got: can not deserialize instance of inner out of start_array token" in outer class, if list<list<integer> data; then deserialization works. but in code, outer , inner classes have business logic related methods , want retain class stucture. i understand issue jackson unable map inner array 'inner' class. have use tree model in jackson? or there someway can still use datamodel here ? jackson needs know how create inner instance array of ints. cleanest way declare corresponding constructor , mark the @jsoncreator annotation. here example: public class jacksonintarray { static final string json = "{ \"versio

java - How to replace the special characters from input string in map reduce program -

i able replace special characters in normal java program. this java code: public class { public static void main(string[] args) { string s = "this785($^#')\""; system.out.println(s); s=s.replaceall("[^\\w\\s]", ""); system.out.println(s); } but trying same in map reduce program not working public static class map extends mapreducebase implements mapper<longwritable, text, text, intwritable> { @override public void map(longwritable key, text value, outputcollector<text, intwritable> output, reporter reporter) throws ioexception { string s = value.tostring().replaceall("\\w+\\s+",""); string[] words=s.split(" "); for(string a:words){ output.collect(new text(a),new intwritable(1)); } } sample input map reduce program "this@#$ is$# word$%^ (count)" "this@#$ is$# word$%^ (count)"

c++ - String.erase giving out_of_range exception -

i meant write program read text text file , erase given words. unfortunately, something's wrong particular part of code, following exception notification: this text sample, based on other textterminate called after throwing instance of 'std::out_of_range' what<>: basic_string_erase i guess there wrong way use erase, i'm trying to use do while loop, determine beginning of word meant erased every time loop done , erase text begins @ beginning of word meant erased , end of - i'm using length. #include <iostream> #include <string> using namespace std; void erasestring(string &str1, string &str2) // str1 - text, str2 - phrase { size_t positionofphrase = str1.find(str2); if(positionofphrase == string::npos) { cout <<"phrase hasn't been found... @ all"<< endl; } else { do{ positionofphrase = str1.find(str2, positionofphrase + str2.size()); str1.erase(pos

php - change database name in Zend Framework -

i'm newbie on zend framework, i've declared database configure : resources.db.params.host = 'localhost' resources.db.params.username = 'root' resources.db.params.password = '' resources.db.params.dbname = 'zftutorial' i created pages through this, want change database name ,how not change multiple databases , using 1 database ? are changing dbname in [production] , [staging : production] , [testing : production] , [development : production] ?

wampserver - WAMP: Fatal error: Call to undefined function mb_detect_encoding() .... When going to localhost/phpmyadmin -

i have enabled mbstring extension removing ';': extension=php_mbstring.dll i using correct php.ini file, checked using phpinfo(). extension dir specified in php.ini: extension_dir = "c:/wamp/bin/php/php5.5.12/ext/" indeed, when go there, find 'php_mbstring.dll' i've restarted wamp multiple times. what else can wrong here? update: seems, whole wamp installation fd respect mysql: your php installation appears missing mysql extension required wordpress. i have mysql installed , though...module enabled etc. this sounds have rouge php.ini file somewhere , loading wrong one. there 2 php.ini files in wampserver in php/apache installations. one called \wamp\bin\php\{phpversion}\php.ini , used php cli the other called \wamp\bin\php\{phpversion}\phpforapache.ini , used when running php through apache. if use wampmanager menus edit 1 used apache/php i.e. wampmanager => php -> php.ini however if have edited correct php.

iron router - Meteor Route.go() is keeping all the previous JS code -

i noticed when route.go() in meteor, keeps of previous page's template handlers/events/render js code. for example, on previous page before route.go(), had setinterval(...) running @ every x seconds. after route.go(), setinterval continued fire, because required elements no longer there, kept generating errors. is design? how can route , start fresh? note: true clicking link well, since technically that's route (if link created route) using router.go not analogous clicking hyperlink or issuing server-side redirect. it's common expect route.go act non-bound hyperlink (i.e. physically issue new request), or issue server-side 301, that's not how iron router works. it handle route within current loaded window environment , typically making use of html5 pushstate swap out url handle route internal meteor. this means existing setintervals or other "global" events continue run unless stop handler explicitly.

c# - how to get textbox value in gridview using javascript -

i want textbox value within gridview using javascript. can't find out value. asp.net page.how can "txtgridname" value update button onclientclick? asp.net code here : <columns> <asp:templatefield headertext="s.no"> <itemtemplate> <%#container.dataitemindex+1 %> </itemtemplate> </asp:templatefield> <asp:templatefield headertext="unit std"> <edititemtemplate> <%--<asp:textbox id="txtloceditname" width="100%" runat="server" text='<%#(eval("loc_name").tostring()) %>' />--%> <asp:dropdownlist id="drpgridunitstd" runat="server" text='<%#(eval("uom_standard").tostring()) %>'> <asp:listitem text="a" value="a"></asp:listitem>