Posts

Showing posts from July, 2012

mongodb - MongoLab and Elasticsearch -

my mongo database hosted @ mongolab. i'd use elasticsearch full text search engine on top of db. as understand mongodb needs run replica-set, don't have control on how database run. i'm using 500mb free plan. on top of that, i'm using scala playframework. was successful technologies , services? update: finally i'm not using mongodb anymore, , went straight elasticsearch solution. found nice cloud host providing 500mb free plan http://facetflow.com/ it useful development. i didn't find satisfying scala library es, therefore i'm using dispatch , make direct http requests es instance. i hope find useful. just quick note ... mongohq has oplog support mongodb elastic deployments ... using elastic search , river. http://blog.mongohq.com/elastic-deployments-now-with-oplog-access/

javascript - Sync file system API in the web -

i have chrome packaged app saves files chrome.syncfilesystem api. want develop web app , fetch these files web. there way this. thanks. you can use google drive api access google drive, , find files there. can discover location empirically, but, not documented, change @ time. google , others (e.g., apple) have habit of moving formerly-easily-visible files obfuscated places. to started, access google drive ui (web page or chrome app), , you'll find synced files. may have hunt around bit links on left of google drive web page.

ascii - Error trying to install argh-0.24.1 Python 3.2 -

i'm trying install argh-0.24.1 via pip on mac os x mavericks i'm getting ascii decode error. here traceback: eos87@local ~> pip install argh downloading/unpacking argh downloading argh-0.24.1.tar.gz running setup.py egg_info package argh traceback (most recent call last): file "<string>", line 16, in <module> file "/users/eos87/.virtualenvs/myenv/lib/python3.2/encodings/ascii.py", line 26, in decode return codecs.ascii_decode(input, self.errors)[0] unicodedecodeerror: 'ascii' codec can't decode byte 0xc2 in position 55: ordinal not in range(128) complete output command python setup.py egg_info: traceback (most recent call last): file "<string>", line 16, in <module> file "/users/eos87/.virtualenvs/myenv/lib/python3.2/encodings/ascii.py", line 26, in decode return codecs.ascii_decode(input, self.errors)[0] unicodedecodeerror: 'asci

javascript - Could not make json data on spring 3.2 and got an error (Page not found 404) -

i trying select data database using sprng 3.2, mybatis , want receive data formatted json. i put jackson-core-asl, jackson-core-lgpl , jackson-mapper-asl(1.9.13) in pom.xml when send request server, got error "http status 404 - /web-inf/jsp/listjson.jsp" . wonder why configuration file doesn't work @responsebody. i googled lot still have error. doesn't work on spring 3.2? when put below instead of <mvc:annotation-driven /> works well. know annotationmethodhandleradapter deprecated on spring 3.2. <beans:bean class="org.springframework.web.servlet.mvc.annotation.annotationmethodhandleradapter"> <beans:property name="messageconverters"> <beans:list> <beans:bean class="org.springframework.http.converter.json.mappingjacksonhttpmessageconverter" /> </beans:list> </beans:property> servlet-context.xml <mvc:annotation-driven /> <bean class="

How can i pass values from two html pages to php? -

i have 2 html pages : page1.html <html> <body> <form action="page2.html" method="post"> enter first name: <input type="text" id="text1"> <input type="submit" value="next"> </form> </body> </html> page2.html <html> <body> <form action="test.php" method="post"> enter last name: <input type="text" id="text2"> <input type="submit" value="submit"> </form> </body> </html> now, retrieve value of text1 page1.html , text2 page2.html. how can go it? looks looking forms. see tutorial http://www.w3schools.com/php/php_forms.asp . post form data page1.php page2.php. on page2.html can access them via $_post. please aware: not secure example, showing purposes! when want show user generated data in frontend, please use sanitizing , validation http://ww

Run CELERY as Daemon in Ubuntu -

how run celery daemon service in ubuntu instead of running " celery -a projname worker -l info " command each time. i using celery 3.1.8 version.... you can make celery daemon init.d script celery's repo (save /etc/init.d/ ). need create configuration file script load in /etc/default/celeryd . here's full celery doc .

c# - Search From Textbox and highlight GridView according session in Asp.net -

hey guys trying search textbox text changed evet , highlight gridview using session .. i have tables in database in rows showroomid, customer_name , pendriveno there. showroom id showrrom login have stored session["user"] . i want when search textbox ,i want particular sessions data should displayed if login showroom id 'hero' row data should displayed on searching text box . i have tried code protected void textbox1_textchanged(object sender, eventargs e) { sqlconnection con1 = new sqlconnection(configurationmanager.connectionstrings["connectionstring"].connectionstring); sqlcommand cmd1; sqldataadapter da1; dataset ds1; cmd1 = new sqlcommand("select * tblshowroom showroomid='"+session["users"]+"' , customer_name like'" + textbox1.text + "%' or pendriveno like'" + textbox1.text + "%'", con1); da1 = new sqldataadapter(cmd1); ds1 = new dataset();

core foundation - understanding crashlytics report -

i've embedded crashlytics in ios app. run application , crashed... i've got following information on dashboard , don't know how read report, , fix. the issue reported is: 1 corefoundation objectiskindofclass infographics shows: 21.3gb free space 23 mb free ram 13% ram (when looking in more details) 76% disk space (when looking in more details) the data crashed: com.apple.main-thread exc_bad_access kern_invalid_address @ 0x50000008 0 libobjc.a.dylib _cache_getimp + 3 2 libobjc.a.dylib class_respondstoselector + 30 3 corefoundation objectiskindofclass + 36 4 corefoundation __handleuncaughtexception + 68 13 uikit uiapplicationmain + 1120 14 myapp main.m line 16 the raw info looks this: thread : crashed: com.apple.main-thread 0 libobjc.a.dylib 0x39c33584 _cache_getimp + 3 1 libobjc.a.dylib 0x39c33fa5 lookupmethod + 28 2 libobjc.a.dylib 0x39c351e7 class_

iphone - iOS - How to make the tableview use paginated API output? -

an api writing has 2000 records, returned in json via simple restful api have written. to reduce issues lots of data, want use pagination return first 10 or first 20 per request via offset or limit or page , etc. but question how ios uitableview know when next page of results? i unsure of how this. user scrolling superfast , api might not have enough time retrieve 20 or 50 records @ time. another issue related is, lets user scrolls down on uitableview, , down again -- how prevent api firing multiple times same rows? thanks seems aren't thinking in terms of mvc . uitableview has little paging , webrequest. it's concerned datasource not pages. restuful api design : assume web request designed follow : /getrecorods?pagesize=20&pageno=2 this return array of json. in addition helpful have count parameter , link next page. helps in parsing , sync web server. how prevent api firing multiple times same rows? a simple flag sufficient avoid lo

sql - How to get a root node and all its child nodes for multiple hierarchy in a table -

i have following heirarchies in db a |_a1 | |_a11 | |_a2 and b |_b1 | |_b2 |_b21 |_b22 i want query displays result as parent child a1 a11 a2 b b1 b b2 b b21 b b22 with w(child, parent) ( select 'a', null dual union select 'a1', 'a' dual union select 'a11', 'a1' dual union select 'a2', 'a' dual union select 'b', null dual union select 'b1', 'b' dual union select 'b2', 'b' dual union select 'b21', 'b2' dual union select 'b22', 'b2' dual ) select connect_by_root child parent, child w connect w.parent = prior w.child start w.parent null ; this returns: 1 2 a1 3 a11 4 a2 5 b b 6 b b1 7 b b2 8 b b21 9 b b22 you can filter lines parent == child adding where connect_by_root child != child between

javascript - Animate LENGTH of border-bottom -

i have navbar. on hover of of menu item want have exact same effect of border-bottom animation in here (see how border or menu items @ top-left animates when hover them.) i tried find similar asked questions on stackoverflow , on google didn't find helpful. any appreciated. well, easy inspecting web developer tools. in page create element inside menu using :before pseudo-element. on hover use css transforms (scale) change length. jsfiddle . span { display: inline-block; padding: 6px 0px 4px; margin: 0px 8px 0px; position: relative; } span:before { content: ''; position: absolute; width: 100%; height: 0px; border-bottom: 1px solid black; bottom: 2px; -webkit-transform: scalex(0); -ms-transform: scalex(0); transform: scalex(0); -webkit-transition: -webkit-transform 0.2s ease-in; transition: transform 0.2s ease-in; } span:hover:before { -webkit-transform: scalex(1); -ms-transform: scal

wpf - Application crashes on start when running through remote desktop -

i developing wpf application. accessing admin account on clients machine using remote desktop. when try run application getting xaml parse exception when program attempts initialise. the strange thing if run program without remote desktop on same account works fine. has experienced before?

java - When the following Regex matches? -

i found following regex in 1 of android source file: string regex = "\\s+(?i)src=\"cid(?-i):\\q" + attachment.mcontentid + "\\e\""; if(string.matches(regex)) { print -- matched } else { print -- not found } note: attachment.mcontentid have values c4ea83841e79f643970af3f20725cb04@gmail.com i made sample code below: string content = "hello src=\"cid:something@gmail.com\" present"; string contentid = "something@gmail.com"; string regex = "\\s+(?i)src=\"cid(?-i):\\q" + contentid + "\\e\""; if(content.matches(regex)) system.out.println("present"); else system.out.println("not present"); this gives "not present" output. but when doing below: system.out.println(content.replaceall(regex, " replaced value")); and output replaced new value. if not present , how replaceall work , replace new value? please cle

TestFlight iOS App get-task-allow Issue -

i have app in testflight ios called mapittrackit. has been working great. i updated xcode 5.1. built app same way have. same profile , ad-hoc cert. this time when try upload ipa file 'invalid profile: developer build entitlements must have get-task-allow set true.' error. i didn't change @ provisioning or not. added more functionality app , rev'ed version. what heck do now? how fix this? boss wants deployed right , can't. same exact issue 4 hours today - restarting xcode seems fix depressing is.

php - Email sent from website not going to domain specific email -

i have website contact form. form uses php mail function send email email doesn't go email address if using same domain name. i'm not sure what/how explain. if website www.example.com , fills out contact form on site, should go info@example.com doesn't. if try using different email address not whatever@example.com works fine. has had problem or can point me in right direction how debug issue this. i not after email server company saying fine end , keep saying there wrong form. **edit have checked spam folder , there nothing have tried sending emails email address outside of website (another email address)

latitude longitude - Couchbase with PHP GeoLocation Search - (Part) Solution -

problem i in need of search range of distance latitude , longitude. relatively straight forward in sql, however, in couchbase came across difficulty. discovered spatial views offer solution this, spatial views aren't accessible via php sdk (yet) , had use rest api alternative. solution i can result set within range latitude , longitude using method, need sort date created. please see end of post. my documents such: { "doctype" : "post", "title" : "test post", "location" : { "latitude" : 1.123456789 "longitude" : -13.9876543210 } "created" : 1395329441 } the trick create index normal view format keys in specific way. the formula preppend keys "point::" add positive or negative sign "+", or "-" make integer part 3 characters long prepending "0"s make decimal part 9 characters long appending "0"

r - labelling two summary data in one boxplot -

Image
i new user of r. • combine results of these 2 groups , still maintain labels 2 groups. when combine, yield figure, has lost labels. • label number 1 , 2 (for both groups) “falling” , “falling-rising”. respectively , “black” , “grey” color show difference easily. • working summary results this formula have used far create figure: d0<-matrix(c(x1,x2), ncol=2) d1<-matrix(c(y1,y2), ncol=2) lmts<-range(d0,d1) par(mfrow = c(1, 2)) boxplot(d0, ylim=lmts, xlab="x") boxplot(d1, ylim=lmts, xlab="y") result1 <-boxplot(d0, ylim=lmts, xlab="x") result2<- boxplot(d1, ylim=lmts, xlab="y") mylist <- list(result1, result2) groupbxp <- do.call(mapply, c(cbind, mylist)) bxp(groupbxp) like this? set.seed(1) # example reproduceable # create example x1=sample(50,100,10) x2=sample(50,100,10) y1=sample(50,100,10) y2=sample(50,100,10) d0<-data.frame(falling=x1,"falling-rising"=x2) # note use of data.frame(..

Intellij IDEA: how hide main menu? -

after installation of enterprise edition see main menu when hover mouse of screen (with clock on right). accidentally pushed button , can't hide main menu. i on lubuntu. have tried view -> enter full screen ? or not you're looking for?

javascript - How to wrap two elements into one div? -

i have problem wrapping 2 elements: label , input 1 div. can me how right ? thank much. example: <label><label> <input> <label></label> <input> should be: <div data-role="fieldcontain"> <label><label> <input> </div> <div data-role="fieldcontain"> <label><label> <input> </div> jquery: $('input[type="text"]').prev().andself().wrap('<div data-role="fieldcontain">'); html: <label>name: </label> <input type="text" name="name" id="name" value="" /> <label>surname: </label> <input type="text" name="surname" id="surname" value="" /> you need loop through each input club input , label , use .wrapall() like $('input[type="text"]').each(function () { $(this).prev().addback

android - insert into sqlite from intentservice using sqlitecursorloader -

i using sqlitecursorloader lib commonsware. receive gcm messages in intentservice , insert entry sqlite database. should update listview if app open. i tried using in activity loader initialized: public static void createdbentry(string title, string message) { contentvalues values=new contentvalues(2); values.put(databasehelper.title, title); values.put(databasehelper.message, message); loader.insert("constants", databasehelper.title, values); } and in intentservice: mainactivity.createdbentry(title,message); as far can tell works of time if loader recycled nullpointer. should initialize new loader in intentservice? please help, new android development. putting loader in static data member bad, loader , let alone sqlitecursorloader , leak activity . i have officially discontinued sqlitecursorloader . either: switch using contentprovider , regular cursorloader , or use event bus ( localbroadcastmanager , square's ott

c# - Date field comparison in linq DataService Query -

i have wcf data service fetch customer records table has datetime column well. in ui have grid displays name , dob.i have text box filter. when there text entered in filter, want text compared against columns in table. getting exception when search text compared against datetime column. query using below. enter code here db.customers.where(customer => customer.lastname.toupper().startswith(text) || customer.firstnme.toupper().startswith(text) || (customer.dob.value.year.tostring() .startswith(text) ); this throws exception 'error translating linq expression uri'. on other hand if compare datetime field direct value works. enter code here db.customers.where(customer => customer.lastname.toupper().startswith(text) || customer.firstnme.toupper().startswith(text) || (customer.dob.value.year ==

php - Laravel 4 - Use Class Functions inside Views -

i wondering if possible use classes , define functions in controller file , call these methods inside views. right : i'm writing normal php functions inluding them inside views : php file function viewprofile() { function getusername() { $username = auth::user()->username; return $username; } function getname() { $name = auth::user()->name; return $name; } function getemail() { $email = auth::user()->email; return $email; } } views file : <?php include(app_path().'/scripts/profile.php'); viewprofile(); ?> <td><?php echo getusername() ?></td> i want write in classes instead : public class profile { public static $username = auth::user()->username; public static $name = auth::user()->]name; public static $email = auth::user()->email; function getusername() { return $username; } function getname() { return $name; } fun

sql - Python manual query building: how to escape strings for MySQL in list comprehension where clause builder? -

i'm using django site, can't use django's orm because it's not built "n" databases dynamically selected user joins between multiple databases, otherwise trust me love to. i'm stuck building query hand , take @ trickery list comprehension: def buildquery(self, pagedata, num_per_page) : given_fields = {k:v k,v in self.entity.fields.items() if k in pagedata.iterkeys()} where_clauses = [(given_fields[k] % pagedata) k in given_fields if pagedata[k].strip() != ''] if where_clauses: self.queryparts['whereclause'] = 'where ' + ' , '.join(where_clauses) else: self.queryparts['whereclause'] = '' if pagedata.get('sort_by', '1') != '': self.queryparts['sortby'] = 'order %s %s' % (pagedata.get('sort_by','1'), pagedata.get('sort_dir','asc')) else: self.queryparts['sortby'] = &#

html5 - How to position an element relative to window scroll position using CSS? -

i'm trying position element on screen based on following formula: element.style.top = element.pivot_y + window.scrolly; i'm doing using javascript , window.requestanimationframe . problem requestanimationframe not available on browsers, have fallback timer, which makes element wiggle due lack of synchronisation rendering. this, can position element similarly, without invoking javascript? as far understand should possible position: fixed; , top: pivot_y pivot_y has fixed number

servicestack - ToOptimizedResult on an HttpResult causes a StackOverflow exception -

i'm using v3.9.56.0 , i'm encountering stack overflow exception when call tooptimizedresult (called own service runner) on returned httpresult service. when dig deeper found exception coming jsonserializer . here snippet of code being returned: return new httpresult(new fileinfo(path.combine(path, file)), true) this happening because tooptimizedresult expects receive dto response object can compress create compressedresult response. however providing httpresult wrapper byte[] / string dto response object of file loading, wrapper complex type, , isn't want trying optimise. if file binary should return byte[] of contents, if plain text return string . tooptimizedresult can optimise data. // binary file type return file.readallbytes(path.combine(path, file)); // returns byte[] // plain text file type return file.readalltext(path.combine(path, file)); // returns string

c# - Moved old Dot Net Nuke site to new server now get linkclick.aspx not found -

i have moved dnn site new hosting service. site comes fine when try click on link /linkclick.aspx not found (404) error. i assume has handler linkclick.aspx , fact running under .net 4 rather .net 2 old site running under. what correct way resolve this? i got work removing runtimeversion2.0 specification in add handler line of web.config. <add name="linkclickhandler" path="linkclick.aspx" verb="*" type="dotnetnuke.services.filesystem.fileserverhandler, dotnetnuke" precondition="integratedmode" /> <add name="captchahandler" path="*.captcha.aspx" verb="*" type="dotnetnuke.ui.webcontrols.captchahandler, dotnetnuke" precondition="integratedmode,runtimeversionv2.0" />

php - I pass Facebook different URLs on a website and they return the same data each time? -

i have problem requesting data facebook. have tried few different ways number of likes individual page on website manage, each time send specific url same information back. share , , comment totals same each url pass facebook. so instance send: http://api.facebook.com/restserver.php?method=links.getstats&urls=http://thiswebsite.com/page21/ or http://api.facebook.com/restserver.php?method=links.getstats&urls=http://thiswebsite.com/page49/ and same information returned. i have open graph tags on site , think implemented correctly when pass urls directly show above same results. og tags have on site effecting results facebook returns, if manually passing them facebook? well have 2 options take. one's overly complicated once have working you'll never have worry it. other takes time requires lot less effort. i'll start simple one. go https://developers.facebook.com/tools/explorer . once there uid should there delete every thing after including ?

linux - this program is incomplete but I'm supposed to ask the user for 10 2-digit numbers and then give the average -

however segmentation fault don't know means , how approach either can please explain? segment .data ;welcome message welcomemsg db "this nasm program calculates average of 10 2-digit numbers", 0xa msglength equ $-welcomemsg endingmsg db "the average is: ", 0xa endinglength equ $-endingmsg numbers db "enter 10 2-digit numbers",0xa numberslength equ $-numbers segment .bss arrayofnumber: resb 30 ;store number entered user in arrayofnumber arrayofnumberlength equ $-arrayofnumber total : resw 1 ; store sum value of 10 numbers segment .text global _start _start: mov eax, 4 ;write() mov ebx, 1 ;where? output mov ecx, welcomemsg ; want output mov edx, msglength ; length of welcomemsg int 0x80 mov eax, 4 mov ebx, 1 mov ecx, numbers mov ed

git push origin master not pushing the files -

i have setup remote git , local git on mac able create git repo (git init myrepo) on remote machine (linux) added few files , committed them no problems (git add , git commit -m "test") from local able clone repo remote no issues (git clone ssh://user@ip/path) so far no issues. i have created few files locally , used git add , commit tried push them remote server using git push origin master initially received error message , searching around solution run command directly on remote server: git config receive.denycurrentbranch ignore that fixed issues , able push successfully: $ git push origin master git add test.sh git add git* git commit -m "adding 2 new files , updating test.sh" [master 4dd11a0] adding 2 new files , updating test.sh 3 files changed, 109 insertions(+) create mode 100644 githowtourls.txt create mode 100644 git_howto.txt git push origin master counting objects: 7, done. delta compression using 8 threads. compressing objects: 100%

github - Git Pull vs. Pull Request -

i'm new using git, apologize if trivial. have private repository set using github , egit . to update , merge local repository branch remote version (essentially git pull ), use team > pull in eclipse. to merge branch into master branch, have request , subsequently approve pull request on github. what difference between calling git pull , sending pull request ? i've seen related fork , pull collaborative development model , used code reviews . think understand motivation , usefulness of pull request, it? if use git pull , pull changes remote repository yours. if send pull request repository, ask maintainers pull changes theirs (you more or less ask them use git pull repository). if maintainer of repository, seems you're making bit more difficult pretending you're playing 2 roles in workflow. might merge locally development branch master branch , push master branch github repository directly. (as side note, if you're new

C/C++ use of int or unsigned int -

in lot of code examples, source code, libraries etc. see use of int when far can see, unsigned int make more sense. one place see lot in for loops. see below example: for(int = 0; < length; i++) { // stuff } why on earth use int rather unsigned int? laziness - people can't bothered typing unsigned ? using unsigned can introduce programming errors hard spot, , it's better use signed int avoid them. 1 example when decide iterate backwards rather forwards , write this: for (unsigned = 5; >= 0; i--) { printf("%d\n", i); } another if math inside loop: for (unsigned = 0; < 10; i++) { (unsigned j = 0; j < 10; j++) { if (i - j >= 4) printf("%d %d\n", i, j); } } using unsigned introduces potential these sorts of bugs, , there's not upside.

javascript - How do I make an OnClick function that will change a word when a user clicks it to another word? -

okay so, want make onclick function in javascript makes when user clicks on it, change word. there replaceword() function or let me so? know not real code, example: <p>quickly <span onclick="replaceword('surf');">search</span> web!</p> if there is, can tell me how reverse code maybe? when click on second time, change "search"? no, there isn't native function, can create on own. function replaceword(that, word, oword) { that.textcontent = that.textcontent == oword ? word : oword; } you can call this: <p>quickly<span onclick="replaceword(this,'surf','search');">search</span>the web!</p> live demo: http://jsfiddle.net/t6bva/6

c++ - Include not required to define member function with enum? -

i forward declaring typed enum in header file. however, include not needed in cpp though defining member function it. referencing this stackoverflow article should not work. there no other includes indirectly including enum. musicplayer.h - music::id being used declare member function legal namespace music { enum class id; } class musicplayer { public: load(music::id theme); }; musicplayer.cpp - music::id being used define member function without being included should illegal void musicplayer::load(music::id theme) { } this new feature in c++11. enums got rid of need integer #define constants, still had serious issues(like allowed compare other enum types, meaningless). strongly typed enums (enum class) introduced in c++11. use of word class meant indicate each enum type different , not comparable other enum types. enum classes have advantages better scoping , feature forward declaration mentioned. not same class in link. why useful???

c# - get HtmlHelper.textbox value as query string mvc -

Image
i have following idea trying implement @foreach (var item in model) { <div>user: @item.name<br /> scores: @item.scores<br /> @html.textbox("lastvisit"); @html.actionlink("update item", "updatemyitem", new { name = item.name, lastvisit=????? }) </div> } i have seen question pass text in query string , not want.. so question .. in above code how can replace (?????) value of textbox(lastvisit) , send value querysting in url of action link ?? notice opted not use webform own reason , know how webform.submit(), main concern how extract value of @htmlhelper.textbox().. :) something might help. work need render unique ids links , textboxes. here example action method simple model public actionresult index(int? id) { list<mymodel> mod = new list<mymodel>() { new mymodel { selectedvalue = 1 } , new mymodel {selectedvalue = 2}, new mymodel {selectedvalue

c# - Id not coming in dropdown using viewbag -

i trying dropdown list in application, name of dropdown coming can't track id of user it. i tried doing way- controller- public actionresult _dropdown() { var list = (from u in db.users select new { u.name, u.id }).tolist(); viewbag.uname = new selectlist(list, "id", "name"); return partialview(); } method- @model registration.user @html.dropdownlist("name", new selectlist(viewbag.uname, "id", "name")) i getting "id" not found error , when replacing name same name also. how resolve issue? note- i populate names , id should of selected item. can't attach id dropdown list. try this: viewbag.uname = new selectlist(list, "id", "name"); and in view: @html.dropdownlistfor(model => model.yourmodel, (selectlist)viewbag.uname, "--select--")

c++ - Using Own Stack Class in Encoding Program - Determine Size and Top -

i wrote encoding program using c++ stack library. trying implement own stack class, notice there size() , top() member functions in stack library. not sure how implement code without these functions, or how write functions in class them work code have. here areas stack library functions being called in readfileencode(string filename, stack<char> &text, string cypher) function: ifstream file(filename, ios::in | ios::binary); stack<char> temp; char ch; while (file.get(ch)){ temp.push(ch ^ cypher[temp.size() % cypher.length()]); } while (!temp.isempty()){ text.push(temp.top()); temp.pop(); } here stack class: #include<iostream> #define true 1 #define false 0 template <class type> class stack{ struct node{ type element; node *next; }; public: node *top; int stacksize; stack(void); //constructor ~stack(void); //destructor free stack void push(type & value); type pop(void); type peek(void); int i

Sorting associative arrays/object in javascript/jquery by the length of their values (longest to shortest) -

what best way sort associative array/object using javascript/jquery length of values? longest value shortest value, if value same alphabetical. eg result: name["mike"] = "sanders" name["mary"] = "smith" name["sharon"] = "chan"; name["xu"] = "wang"; name["john"] = "ho"; i have looked , looked , not find similar question. thanks try this var name= []; name.push({ key: 'mike', value: 'sanders' }); name.sort(function(a,b) { var aval = a.value.tostring(); var bval = b.value.tostring(); if (aval.length === bval.length) { return aval.localecompare(bval); } else { return aval.length - bval.length; } }); alert(name[0].value); //ho alert(name[1].value); //chan alert(name[2].value); //wang alert(name[3].value); //smith alert(name[4].value); //sanders

uiscrollview - iOS: Storing Link to UIImageViews in Array, using them afterwards -

i make uiscrollview "page-able" , contains several kind of objects, including images, zoomable. set main uiscrollview , added on pages images additional uiscrollviews zoomable , contain subviews uiimages. while doing store link uiimageviews in array: uiscrollview *imagescrollview = [[uiscrollview alloc] initwithframe:scrollviewimagerect]; [imagescrollview setminimumzoomscale:1.0]; [imagescrollview setmaximumzoomscale:2.0]; imagescrollview.delegate = self; uiimageview *imageview = [[uiimageview alloc] initwithframe:cgrectmake(x, y, w, h)]; [imagelinkarray addobject:imageview]; [imagescrollview addsubview:imageview]; [self.scrollview addsubview:imagescrollview]; in viewforzoominginscrollview can current page of main scrollview , return link: - (uiview *)viewforzoominginscrollview:(uiscrollview *)scrollview { return [imagelinkarray objectatindex:page - 1]; } works fine far, reset zoom scale whenever swipe page, else when swipe image still zoomed-in. therefor

angularjs - Params with angular form submit -

i'm trying set dummy form angular. have form set i'd fake params sent , see outcome. think it's called serializing params. please consider following code on success $scope.message = "message sent " + $scope.formdata currently returns message sent [object object] i'd return params sent message sent {"order": ["company": "test", "phone": "1111"]} here full code angular.module("app").controller "contactcontroller", ($scope, $http) -> $scope.formdata = {} $scope.processform = -> console.log $scope.formdata $http( method: "post" url: 'process.php' data: $scope.formdata ).success( (data) -> # if successful, bind success message message $scope.message = "message sent " + $scope.formdata $scope.formdata = '' ).error (status) -> console.log "an error occured processign for

sql server - Can anything else send emails except sp_send_dbmail? -

i'm using sql server 2012. i plan enable emails on staging server make sure performs planned before going live. i'd emails being sent come own email address , not go real clients, i've hardcoded to, cc, , bcc fields in [sp_send_dbmail] can send me, regardless of parameters being passed in. the technet page @ http://technet.microsoft.com/en-us/library/ms189635.aspx mentions sp_send_dbmail, , know xp_sendmail no longer available, want sure nothing can emailed clients before enabling email on server. so before enable emails, know of other sps or xps can send emails may not have considered? thanks this resolved now, else looking solution same question though ... it seems sends emails, or involved emails in sql server 2012 revolves around [msdb].[dbo].[sp_send_dbmail] (previous versions of sql server had xp_sendmail). so can edit [msdb].[dbo].[sp_send_dbmail], after begin statement, insert following: set @recipients = 'yourdevemail@addresshe

c# - How to know the numbers of pin code remained on a smart card -

i'm sing smart card , token , have code checks pin code them, want catch number of pin remains until blocked if password incorrect. this code: public static bool isvalidpasswordforcertificate(x509certificate2 certificate, string password) { cspparameters csp = new cspparameters(); try { rsacryptoserviceprovider rsaencryptor = (rsacryptoserviceprovider)certificate.privatekey; csp.keycontainername = rsaencryptor.cspkeycontainerinfo.keycontainername; csp.providername = rsaencryptor.cspkeycontainerinfo.providername; csp.providertype = rsaencryptor.cspkeycontainerinfo.providertype; } catch (exception) { throw; } //import password csp details try { securestring secure = new securestring(); foreach (char c in password) secure.appendchar(c); csp.keypassword = secure; } catch (exception) { throw; } //try import csp , password details provider try { rsacryptos

linking to libredwg in c++ not working -

i'm trying use libredwg open , understand dwg files. have installed , @ least got of test programs run (even if seg fault later on). anyway, have included small header file in project similar simple example found here https://github.com/h4ck3rm1k3/libredwg/blob/master/examples/load_dwg.c there seems general problem data types (at least in way i'm compiling it) meaning i've added few casts of form (char*) number of variables trying automatically convert (void*) , (unsigned char*) type (char*) , got rid of compiler complaints. still when compile so g++ xxx.c++ -l/opt/local/lib/ -lredwg -o program_name i following error: undefined symbols architecture x86_64: "dwg_read_file(char*, _dwg_struct*)", referenced from: load_dwg(char*)in ccn6huqz.o "dwg_free(_dwg_struct*)", referenced from: load_dwg(char*)in ccn6huqz.o ld: symbol(s) not found architecture x86_64 collect2: ld returned 1 exit status i'm not sure do, i've fi

php - fastest way to check web-services availability -

my application uses 70 external services. on init function want test if of them avaliable , can produce json. trying via curl , via parallel curl , if service unavaliable have wait timeout (5 sec) in worst case script hang 70 * 5 seconds not init function in application. maybe have better idea? my code strict curl: foreach ($services $key => $value) { $url = $value['url'] . '?f=json'; $curl = curl_init(); curl_setopt($ch, curlopt_timeout, 5); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_useragent, 'mozilla/5.0 (windows; u; windows nt 6.1; en-us; rv:1.9.1.2) gecko/20090729 firefox/3.5.2 gtb5'); curl_setopt($curl, curlopt_url, $url); $result = curl_exec($curl); $result2 = json_decode($results, true); if ($result != false && gettype($result) !== "integer" && !array_key_exists('error', $result)) { $avaliableservices[$key] = true; } } i trying modify timeout

java - Why there is no output is eclipse console -

i have no idea why eclipse not printing on console while running program. public class stringoptimization { public stringoptimization() { } public static void main(final string[] args) { final stringoptimization optimization = new stringoptimization(); final string samplearray[] = new string[60000]; (int = 0; <= 50000; i++) { samplearray[i] = "i"; } final string finalstring = optimization.addstringitems(samplearray, true); system.out.println(finalstring); } public string addstringitems(final string[] items, final boolean forceuppercase) { final stringbuilder returnvalue = new stringbuilder(); (final string item : items) { returnvalue.append(item); } return forceuppercase ? returnvalue.tostring().touppercase() : returnvalue.tostring(); } } there configurable limit number of characters k

ruby - Weird Rails 4 RESTful URL after form error -

i have restful controller inside of namespace called dashboard, url looks this: /dashboard/member /dashboard/member/edit something weird happening when submit member form validation error... shows error it's suppose to, when goes patch url "/dashboard/member" comes ".2" in end: /dashboard/member.2 the "2" id of record. the funny thing did correctly , works great, ".2" thing bothering head. my controller class dashboard::memberscontroller < applicationcontroller load_and_authorize_resource :class => member before_filter :authenticate_member! def show end def edit @member ||= current_member end def update @member ||= current_member if @member.update_attributes(member_params) flash[:success] = "profile updated" redirect_to dashboard_member_path else render "edit" end end private def member_params params.require(:member).permit(:f

java - YouTube API upload stuck on processing -

i'm trying upload video own youtube account using v3 api , java library. if call method, see video permanently stuck @ "processing..." stage in youtube account. exception never reaches catch blocks, , i've managed upload same videos logging youtube directly , using drive api (with similar code what's listed below). missing? public boolean savetoyoutube(file fileorig) { youtube service = new youtube.builder(httptransport, jsonfactory, getcredential()).build(); // add information video before uploading. video video = new video(); videostatus status = new videostatus(); status.setprivacystatus("private"); //public, private video.setstatus(status); videosnippet snippet = new videosnippet(); snippet.settitle("test"); snippet.setdescription("this test video"); list<string> tags = new arraylist<string>(); tags.add("t

How show active call between sip to sip in asterisk? -

when type "core show channels" channel current calls through dahdi want see calls between sip sip too. use http://asternic.org or other panel project writed. btw, core show channels show calls, including sip. if not see sip calls, have set on peer canreinvite=no

r - Cannot use `fill = NA` in cast -

i received following error: dcast(rep.data, country ~ variable, mean, fill=na) error in vapply(indices, fun, .default) : values must type 'logical', fun(x[[4]]) result type 'double' here rep.data data frame above: structure(list(id = c("mrt1996", "bfa1982", "lbr1990", "ukr2000", "mng1993", "ven1992", "omn1987", "lao1996", "omn1982", "syr1993" ), wbcode = c("mrt", "bfa", "lbr", "ukr", "mng", "ven", "omn", "lao", "omn", "syr"), polcode = c("maa", "bfo", "lbr", "ukr", "mon", "ven", "oma", "lao", "oma", "syr"), country = c("mauritania", "burkina faso", "liberia", "ukraine", "mongolia", "venezuela, rb", &

oracle - SQL issue; count + display -

after searching more 2 hours on internet have not found specific answer questions : 1) how display 3 columns of specific table ? 2) how count (the sum) of column in table. if don't want display columns of table should specify names of columns want display: select column1, column2, column3 table; if want add values of column: select sum(column1) table; if wanted display summatory along other columns, should group columns: select column1, column2, sum(column3) table group column1, column2; if want count number of rows --it works sum function--: select count(*) table;

objective c - Get default font name in Cocoa for NSMenuItem? -

Image
i using nsattributed nsstring in nsmenuitem, it's font changed compare default font, wants use default font attributed string. can 1 explain, how find or fetch default font nsmenuitems. right using : nsdictionary *attributes = @{ nsfontattributename: [nsfont fontwithname:@"helvetica" size:14], nsforegroundcolorattributename: [nscolor blackcolor], nsparagraphstyleattributename:paragraphstyle }; thanks to default font of nsmenuitem use method [nsfont menubarfontofsize:0] . nsdictionary *attributes = @{ nsfontattributename: [nsfont menubarfontofsize:0], nsforegroundcolorattributename: [nscolor blackcolor], nsparagraphstyleattributename: paragraphstyle }; which easier in ways.