Posts

Showing posts from July, 2012

class - Dynamically create objects in c++? -

take @ code, has class that, when new object created, give random number 'lvl' between 1 , 100. after class, define objects using class instances. #include <iostream> #include <cstdlib> using namespace std; int main() { class newpokemon { public: int lvl; newpokemon() { lvl = (rand() % 100 + 1); }; void getlevel() { cout << lvl << endl; }; }; newpokemon gengar; newpokemon ghastly; newpokemon ayylmao; }; what want next allow use define new pokemon (objects) asking them name. means, however, need create objects dynamically. example, program asks user name name saved object class newpokemon program can use name run other functions class, getlevel. how able this? i, of course, can't hard coded ones, cannot reference user input variable name, there way asking manipulating pointers or something? use std::map ...

javascript - AngularJS: Checking the radio button and added a new partial at the end -

i have been using angularjs while now. have radio button gives users option , json data has value of correct answers. want check number of correct answers user has provided(after user clicks 'submit button') , display @ end of test. how achieve it? controllers.js var testcontrollers = angular.module('testcontrollers', []); testcontrollers.controller('ansacontroller', ['$scope', function($scope) { $scope.check = function check(){ alert("he"); }; }]); testcontrollers.controller('listcontroller', ['$scope', '$http', function($scope, $http) { $http.get('js/data.json').success(function(data) { $scope.questions = data; $scope.artistorder = 'name'; }); }]); testcontrollers.controller('detailscontroller', ['$scope', '$http','$routeparams' ,function($scope, $http, $routeparams) { $http.get('js/data.json').success(function(data) { $scope....

Java Split regex -

given string s, find number of words in string. problem word defined string of 1 or more english letters. note: space or of special characters ![,?.\_'@+] act delimiter. input format: string contain lower case english letters, upper case english letters, spaces, , these special characters: ![,?._'@+]. output format: on first line, print number of words in string. words don't need unique. then, print each word in separate line. my code: scanner sc = new scanner(system.in); string str = sc.nextline(); string regex = "( |!|[|,|?|.|_|'|@|+|]|\\\\)+"; string[] arr = str.split(regex); system.out.println(arr.length); for(int = 0; < arr.length; i++) system.out.println(arr[i]); when submit code, works on half of test cases. not know test cases are. i'm asking murphy's law. situations regex implemented won't work? you don't escape special characters in regex. let's start []...

arrays - Find the indices of the lowest closest neighbors between two lists in python -

given 2 numpy arrays of unequal size: (a presorted dataset) , b (a list of query values). want find closest "lower" neighbor in array each element of array b. example code below: import numpy np = np.array([0.456, 2.0, 2.948, 3.0, 7.0, 12.132]) #pre-sorted dataset b = np.array([1.1, 1.9, 2.1, 5.0, 7.0]) #query values, not sorted print a.searchsorted(b) # result: [1 1 2 4 4] # desired: [0 0 1 3 4] in example, b[0]'s closest neighbors a[0] , a[1]. closest a[1], why searchsorted returns index 1 match, want lower neighbor @ index 0. same b[1:4], , b[4] should matched a[4] because both values identical. i clunky this: desired = [] b in b: id = -1 in a: if > b: if id == -1: desired.append(0) else: desired.append(id) break id+=1 print desired # result: [0, 0, 1, 3, 4] but there's gotta prettier more concise way write numpy. i'd keep solution in numpy because i...

html - Rotating links when submit button is clicked -

i want know if there way have submit button in form redirect different links every time clicked depending on person selected. example: form have name, email, , how did hear drop down of numerous options , submit button. if person picked option 1 once submit button clicked redirect link 1. when person comes , pick option 1 redirect link 2. when person comes , pick option 1 again redirect link 1 , on. need possible options in drop down , email addresses recorded me see @ later time. possible? sorry new this. you can this html <form action="./hi_friend.php" method="post" id="countform"> <select name="sellist" id="sellist"> <option value="1">first</option> <option value="2">second</option> <option value="3">last</option> </select> <input type="submit" value="submit"> </form> js $('#countform...

java - javax.net.ssl.SSLException: Received fatal alert: unexpected_message -

encountered sslexception when using curl hit java web service: javax.net.ssl.sslexception: received fatal alert: unexpected_message @ sun.security.ssl.alerts.getsslexception(alerts.java:208) ~[na:1.8.0_65] @ sun.security.ssl.sslengineimpl.fatal(sslengineimpl.java:1666) ~[na:1.8.0_65] @ sun.security.ssl.sslengineimpl.fatal(sslengineimpl.java:1634) ~[na:1.8.0_65] @ sun.security.ssl.sslengineimpl.recvalert(sslengineimpl.java:1800) ~[na:1.8.0_65] @ sun.security.ssl.sslengineimpl.readrecord(sslengineimpl.java:1083) ~[na:1.8.0_65] @ sun.security.ssl.sslengineimpl.readnetrecord(sslengineimpl.java:907) ~[na:1.8.0_65] @ sun.security.ssl.sslengineimpl.unwrap(sslengineimpl.java:781) ~[na:1.8.0_65] @ javax.net.ssl.sslengine.unwrap(sslengine.java:624) ~[na:1.8.0_65] @ org.jboss.netty.handler.ssl.sslhandler.unwrap(sslhandler.java:1225) ~[netty-3.6.6.final.jar:na] @ org.jboss.netty.handler.ssl.sslhandler.decode(sslhandler.java:913) ~[netty-3.6.6.final.jar...

ios - Section header persists even after removing section data and reloading UICollectionView -

after removing last item in section, goal remove entire section, including header, uicollectionview. unfortunately, section header persists though there no section in underlying data model. refreshing view -- popping navigation stack , navigating view -- correctly shows uicollectionview section header removed. in test case, there 1 section uicollectionview should become blank after removing final item. suggestions? func numberofsectionsincollectionview(collectionview: uicollectionview) -> int { print("# sections: \(user.getsections().count)") return user.getsections().count } // delete item let indexpath = view.indexpathsforselecteditems()![0] let section = user.getsections()[indexpath.section] user.removeitemat(section, index: indexpath.row) view.deleteitemsatindexpaths([indexpath]) // update 1 section or entire view if (section.getnumitems() > 0) { view.reloadsections(nsindexset(index: indexpath.section)) ...

java - Why is File::listFiles faster than DirectoryStream - accepting only directories -

so "heard" directorystream introduced in java 7 faster traditional methods of directory listing. however, not case me. might have been faster listing whole directory, when filtering out files , accepting folders, takes far more time. instance, these codes: using file : arraylist<file> temparray = new arraylist(); (file file : somefile.listfiles()){ if(!file.isdirectory()) continue; temparray.add(file); } using directorystream : directorystream<path> stream = null; try { stream = files.newdirectorystream(dir, new directorystream.filter<path>() { public boolean accept(path file) throws ioexception { return files.isdirectory(file); } }); } catch (ioexception ex) { } arraylist<file> files = new arraylist(); (path path : stream) files.add(path.tofile()); stream.close(); the second method (using directorystream) more slower. know both methods check each , every file see i...

python - How to average columns in a data frame based on grouping of another dataframe -

i have 2 csv data looks this: gene,stem1,stem2,stem3,b1,b2,b3,t1 foo,20,10,11,23,22,79,3 bar,17,13,505,12,13,88,1 qui,17,13,5,12,13,88,3 and this: celltype,phenotype sc,stem1 bc,b2 sc,stem2 sc,stem3 bc,b1 tc,t1 bc,b3 the data frame this: in [5]: import pandas pd in [7]: main_df = pd.read_table("http://dpaste.com/2mrrrm3.txt", sep=",") in [8]: main_df out[8]: gene stem1 stem2 stem3 b1 b2 b3 t1 0 foo 20 10 11 23 22 79 3 1 bar 17 13 505 12 13 88 1 2 qui 17 13 5 12 13 88 3 in [11]: source_df = pd.read_table("http://dpaste.com/091pne5.txt", sep=",") in [12]: source_df out[12]: celltype phenotype 0 sc stem1 1 bc b2 2 sc stem2 3 sc stem3 4 bc b1 5 tc t1 6 bc b3 what want average every column in main_df based on grouping in source_df . looks in end: sc ...

postgresql - Use geometry data type in dynamic query -

i creating function in postgresql postgis accept tables name , geometry of point , want use them in query inside function...... create or replace function trial(tbl text[],tag text[],geo geometry) returns boolean $body$ declare integer; declare len integer; declare result boolean; declare bool boolean; begin result=true; select array_length(tbl,1) len; in 1..len loop execute format('select st_dwithin(geo::geography,geom::geography,1) %s name=any(array[%s]) , st_dwithin(geo::geography,geom::geography,1)=true',tbl[i],tag[i]) bool; if (bool!=true) result=false; exit; end if; end loop; return result; end; $body$ language plpgsql volatile cost 100; this shows me error as line 1: select st_dwithin(geo::geography,geom::geography,1) grn... when use %s geometry i next error error: syntax error @ or near "aa40e9a0e5440f498329474092a40" line 1: select st_dwithin(0101000020e6100000002aa40e9a0e5440f...

How to access arrays from other class in Java? -

i need in accessing array different class can change values in different class. public class a320ticketorderflorida extends javax.swing.jframe { static boolean a320floridabusinessa[]=new boolean [6]; static boolean a320floridabusinessc[]=new boolean [6]; static boolean a320floridabusinessd[]=new boolean [6]; static boolean a320floridabusinessf[]=new boolean [6]; static boolean a320floridacoacha[]=new boolean [32]; static boolean a320floridacoachb[]=new boolean [32]; static boolean a320floridacoachc[]=new boolean [32]; static boolean a320floridacoachd[]=new boolean [32]; static boolean a320floridacoache[]=new boolean [32]; static boolean a320floridacoachf[]=new boolean [32]; how can access arrays in class ticketrefund.java class change values of array? the simplest solution make arrays public, such public static boolean a320floridabusinessa[] = new boolean[6]; then access writing a320ticketorderflorida.a320floridabusinessa h...

android - how to set set max counter and change TextView if max value is reached -

if value of counter more maxcount textview change. code. hope understand mean. thx. int counter = 0; int maxcount = 5; textview txtcount, txtresult; private vibrator mvibrator; protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.tasbih); img = (imageview) findviewbyid(r.id.img_btn); img.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { mvibrator.vibrate(700); counter ++; txtcount.settext(integer.tostring(counter)); (int = 0; < maxcount; i++ ){ if (counter >= maxcount) { txtresult.settext("text 2"); counter = 0; break; }else if (counter >= maxcount){ txtresult.settext("text 3"); toast.maketext(mainactivity.class, "done!!!", toast.l...

java - Differentiate between .csv and false .csv -

i have method uploads csv file. works fine when work normal csv file. the problems comes when reads file (say, pdf) renamed .csv file extension , doesn't throw exception. can me in differentiating bona fide csv file , "fake" csv file .csv file extension? update following comment: here code: csvreader csvreader = new csvreader(); arraylist <arraylist<string>> arrdata=null; string path="c:/users/avinash/desktop/asset.csv"; arrdata=csvreader.readcsv(path,printinconsole); the above code works fine if asset.csv real csv file. other format file (say asset.pdf ) renamed asset.csv , doesn't throw exception reads junk values. can in differentiating these 2 different file types? i tried jmimemagic fails give correct mime type of spreadsheets open office. how differentiate bona fide csv file , "fake" csv file .csv file extension? you can not in straight forward way, since each file can interpreted csv file...

ios - Create left navigation bar - Swift -

i want create left navigation bar in swift. have table view navigation options. when user swipes left, want navigation bar appear , take 1/3 of screen. remaining 2/3 of screen displaying current view user on. any appreciated. thanks. if want create own side-menu/hamburger view in swift, can refer blog or tutorials like: http://www.appcoda.com/sidebar-menu-swift/ and if want use third party, there lot of them available on cocoacontrols.com

jms - Mixing protocols while using Apache ActiveMQ -

i exploring activemq advanced messaging between heterogeneous applications based on different technologies - c, java, ruby , python. while looking @ supported protocols stumbled understand use case of mixing protocols while performing message exchange. had searched activemq documentation unable find such reference talking this. my question is, - producer ( newspublisher ) publishing news( sports, finance, world ) topic ( newstopic ) using amqp. after publishing, topic storing these news under respective queues ( sports, finance , world queues ) in situation, client subscribed sports queue jms based, client subscribed finance queue stomp based; can these clients able receive message available on queue published using amqp newpublisher ? i see related question posted earlier found answers unrelated original question thought double check. mixing protocols in activemq not hard, broker takes care of internal routing , converting of messages incoming protocol outgoing bi...

javascript - How to execute method on listbox item select asp.net -

need select item listbox , on select method executed load_data() , data loaded , displayed instead after page gets refreshed , again value displayed set default . autopostback property true . should ? protected void listbox1_selectedindexchanged1(object sender, eventargs e) { load_data(listbox1.selecteditem.text); } if databinding listbox in page_load method, make sure databind when it's not postback this... protected void page_load(object sender, eventargs e) { if (!page.ispostback) { // initial databind listbox here (where default data loaded) } } you can still keep selectedindexchanged event protected void listbox1_selectedindexchanged1(object sender, eventargs e) { load_data(listbox1.selecteditem.text); }

xslt - IBM Integration Bus XSL Transform node not generating XML -

i pretty new iib. creating mediation service on ibm integration bus 10. first node soap node , second node xsl transform. complete flow of service xsl transform working fine soap input when test in different tool. fails here when testing soapui. after transform node, getting output without xml tags (all values appended in single string) i have no clue why happening. appreciated. i getting output without xml tags (all values appended in single string) iib not assume output of xsltransform node xml. xsl stylesheet can output formatted text. must set 'domain' property in 'output message parsing' section of xsltransform node. set xmlnsc, obviously. first node soap node , second node xsl transform is there particular reason why have chosen use xsltransform node? mapping node or compute node perform better, , more maintainable xsl (unless doing genuinely complex transformations in xsl).

ios - Editing locked files from a CocoaPods framework -

i have xcode workspace uses cocoapods include several third-party frameworks. edit line of source code within 1 of these dependencies. however, when so, xcode warns me file locked , changes make may not saved. question is: changes source code discarded when run pod install/update? if not, there other scenario, possibly unrelated cocoapods, discard changes? , finally, there way can edit source code without running such problems? thanks in advance. you can not make changes in original pod file. if want add more features have fork particular repo. follow steps : find library want use on git. fork library. update podfile refer forked version. suppose want fork gpuimage library. point fork in podfile given. pod 'gpuimage', :git => ' https://github.com/username/gpuimage.git ' make changes. commit/push changes forked repo. submit pull request original author of library. if pull request accepted , pod updated, revert podfile use public...

c++ - Libraries or algorithms for blob detection in stereo images -

i looking way detect blobs in stereo-images have not been able find yet. want detect objects example people standing in front of camera , cut object out continue processing on blob without background. know libraries or algorithms blob detection / tracking in stereo images? if can expect background static relative foreground try opencv background subtractor . there 2 versions based on modelling each pixel mixture of gaussians, constructing background model distributions persist longest (i.e. static). pixels can labeled foreground when values shift beyond threshold learned background distribution.

database - Mysql partition - How to do list partitioning of a table that contains unique column? -

i doing mysql list partitioning. table data below ---------------------------------------- id | unique_token | city | student_name | ---------------------------------------- 1 | xyz |mumbai| sanjay | ----------------------------------------- 2 | abc |mumbai| vijay | ---------------------------------------- 3 | def | pune | ajay | ---------------------------------------- in above table unique_token column has unique key , want list partitioning city column. per mysql documentation every partition column must part of every unique key of table , hence in order list partitioning city column have create new unique key unique_key(unique_token,city) . now issue unique_token column should unique , if insert 2 rows in table ('xyz','banglore') , ('xyz','pune') these rows inserted table unique_token column won't unique @ all. i want know how list partitioning on table without having duplicate data...

ios - Crash issue in ad-hoc build while drawing -

i'm facing crash issue in following code (only in ad-hoc build). - (void)drawpreviewinrect:(cgrect)rect { cgcontextref context = uigraphicsgetcurrentcontext(); cgcontextsavegstate(context); cgcolorref strokecolor = [self.delegate.strokecolor cgcolor]; cgfloat strokewidth = self.delegate.strokewidth; cgfloat x = rect.size.width/2.0f; cgfloat y = rect.size.height/2.0f; cgpoint strokepoint = cgpointmake(x, y); cgcontextsetlinecap(context, kcglinecapround); cgcontextsetlinewidth(context, strokewidth); cgcontextsetstrokecolorwithcolor(context, strokecolor); cgcontextmovetopoint(context, strokepoint.x, strokepoint.y); cgcontextaddlinetopoint(context, strokepoint.x, strokepoint.y); cgcontextstrokepath(context); cgcontextrestoregstate(context); } the crash log shows following picture: exception type: exc_bad_access (sigsegv) exception codes: kern_invalid_address @ 0x10000008 crashed thread: 0 thread 0 name: dispatch...

Java Properties - int becomes null -

whilst i've seen similar looking questions asked before, accepted answers have seemingly provided answer different question (imo). i have joined company , before make changes/fixes, want ensure tests pass. i've fixed one, i've discovered due (to me) unexpected behavior in java. if insert key/value pair properties object value int, expected autoboxing come play , getproperty return string. however, that's not what's occuring (jdk1.6) - null. have written test class below: import java.util.*; public class hacking { public static void main(string[] args) { properties p = new properties(); p.put("key 1", 1); p.put("key 2", "1"); string s; s = p.getproperty("key 1"); system.err.println("first key: " + s); s = p.getproperty("key 2"); system.err.println("second key: " + s); } } and output of is: c:\development\...

git - How to publish project on github-pages without committing the same files twice? -

i have several simple html/css/js projects (one page, no backend) , want publish on project github pages. what best way it? possible without commiting same files twice master , gh-pages branches when want update something? i commit gh-pages think not ideal solution because have files not related site content , should in master, such readme. committed master . if you're not using github.io page, gh-pages branch right answer. leave readme in master , gh-pages website in latter.

c++ - C++11 Avoiding Redundant Return Type in specific Situation -

ok, has looked @ this. i've recreated exact scenario easy viewing @ link below, i'll comment out original text had wasn't clear. http://cpp.sh/5lp4l in comment section show calling make_some(32, std::string{"hi"}) without specifying data type declaration call. realize seems insane , way above expected use case, automatically inferring composite type (inferring wanted data, based on int/string) based on arguments wasn't necessary, or idea. the compiler right. there's no relation given between t , args . hence, cannot determine queryresult<t> means. what apparently expect return type of somefn forces t int, int . that's not possible 2 reasons: t denotes single type, , there's no mechanism return statement somehow affects template instantiation of make_some .

python - Multiprocessing and global True/False variable -

i'm struggling head around multiprocessing , passing global true/false variable function. after get_data() finishes want analysis() function start , process data, while fetch() continues running. how can make work? tia import multiprocessing ready = false def fetch(): global ready get_data() ready = true return def analysis(): analyse_data() if __name__ == '__main__': p1 = multiprocessing.process(target=fetch) p2 = multiprocessing.process(target=analysis) p1.start() if ready: p2.start() you should run 2 processes , use shared queue exchange information between them, such signaling completion of action in 1 of processes. also, need have join() statement wait completion of processes spawn. from multiprocessing import process, queue import time def get_data(q): #do data time.sleep(2) #put event in queue signal get_data has finished q.put('message get_data analyse_data') def analyse_data(q)...

Uncaught syntax error: ) missing after argument list in asp.net mvc application javascript -

i have researched on why "uncaught syntax error: ) missing after argument list" error , went through code throughly, after reading few answers on stack overflow. i've been on more day, yet error still persist. please help. my code function openinnewtab(filename) { var url = @url.action("displaydocuments", new { filename = filename }); var redirectwindow = window.open(url, '_blank'); redirectwindow.location.reload(true); return false; } and calling here in view, im tring tto implement onclick functionality on image when image clicked, opens new window , displays image. <a onclick="openinnewtab(@filename);"><img title="@filename" src="~/content/images/image.png"></a> basically missing single quotes , mixing js variables in razor code, code should - <a onclick="openinnewtab('@filename');"><img title="@filename" src="~/conte...

python 2.7 - Multiple Errors in Hangman program -

i've been teaching self program in python lately , decided make game. have been successful majority of except few things when incorrect letter inputted, letter appended wrong letter array many spots in gamespace array userletter equal.example: if type in "the" wordtarget, t, h , e printed 2 times wrong letter array. no matter letter gets out wrong letter array code: wordtarget = raw_input("enter word here: ").lower () gamespace = ["_"] * len(wordtarget) wrongletter = [] def main(): x in range(0, len(wordtarget)): while (gamespace[x] != wordtarget[x]): getletter() in range(0,len(wordtarget)): if (wordtarget[i] == userletter): gamespace[i] = userletter elif (wordtarget[i] != userletter): print "letter incorrect, try again" wrongletter.append(userletter) print ("incorrect letters: %s...

mysql - getting GET http://localhost:3000/load net::ER_CONNECTION_REFUSED in google chrome console -

am running node server angular js fetch data mysql database table, working absolutely fine in local system but accessing same project via simplehttp server in other machine (ubuntu os in chromium browser) http://192.168.1.4/desktop/clients/my-folder/my-file getting following error in browser console get http://localhost:3000/load net::er_connection_refused i searched lot in google did not found answers still now, please me solve issues

java - Automate Logic using Loops? -

i need automate below code snippet using loops. need max values if availpoints reaches infinite numbers how can achieve within few lines of codes if (availpoints < 500 ) { pointsmax = 500; moneymax = 25; } else if (availpoints < 1000 ) { pointsmax = 1000; moneymax = 50; } else if (availpoints < 1500 ) { pointsmax = 1500; moneymax = 75; } update: assume availpoint points user score 1 1000000(infinite too). every 500 points slot. if points enter next slot. max values pointmax has incremented 500 & moneymax 25. it not require loop. (int availpoints = 400; availpoints < 2000; availpoints += 200) { int rank = availpoints / 500; int pointsmax = (rank + 1) * 500; int moneymax = (rank + 1) * 25; system.out.printf("availpoints %d -> pointmax=%d moneymax=%d%n", availpoints, pointsmax, moneymax); } result: availpoints 400 -> pointmax=500 moneymax=25 availpoints 600 -...

java - What is the best practice for sharing models between a WEB API server and an Android client application -

i have android application talks .net server using web api web services. currently, have transfer objects on server , on client. java class public class useraction { private string username; private string action; public string getusername() { return username; } public void setusername(string username) { this.username = username; } public string getaction() { return action; } public void setaction(string action) { this.action = action; } } my c# class on server side public class useractionto { public string username { get; set; } public string action { get; set; } } i wish share these models, between 2 applications. i found question discussing sharing types situation bit different. should share types between web api service , client ? other options? i considering creating c++ dll, both android application , c# application use. best option? edit using json transfer data ...

asp.net - add video in website -

if use code don't see in firefox in chrome , explorer. idea resolve this? <embed id='embed1' runat="server" name='mediaplayer' type='application/x-mplayer2' pluginspage='http://microsoft.com/windows/mediaplayer/en/download/' displaysize='4' autosize='-1' bgcolor='darkblue' showcontrols='true' showtracker='-1' showdisplay='0' showstatusbar='-1' videoborder3d='-1' width='500' height='405' designtimesp='5311' loop='false' src="movie.mp4" /> try this: type="application/x-ms-wmp" this supports .wmv, .wma, etc. (all windows formats) and .mp4 controversial due copyright issue.. note: yes need install plug-in in browser.

javascript - Dynamically add options to a Angular chosen combo box -

the following code doesn't work: <select ui-jq='chosen' ng-model='trainer_list' multiple class="form-control" data-placeholder="select multiple trainers" ng-options='trainer.id trainer.name trainer in trainers'> </select> i took angular bootstrap theme, , i'm struggling use it. want use angular script $http({ method: 'get', url: 'http://localhost/training_system/retrieve_train.php?trainer=y' }).success(function (result) { $scope.trainers = result; }); and use in combo box, can't use static options, apparently ones working. do? update: tried solution abhilash using ng-repeat instead of ng-options, , worked first few attempts. no longer repeat it, , have empty dropbox. didn't change anything, it's no longer working. possible ui-jq incompatible angularjs? try one: <select ui-jq='chosen' ng-model='trainer_list' multiple class=...

ruby on rails - Devise confirmation link is missing domain -

devise confirmation_url producing relative url no domain such as: http://users/confirmation?confirmation_token=... i tried changing confirmation_url(@resources, :confirmation_token => @resource.confirmation_token) to confirmation_url(:confirmation_token => @resource.confirmation_token) but produces same url. upgraded devise 2.2.3 same outcome. rails 3.1.4 update: have set in production.rb: config.action_mailer.default_url_options = { :host => 'mysubdomain.mysite.com' } and tried setting before_filter set_actionmailer_host def set_actionmailer_host actionmailer::base.default_url_options[:host] = request.host_with_port end to no avail in application controller ( https://github.com/plataformatec/devise/issues/1567 ) update: occurs in both development , production. update can't understand why devise isn't using template in app/views/devise/mailer/confirmation_instructions.html.haml if edit append host manually:...

cordova - PhonegapOCRPlugin is not scanning photo -

i created phonegap/xcode project , added phonegapocrplugin dependencies. when run project, see "capture editable photo" button in screen. but after take photo of business card , use it, nothing seems happening. have i missed anything? using cordova-2.5.0rc1 . thanks. just tested , it's working on phonegap 2.5.0 the problems had 1. had remove armv7s valid architectures. 2. had add line config.xml because readme older version using cordova.plist <plugin name="com.jcesarmobile.ocrplugin" value="ocrplugin" />

java - Android: NullPointerException error -

i know dull ask answers nullpointerexception, , there similar questions out there. however, cannot find solution problem other questions. i have 2 classes: createcontactactivityl.java: passes intent of text output regexocr1.java regexocr1.java: receives text output, pass text output method within class the error occurs in regexocr1.java stated logcat: fatal exception: java.lang.runtimeexception: unable start activity componentinfo{com.example.l33902.contactmanagment1512/com.example.l33902.contactmanagment.regexocr1}: java.lang.nullpointerexception: attempt invoke virtual method 'java.lang.string android.os.bundle.getstring(java.lang.string)' on null object reference @ android.app.activitythread.performlaunchactivity(activitythread.java:3155) @ android.app.activitythread.handlelaunchactivity(activitythread.java:3263) @ android.app.activitythread.access$1000(activitythread.java:197) @ android.app.activitythread$h.handlemessage(act...

android - IBM worklight 7.1 change push notification icon -

i'm confused right now, want change push notification icon (android) , i've change push.png in res-drawable folder , add line in androidmanifest.xml: < meta-data android:name="com.parse.push.notification_icon" android:resource="@drawable/push" > but no success. still showing default worklight push notification icon ( default push notification icon ). here? fyi i'm using ibm mobile first platform 7.1 as vivin suggested in comments, should not update androidmanifest.xml new line. you need replace existing push.png own image, named push.png. all.

internet explorer - Extjs 5 , Dynamic Grid Memory leak in IE? -

we using ext js 5.1.1.451 we have dynamic grid (paginated), populated 25 rows , around 230 columns (sometimes more). following characteristics of grid: it has 5 static columns (last 2 has combobox , text field - added editor) it has checkboxmodel , cellediting plugin. (both of has rules in beforeselect , beforeedit listeners control editability) remaining 225 columns dynamically calculated json response follows. originally arnd 115 columns , based on flag decide whether make column editable. in case particular column editable, divide column 2 (example: if column name cost, name base_cost(this read-only field) , adjustable_cost(this editable field)). editable fields text field, attached cell editor. when grid loads first time, load store, , data obtained have, column header details , row data. so, first form columnhead header details, giving them editor, width, name, dataindex etc. then transformation of row data (basically give individual dataindex newly formed base_c...

http - Is ETag returned in a 304 response? -

i'm building node.js app - reguarly, once day - fetches data external web server (using " request " package). i want avoid fetching same data twice, keep track of each resource etag when first downloading ( 200 status code). then, when fetching again (next day) resource add if-none-match header saved etag in request. since suspect sometime receive 200 status code (instead of expected 304 ) remote web server if resource contents not modified, ask if should expect resource etag returned in 304 response (and how in request response...), try debug issue. please have @ appropriate rfc 2616 . the response must include following header fields: (...) etag and/or content-location, if header have been sent in 200 response same request so if etag header returned 200 ok status code must included in 304 not modified response .

jquery - Semantic UI - unobtrusively test form validity -

i have multiple form classed div s in page , i'd know if there's method can use unobtrusively test validity of each form ? each div class of form has button (with class of ok ) allows user continue through form div s. i'd disable button on page load ensure relevant data collected form s, , when form valid allow progression. i've tried adding function each form elements change calls semantic's is valid highlights each , every validity issue. this jsfiddle illustrates problem: https://jsfiddle.net/annoyingmouse/3z1wfjel/ when first name field clicked automatically shows all errors on form - want errors show when a required field has been blurred rather showing errors result of testing using is valid . anyone got ideas? this not complete solution it's small step towards one. use oninvalid , onvalid callbacks rather doing. i've modified fiddle demonstrate. the problem if, example, has valid until last element when want enab...

java - WebAppConfigurationImpl memory leak? -

about every 2-3-4 weeks have restart our development , test server gets outofmemoryerror. there 1 applicaton installed on instance using spring/hibernate. outofmemoryerror occurs while new version of application being installed via jython scripts. goes 20 times, gets outofmemoryerror. have increased max heap size 1gb result was, took more time (or app installation) until memory got full. looking @ dumps heap analyzer found following leak suspect: leak suspect 672 338 752 bytes (62,84 %) of java heap used 15 instances of java/util/weakhashmap$entry contains 14 instances of following leak suspects: - com/ibm/ws/webcontainer/webapp/webappconfigurationimpl holding 26 033 976 bytes @ 0xc7e5970 - com/ibm/ws/webcontainer/webapp/webappconfigurationimpl holding 26 136 480 bytes @ 0x832e0e8 - com/ibm/ws/webcontainer/webapp/webappconfigurationimpl holding 30 268 008 bytes @ 0x1a6fabb0 - com/ibm/ws/webcontainer/webapp/webappconfigurationimpl holding 26 059 488 bytes @ 0xf1e69e8 - com/ibm/...

emacs - org-capture date deadlines -

my projects deadline driven. want create org-capture template need input deadline date project head line once, , deadlines of subtasks in template calculated project's deadline. example. ;; org-capture template ** project %? deadline: %^{project deadline}t <- how can use prompt calculate deadlines subtasks below *** todo task 1 deadline < 5 months before project headline's prompt> *** todo task 2 deadline <1 months before project headline's prompt> i don't want prompt deadline each subtask in template since each project has 20 subtasks. is there way cache date entered in project's dead line %^{project deadline}t ?

xPages Ext Lib ViewController -

i've found interesting bit of code link implements viewcontroller in the extension library. how can programmer access class managed bean. have extension library (8.5.2) installed. com.ibm.xsp.extlib.data.viewcontroller can't resolved. may in on head here, willing take plunge. thanks, -- jeff right click on project in java perspective/package explorer view. use build path\configure build path... menu. use fourth tab order , export. tick plug-in dependencies item. access extlib classes in java code. unfortunately, class found sources not part of extlib distribution (package com.ibm.xsp.extlib.group ), won't find it.

database - How to create multiple connected search combo boxes to filter a form? -

i have form 10 columns, , 5 of them (project_phase, contract, design_dpm, amm/ucc, 1_or_2 stat) want add connected drop list combo boxes filter records , display data selected in combo boxes. i know how make multiple drop list combo boxes filter whole form based on selection of 1 value 1 column. example, "contract" combo box has options: signed, not signed. if select "signed" display records have "signed". , if filter column cancel previous filter , display records relevant selection column. but want ability filter using number of filtering options 5 columns mentioned. example, if want see records ("signed" under "contract") , in ("proposal" under "project_phase") , ("a dpm" under "design_dpm"). , after filtering want able clear filters , see records again, using form display records users. not want cascaded, might want filter using 1 column or more or all. , not want query or use basic fi...

ViewPager return type mismatch error when using android.support.v4.app.FragmentStatePagerAdapter -

i used this example of viewpager in app , solve "android.support.v13.app.fragmentstatepageradapter error: cannot resolved error" used in this post . got new "return type-mismatch error" because create() method returns com.example.screenslidepagefragment : public class screenslidepagefragment extends fragment { public static final string arg_page = "page"; private int mpagenumber; public static screenslidepagefragment create(int pagenumber) { screenslidepagefragment fragment = new screenslidepagefragment(); bundle args = new bundle(); args.putint(arg_page, pagenumber); fragment.setarguments(args); return fragment; } which not compatible should returned in getitem() method: private class screenslidepageradapter extends fragmentstatepageradapter { public screenslidepageradapter(android.support.v4.app.fragmentmanager fm) { super(fm); } @override publ...

Camel route multiple files -

how 1 pass multiple files through pojo fetches them , file component, , ftp in 1 route? i've been trying use map not sure body should have key name, should getfiles pass on multiple files in below example? if map should returned keys should map hold? from("mock:start") .to(getfiles.class) .to("file:transfer/outbound") .to("sftp:{{sftp_uri}}"); why not drop files folder, have 1 route without java? from("file:///inbound").multicast().to("file:outbound/", "sftp://");

java - Convert a JSON from one format to another? -

i have stream formatted in json, want transform format in order match application's input. example: { "id": "133880733349264", "feed": { "data": [ { "message": "message", "created_time": "2013-03-16t12:12:10+0000", "id": "133880733349264_477856435618357", "comments": { "data": [ { "message": "message", "id": "133880733349", } ] } } needs be: { "feed": { "identifier": "133880733349264" "message": "message", "created_time": "2013-03-16t12:12:10+0000", "id": "133880733349264_477856435618357", }, "comments": { "message": ...

swift - How to add two collection view cell by indexPath? -

Image
lets got 4 collection view cells : if going replace 2 collection view cell @ cell 3 , cell 4 position : as can see,cell 3 , cell 4 goes down , new cell 1 , cell 2 replace position. is there way can @ uicollectionview? i beginner @ using uicollectionview because app development full of tableview usage.so,i want learn more. any code appreciated.github repo of example more appreciated. thanks. from here took sample project collection view , did modification in per requirement. and below complete code updating collection array when user press button on view. import uikit class viewcontroller: uiviewcontroller, uicollectionviewdelegateflowlayout, uicollectionviewdatasource, customcollectionviewcelldelegate { @iboutlet weak var overlayview: uiview! @iboutlet weak var collectionview: uicollectionview! @iboutlet weak var overlaylabel: uilabel! var purchasecount:float = 0.0 //your collection view data source @ start. var cellarray...

q - IIA assumption in MNL model -

i trying conduct iia assumption test (hausman, smhsiao, suest) mnl model in stata. typed code: e.g. mlogtest, hausman; mlogtest, smhsiao; mlogtest, suest. results appeared this: "convergence not achieved". should do? grateful if me. using stata 13.

linux - How to get the list of clients connected to an NFS server within a local network? -

i have nfs server folder permissions follows. there 50 clients need connect server within same network. know what's command lookup clients accessing server server. nfs server configuration file looks this. [root@server ~]# cat /etc/exports /home/guests *(rw,sync) /india *(rw,sync) below list of shared folders [root@server ~]# showmount -e export list server.sanith.com: /india * /home/guests * for testing purpose have connected 1 client server. below output "client2" machine. [root@client2 ~]# showmount -e 192.168.1.10 export list 192.168.1.10: /india * /home/guests * [root@client2 ~]# mount -t nfs 192.168.1.10:/india /test [root@client2 ~]# mount /dev/sda2 on / type ext4 (rw) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) devpts on /dev/pts type devpts (rw,gid=5,mode=620) tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0") /dev/sda1 on /boot type ext4 (rw) /dev/sda3 on /home type ext4 ...

FATAL org.apache.hadoop.hbase.master.HMaster Unhandled exception. Starting shutdown -

i have 4 nodes centos hadoop cluster. installed cloudera manager 5.5.1. i failed start hbase master. fatal org.apache.hadoop.hbase.master.hmaster unhandled exception. starting shutdown . caused by: org.apache.hadoop.ipc.remoteexception(org.apache.hadoop.security.accesscontrolexception): permission denied: user=hbase, access=write, inode="/":hdfs:supergroup:drwxr-xr-x any thoughts? thanks

solr - Be very careful committing from the client! In fact, don’t do it -

i created solr cloud cluster 3 replicas , shards , configured external zookeeper. working fine. after period of time notice when restarted node takes long time start up. i observe in version in zookeeper on each node has huge amount of data in version-2 folder.after few days noticed nodes down .recovery fail in many cases. in application need live updates in cloud.so when user updates profile rewrite document solr commit() . is missing or live updates not right option because thousands of peoples updating profiles same time?

c - Passing a pointer to multiple functions and memory allocation in first function -

my question in context of c programming , not c++! trying pass pointer between multiple function. memory allocation should not done caller. tried small example simulate this. can seen, when pointer points struct variable defined in main function, 'working' expected. function can manipulate value in memory address when value of address passed. when function call returns , control passes on main, why pointer 'reinitialized'? can pointer somehow reflect address pointing to? how can done? here have: #include <stdio.h> #include <stdlib.h> #include <string.h> //example pass struct void pointer , void pointer struct //testing if memory allocation done callee , not caller typedef struct mystructure{ int a; char b; unsigned char c[10]; }mystruct; void func(void *var){ mystruct *s = var; s->a = 100; s->b = 'i'; strncpy(s->c,"test",5); printf("in func\n"); printf("s->...

fortran - Reading multiple files in parallel and storing them in shared variables -

i have program reads number of large files (~100s files, 120mb each) generated mpi program, can take time. each file contains variables in corresponding subdomain. want read in variables files , store them specific slice of 4 dimensional array. since takes considerable amount of time, parallelize piece of code openmp : 6 subroutine read_old_restart 7 integer :: ii 8 integer :: thread_id 9 integer :: omp_get_thread_num 10 character(len=21) :: file_name 11 12 !$omp parallel private(ii,file_name) 13 ii=0,nproc_old-1 14 if(ii < 10) 15 write(file_name,401) "input/restart_00", ii, ".out" 16 else if(ii < 100) 17 write(file_name,402) "input/restart_0" , ii, ".out" 18 else 19 write(file_name,403) "input/restart_" , ii, ".out" 20 end if 21 print...

Facebook loads page tab secure url as http -

i'm doing basic facebook app. have it's "secure page tab url" set ssl certificated url ( https://example.com/ ). said url nothing fancy, plain old html. add fb app fb page tab. sounds dead simple, right? no. instead of loading contents of https://example.com/ , i'm getting 302 nginx. according our server guy, has setup if accesses http://example.com/ , nginx 302 them https://example.com/ . leads conclude facebook loading http://example.com instead, makes no sense @ all. i'm pretty sure facebook app setup correct (tested site, iframe loaded no problems), problem must on our server side. should looking at? pointers appreciated.