Posts

Showing posts from January, 2010

ember.js - EmberJS / Ember-Data: 404's Not Getting Caught -

Image
i trying catch 404 errors in ember app, , redirect /not-found . i have errors action on applicationcontroller , , have rsvp.on('error') function 404's aren't getting caught. 404 error thrown console jquery, error not getting passed error handler. errors initializer: import ember 'ember'; var initialize = function(container) { var errorreporting = container.lookup("service:errorreporting"); ember.rsvp.on('error', function(err) { ember.warn("ember.rsvp error..... logging error:"); console.log(err); if (err.name && err.name === 'transitionaborted') { ember.debug("transitionaborted error. doesn't should catching these."); } else { container.lookup('route:application').send('error', err); } }); window.onerror = function(err) { // window general errors. ember.warn("uncaught error (tripped window.onerror)..... logging error:")...

bash - Peroidcly running osascript in shell script to run apple script -

what i'm doing i running shell script periodically checks resolution of screen. based on run 1 of 2 apple scripts changes visibility on application (geek tools). my problem the apple scrip runs fine self. understand osascript way call apple script, because if try run directly says "cannot execute binary file". when use osascript $home/path/smallscreen.scpt gives me new error: osascript[61390:1405791] error loading /library/scriptingadditions/adobe unit types.osax/contents/macos/adobe unit types: dlopen(/library/scriptingadditions/adobe unit types.osax/contents/macos/adobe unit types, 262): no suitable image found. did find: /library/scriptingadditions/adobe unit types.osax/contents/macos/adobe unit types: no matching architecture in universal wrapper osascript: openscripting.framework - scripting addition "/library/scriptingadditions/adobe unit types.osax" declares no loadable handlers. maybe i'm misunderstanding thought should straight ...

python - Remove items from a list while iterating -

i'm iterating on list of tuples in python, , attempting remove them if meet criteria. for tup in somelist: if determine(tup): code_to_remove_tup what should use in place of code_to_remove_tup ? can't figure out how remove item in fashion. you can use list comprehension create new list containing elements don't want remove: somelist = [x x in somelist if not determine(x)] or, assigning slice somelist[:] , can mutate existing list contain items want: somelist[:] = [x x in somelist if not determine(x)] this approach useful if there other references somelist need reflect changes. instead of comprehension, use itertools . in python 2: from itertools import ifilterfalse somelist[:] = ifilterfalse(determine, somelist) or in python 3: from itertools import filterfalse somelist[:] = filterfalse(determine, somelist)

ios - AppTest on iPhone 6 reveals unknown screen glitches (gray lines) -

Image
i own iphone 5 , have tested app on it, works on iphone 5 device, iphone 5 , 6 simulator, when borrowed iphone 6 weird gray lines started appearing , disappearing (when move iphone around move , disappear) around collection view cells, buttons (which in uiview containers) i erased , still there, i've hidden buttons in cells, putted backrground , border color clear ; these lines sort of follow borders of cell. func numberofsectionsincollectionview(collectionview: uicollectionview) -> int { return 1 } func collectionview(collectionview: uicollectionview, numberofitemsinsection section: int) -> int { switch collectionview{ case collectionviewone!: return collectionviewonerows case collectionviewtwo!: return collectionviewtworows default: return 0 } } func collectionview(collectionview: uicollectionview, cellforitematindexpath indexpath: nsindexpath) -> uicollectionviewcell { switch collectionview{ case collec...

xcode - How to remove the first top border of the table in swift -

Image
i have created left side menu. static table view 6 rows. as can see here, there first top border - number (1) - of table view. try rid of using code below make color of border similar background in willdisplaycell didn't work: if(indexpath.row == 0){ cell.layer.bordercolor = deselectedcolor.cgcolor } any idea remove first top border? thank you edit: i have solution somehow still facing little bit of problem. var border = calayer() border.frame = cgrectmake(0, 99, cgrectgetwidth(cell.frame), 1) border.backgroundcolor = bordercolor.cgcolor cell.layer.addsublayer(border) i turn off separator main story board , try redraw bottom border each cell. worked great first cell did not have bottom line , not figure out...

java - Conditional statement within readline() method -

so, fileinputstreaming .xml file(name ini--which contains list of .txt files). however, want .txt files in .xml file. how go doing that? appreciate feedback. thanks. filereader filereader = new filereader(new file("ini.xml")); bufferedreader br = new bufferedreader(filereader); while ((line = br.readline()) != null) { // reading lines till no more lines //however ....want place if or line contains method specify .txt files. your feedback appreciated. assuming each line contains file name test see if string ends .xml while ((line = br.readline()) != null) { if (line.tolowercase().endswith (".xml")) continue }

html - Text on div border with transparent background -

this question has answer here: how center <legend> element - use instead of align:center attribute? 10 answers how put text on border div text has transparent background matches image behind? the problem background-image has shapes , multiple colors , can't put background color the text because won't fit. example: html, body { width: 100%; height: 100%; } body { margin: 0; background: url(http://wallpoper.com/images/00/45/05/47/green-background-2_00450547.jpg); } #main { margin-top: 100px; -webkit-border-radius: 20px; -moz-border-radius: 20px; border-radius: 20px; border: 1px solid #000000; } #main h2 { font-size: 60px; font-weight: 700; text-align: center; margin: -40px 0 0; background: transparent; /* somehow remove border behind text */ padding: 0 20px; } <div id="main...

C - libcurl - How to get dltotal without using the CURLOPT_XFERINFOFUNCTION -

i using libcurl multi interface , need know how data being sent each request. rather not use curlopt_xferinfofunction because gets called lot , need know dltotal while in curlopt_writefunction callback. want clean existing easy handle , malloc'd data while still in write callback once data has been received. there function can call return total amount of data being sent particular easy handle? i tried using curl_easy_getinfo() curlinfo_size_download , returned 0 . tried curlinfo_content_length_download returned 0 . calling within curlopt_writefunction callback. the reason zeroes calls because size isn't known before-hand. but let me alert "i want clean existing easy handle , malloc'd data while still in write callback" sounds disaster waiting happen. should not cleanup handle within callback.

javascript - Get new value in Fuelux Spinbox change event -

i'm using fuelux spinbox 3.7.3 according docs: http://getfuelux.com/javascript.html#spinbox can handle change event through "changed.fu.spinbox". event fires 2 arguments: event , value, being value current value. is possible new value? (or @ least know if increase or decrease). examined both arguments , find reference new value. at time event fired, input still not updated , therefore cannot new value way.. in change event take action depending of increment or decrease. any other approach appreciated thanks the changed.fu.spinbox should return new value. i visited nightly build server fuel ux , if open browser's console, should see change event returns new value, not old value. there bug causes changed event fire twice on first click of spinbox, after new value returned via value parameter of event. i recommend storing old value , comparing new value in order discover increase or decrease.

installer - Visual Studio Install generating multiple files instead of just setup.exe -

Image
i had install project have been using , generating setup.exe file... (i don't remember changing anything) folder ends many files: used end setup.exe file. (other files generated during compilation... setup.exe file remained after compilation complete.) anyone have idea might have changed? note: program files directory has usual exe, configs, dll's , such... this: so, reason (brain blip) started getting install directory: nexus\nexusinstaller\nexusinstaller\express\dvd-5\diskimages\disk1 when in fact before (and should now) getting directory: nexus\nexusinstaller\nexusinstaller\express\singleimage\diskimages\disk1

vector - How can i make this program look at more than the first character? -

#include <iostream> #include <string> #include <vector> using namespace std; int main() { const int setnum = 26; vector<char> normalv(setnum); vector<char> cipherv(setnum); string todec = ""; string beendec = ""; int = 0; normalv.at(i) = 'a'; cipherv.at(i) = '!'; ++i; normalv.at(i) = 'b'; cipherv.at(i) = '^'; ++i; normalv.at(i) = 'c'; cipherv.at(i) = '&'; ++i; normalv.at(i) = 'd'; cipherv.at(i) = '*'; ++i; normalv.at(i) = 'e'; cipherv.at(i) = '@'; ++i; normalv.at(i) = 'f'; cipherv.at(i) = '('; ++i; normalv.at(i) = 'g'; cipherv.at(i) = ')'; ++i; normalv.at(i) = 'h'; cipherv.at(i) = '-'; ++i; normalv.at(i) = 'i'; cipherv.at(i) = '#'; ++i; normalv.at(i) = 'j'; cipherv.at(i) = '_'; ++i; normalv.at(i) = 'k'; cipherv.at(i) = '='; ++i; normalv.at(i) = 'l...

javascript - how to refer to extJS combobox using a string? -

is there way refer via string instance of combobox? have workaround in place, not happy it, see need create more combobox's in future. have tried unsuccessfully use 'reference','id','itemid'. the reason why ask b/c dumping meta information fields , meta-info comes across strings. works until need javascript instance 'editor'. i can not refer javascript instance when info has quotes around it. posting code (just relevant portion) below comment near issue/question/workaround. var my_combo=ext.create('ext.form.field.combobox', { listclass: 'x-combo-list-small', store: ['string', 'int', 'number', 'boolean', 'date'], querymode: 'local', displayfield: 'data_type', valuefield: 'data_type' }); var center_grid = ext.create('ext.grid.panel', { store: ourrecordstore, region: 'center', selmodel: ext.create('ext.sele...

angularjs - Login to Parse.com DB using API returns XMLHttpRequest header error -

Image
here call make parse.com's api login user: var deferred = $q.defer(); $http({ method: "get", url: "https://api.parse.com/1/login", headers: { "x-parse-application-id": parse_credentials.app_id, "x-parse-rest-api-key": parse_credentials.rest_api_key, "content-type": "application/json" }, data: { "username": credentials.username.tolowercase(), "password": credentials.password } }).success(function(data) { deferred.resolve(data); }).error(function() { deferred.reject("error") }); return deferred.promise; when trigger angular service method, following error in console: xmlhttprequest cannot load https://api.parse.com/1/login. request header field access-control-allow-headers not allowed access-control-allow-headers. i'm not sure how resolve this. here current contents of common headers object angular app: obj...

php - Session variable isn't carrying over to next page - session_start() has been started -

i'm not sure why session variables not being carried on next page. session_start(); has been added both pages, , if dump session on first page, array expect. when go redirect next page, session_id remains same, array empty. here code: session_start(); if (isset($_post['submit'])){ $price=check_input($_post["price"]); $number=$_post['number']; $activity=$_post['activity']; $_session['price']=$price; $_session['number']=$number; $_session['activity']=$activity; $index_query=mysql_query("select id activities people >= '$number' , type='$activity' , cost <= '$price' order rand() limit 0,1;"); $index_fetch=mysql_fetch_assoc($index_query); $activity_id=$index_fetch['id']; header("location: activity.php?id=".$activity_id.""); } now, added below above header redirect see if session carrying anything, , printed correct informat...

weka - Clustering initialization -

how set clustering initialization method? i found besides random initialization can select couple of more methods, such k-means++ , farthest first. i found can use following method that: clusterer.setinitializationmethod(new selectedtag); now, i'm confused selectedtag. represent , how use it? more specifically, how specify k-means++ or farthest first initialization methods? thanks i found solution, here needs done: clusterer.setinitializationmethod(new selectedtag(simplekmeans.kmeans_plus_plus, simplekmeans.tags_selection)); if @ simplekmeans see has following static members: static int canopy static int farthest_first static int kmeans_plus_plus static int random static tag[] tags_selection and how use them. can pass distance identifier need. cheers!

oracle - SQL group by and aggregate function -

i have following table structure sample data (only columns of interest listed). want query return # of bsp_id's completed # of up_id's. bsp_id | up_id | status_flag 1256 15 completed 1232 1 completed 1216 15 completed 1216 1 completed 1235 1 completed and result of query should be count(bsp_id) | count(up_id) 1 2 3 1 you need nested query. should work: the internal query: select bsd_id, count(*) c mitable status_flag='completed' group bsd_id results: 1256, 1 1232, 1 1216, 2 1235, 1 the complete query: select count(*), t.c (select bsd_id, count(*) c mitable status_flag='completed' group bsd_id) t group t.c results: 1, 2 3, 1

ios - Swift logout process -

i building app in swift interacts api. there 2 ways user can logged out, clicking logout button or receiving 401 response when calling api. i plan on using nsnotificationcenter in api class broadcast event when unsuccessfully response received generic handling of things 401, 400, 500 can handled in 1 place outside of api class. to prevent duplicating logic involved logging out in multiple places have created class clear existing tokens , present login view controller. class can used when logout button clicked in view controller or when 401 response picked response observer. my problem is, since logic not inside view controller unsure how can present login view controller not have access method self.presentviewcontroller you're going need pass responsibility view controller. how i've handled in past using key-value observer (or rac ) monitor active token. when token goes away, swap out root controller. where depends on how you've structured things. app...

JSF: Is there a way to bind method to h:outputLink? -

i working on this: a jsf template has side-navigation bar contains links(either anchor or h:outputlink), , there cases 2 options lead same link(page), different value in view parameter, , rendering different data being displayed on page. is there way this? using commandlink or commandbutton not seem option me since mess styling. thanks in advance. an output link normal html link, conventional way query parameter, e.g. /contentarea.xhtml?myparam=value . i don't think should bind method output link. involve javascript onclick handler ( commandlink ), , don't think that's necessary here. said, i'm surprised commandlink messes styling, renders normal html link. see also http://incepttechnologies.blogspot.ca/p/view-parameters-in-jsf-20.html (see first technique using f:viewparam ) http://www.mkyong.com/jsf2/jsf-2-link-commandlink-and-outputlink-example/

jquery - Bind Infinite Scroll + Masonry plugins -

i use infinite scroll , masonry plugins display pictures. i'm stuck html part. i use code below bind 2 plugins don't know how display html class .navigation , .nav-previous a in dom make work. $(window).load(function(){ // main content container var $container = $('.grid'); // masonry + imagesloaded $container.imagesloaded(function(){ $container.masonry({ // selector entry content itemselector: '.grid-item', columnwidth: 300, "gutter": 10 }); }); // infinite scroll $container.infinitescroll({ // selector paged navigation (it hidden) navselector : ".navigation", // selector next link (to page 2) nextselector : ".nav-previous a", // selector items you'll retrieve itemselector : ".grid-item", // finished message loading: { finishedmsg: 'no more pages load.' } }, // trigger masonry callback function( newelements ) { // hide new items while loading var $newelems = $( newelements...

angularjs - UI Router and Rails: Template is Missing -

i creating application rails , angular. using ui.router . when visit route via ui-sref link, loads. however, if refresh page, following error: missing template posts/show, application/show {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder]}. the home page (root of site) not have problem. also, if type in url, /posts/1, same message, if click ui-sref link post, page load. (though refreshing page break it.) behavior might shed light on misconfiguration can click ui-sref link route /login – route undefined on rails side, defined in angular routes (app.js). however, when try reach /login other means, or if refresh /login, error: 'no route matches [get] "/login"' routes.rb rails.application.routes.draw devise_for :users, :skip => [:registrations] root to: 'application#angular' resources :posts, only: [:create, :index, :show, :update, :destroy] resources :comments, only: [:s...

sql - MySQL Custom calculate views -

i having difficulty trying combine set of queries using. having execute multiple queries different years , cid numbers. (cid 1-5, years currentyear currentyear-6) current sql statement: select 1 cid, 2015 `year`, ( select sum( legacy_reports_payments.amountpaid ) * -1 payments legacy_reports_payments datepaid >= "2015-01-01 00:00:00" , datepaid < "2015-02-01 00:00:00" , cid = 1) paymentsjan, ( select sum( legacy_reports_payments.amountpaid ) * -1 payments legacy_reports_payments datepaid >= "2015-02-01 00:00:00" , datepaid < "2015-03-01 00:00:00" , cid = 1) paymentsfeb, ( select sum( legacy_reports_payments.amountpaid ) * -1 payments legacy_reports_payments datepaid >= "2015-03-01 00:00:00" , datepaid < "2015-04-01 00:00:00" , cid= 1) paymentsmar, ... this returns: cid | year | paymentsjan | paymentsfeb | ... 1 | 2015 | 3000.00 | 3000.00 | ...

javascript - Build embeddable HTML page -

i'm new html5 i'm trying make basic paint/whiteboard webpage embeddable other website. the whiteboard consist of 3 files: index.html, app.js , style.css what i'm asking how make more widget embeddable where? i have did many searches , confused, between building jquery widget http://alexmarandon.com/articles/web_widget_jquery/#loading-javascript-libraries or don't have there many separate files? any recommendation , guidance highly appreciated thanks i think answer here depends on target audience. @lucasnadalutti correct iframe may universally accepted way embed entire html page, if page needs interact host site's other elements, data, or server in way, you'll want pursue approach. since you're creating widget meant embedded in other people's websites, target audience other developers, since ones might choose use widget on sites build. assuming developers target audience widget, create wordpress plugin, jquery plugin, or num...

ruby - Rails 4 model formatting and hashes (really basic) -

i have basic validation in model: validates :student_number, :presence => true, :length => { :maximum => 255 }, :uniqueness => true so that? here's best guess, if kindly tell me i'm mistaken, i'd appreciate it. validates method. send symbol :first_name , :presence => true , is...a hash :presence key , true value? except doesn't hash, @ least not according docs . and :length => { :maximum => 255 } same sort of entity (hash?) :presence => true expects hash argument? thanks assistance. ruby allows drop parentheses , brackets if can infer locations itself; in case, rewrite code as: validates(:student_number, { :presence => true, :length => { :maximum => 255 }, :uniqueness => true }) which method call, passing first argument attribute validate, , second argument validation options, hash. note: explanation ...

Future proof JSON schema -

is possible force known objects ("enemy" , "friend") defined while other objects allowed? i've added last object {"type": "object"} display intended behaviour - in reality last object overrule 2 defined objects ("enemy" , "friend") causing kind of object valid schema. if remove last object, allow 2 objects nothing else. json schema (using array faster testing): { "type": "array", "items": { "anyof": [ {"$ref": "#/definitions/friend"}, {"$ref": "#/definitions/enemy"}, {"$ref": "#/definitions/future"} ] }, "definitions": { "friend": { "type": "object", "properties": { "time": {"type": "string"}, "value": {"type": "number", "minimum":...

matlab - How to recursively fill an array with functions? -

so i'm trying write function generate hermite polynomials , it's doing super crazy ... why generate different elements h when start different n ? inputting hpoly(2,1) gives h = [ 1, 2*y, 4*y^2 - 2] while hpoly(3,1) , h = [ 1, 2*y, 4*y^2 - 4, 2*y*(4*y^2 - 4) - 8*y] ( (4y^2 - 2 ) vs (4y^2 - 4 ) third element here ) also, can't figure out how evaluate expression. tried out = subs(h(np1),y,x) did nothing. code: function out = hpoly(n, x) clc; syms y np1 = n + 1; h = [1, 2*y]; f(np1) function f(np1) if numel(h) < np1 f(np1 - 1) h(np1) = 2*y*h(np1-1) - 2*(n-1)*h(np1-2); end end h y = x; out = h(np1); end -------------------------- edit ---------------------------- so got around using while loop instead. wonder why other way didn't work ... (and still can't figure out how evaluate expression other plug in x beginning ... suppose that's not important, still nice know...) sa...

autocad - auto lisp to retrieve project names from drawings -

i have client hard drive has crashed. able recover data in enumerated files, no dates, sizes or kind of naming scheme. these drawing files autocad, , there literally tens of thousands of these files. drawings have title blocks opening , renaming hand, take century. know of lisp can use open drawings , grab text title block? have tried myself have failed miserably. if text require in same location based on absolute coordinates , possibly layer/text style/text height/etc., might still have chance. you follow type of pattern: open document, zoom extents, select text entities given coordinates need search @ using bounding or crossing selection window, loop through returned selection set (possibly comparing contents of text string regular expression validation), extract value if it's located correctly, store current file name , extracted text value in csv, xml, xls file, close document, repeat. this give complete list of documents current name , required...

sql server - Prompt user with yes/no textbox during SQL query -

what ways there create textboxes during sql query? have query searches duplicate rows in database. i'd inform user of duplicates , prompt them textbox says "250 duplicate entries have been found. delete them? yes/no" if yes, data deleted. if no, nothing happens. unfortunately can't sql. you'd have use else build interface can prompt user input. javascript, php, c#, or shell scripting language work this.

c - How to malloc linked list node while reading file -

i've posted question similar this, able further narrow down issue. i'm pretty sure know problem is, i've been stuck figuring out how solve it. //assuming typedef struct person person; struct person{ char first_n[100]; char last_n[100]; char middle_n[100]; struct person* next; }; void open_file_and_read(char* file){ file* fp = fopen(file_name, "r"); if (fp != null){ while (!feof(fp)){ person* person = malloc(sizeof(person)); person->next = null; while (fscanf(fp, "%s %s %s", person->first_n, person->last_n, person->middle_n) == 3){ add_to_contacts(person); } } } } void open_write_file(char* file){ file* filep = fopen(file, "w"); person* copy; (copy = front; copy != null; copy=copy->next){ fprintf(filep, "%s %s %s\n", copy->last_n, copy->first_n, c...

rebol - file stop read when line reached -

i have code below begin read rest of file after have found line containing string "start" foreach line clines [ if find [%start] line [ print line ] ] i can't figure out documentation.. what's going on here? seems logical me. you have read file before can search in content of file. maybe looking like clines: read/lines %myfile found: false foreach line clines [ if [ found found: find line "start" ] [ print line ] ] an other way be cfile: read %myfile print [ cfile: find cfile "start" find/tail cfile lf ]

javascript - Include an angular template in another using webpack -

i have issue using angular , webpack. project composed of multiples views controllers. for example, have view usersummary.tmpl.html load list of users. reuse template in groupsummary.tmpl.html display users too. i can't use ng-include because views contained in bundle.js, nothing else. use webpack include views directly in another. is possible? to enable must configure "relativeto" parameter, otherwise template partials loaded @ "/home/username/path/to/project/path/to/template/" (check bundle.js you're leaking username in projects) var ngtemplateloader = ( 'ngtemplate?relativeto=' + path.resolve(__dirname, './src/') + '!html' ); module.exports = { ... module: { loaders: [ {test: /\.html$/, loader: ngtemplateloader}, ], }, ... } then in code, side-effect require: // src/webapp/admin/js/foo.js require('../../templates/path/to/template.html'); then ...

oracle - Confluence DB Connection Setup -

i reading atlassian's confluence setup guide oracle database connections, impression setting connectivity between oracle , confluence can done @ installation of confluence, not afterwards. i trying create relationship between installed confluence , oracle. can done? take @ document. should out. migrating database

JSoup - preserve html entities when outputting as utf-8? -

i want preserve html entities while using jsoup. here utf-8 test string website: string html = "<html><body>hello &#151; world</body></html>"; string parsed = jsoup.parse(html).tostring(); if printing parsed output in utf-8, looks sequence &#151 gets transformed character code point value of 151. is there way have jsoup preserve original entity when outputting utf-8? if output in ascii encoding: document.outputsettings settings = new document.outputsettings(); settings.charset(charset.forname("ascii")); jsoup.parse(html).outputsettings(settings).tostring(); i'll get: hello &#x97; world which i'm looking for. you have hitted missing feature of jsoup (as of writing jsoup 1.8.3). i can see 3 options: option 1 send request feature on https://github.com/jhy/jsoup i'm not sure you'll added soon... option 2 use workaround provided in answer: https://stackoverflow.com/a/34493022/36357...

Computing the Jacobian of vectorized ODEs in MATLAB -

this works fine: syms b x jacobian ([a*x - a*b, a*b],[a, b]) but this: syms b(i) x = 1:6 jacobian ([a*x - a*b(i), a*b(i)],[a, b(i)]) returns error: error using sym/jacobian (line 37) second argument must vector of variables. in opinion second argument is vector of variables don't understand error. is possible differentiate respect vector of odes e.g. b(i) ? how go it? the declaration syms b(i) creates symbolic function b of i . so, if vector of doubles passed b(i) , output vector of function values: >> syms b(i) >> b(1:6) ans = [ b(1), b(2), b(3), b(4), b(5), b(6)] >> b(i) = i^2; % defining actual function generate actual values >> b(1:6) ans = [ 1, 4, 9, 16, 25, 36] so error correct: have list of values. create vector of variables, use sym function >> b = sym('b',[1,6]) b = [ b1, b2, b3, b4, b5, b6]

HTTP Post in ruby NoMethodError -

i trying make http post using require 'net/http' here request token_url = 'http://www.[url].com/oauth/token' uri = uri(token_url) req = net::http::post.new(uri) req.basic_auth env['oauth_id'], env['oauth_password'] req.set_form_data({ 'grant_type' => 'client_credentials' }) resp = net::http.new(uri.host, uri.port).start {|http| http.request(req) } json.parse(resp.body)['access_token'] i keep getting error: nomethoderror - undefined method 'empty?' #<uri::http:0x007fb2ed01bdf8>: this happens on line " req = net::http::post.new(uri) ". ideas why? figured out: replace req = net::http::post.new(uri) with req = net::http::post.new(uri.request_uri)

node.js - How to dynamically add an object in schema? -

i have collection this- var schema= new mongoose.schema({ username:{type:string}, responses:{type:mongoose.schema.types.mixed} }); i save document in collection like- { username:anonymous,responses:{}} now want update - {username:anonymous,responses:{tst123:{duration:30,res:{}},tet456:{duration:50,res:{}}} i want update document in following step goes- 1) responses:{} 2) responses:{test123:{},res:{}} 3) responses:{test123:{dur:30,refresh:false},res:{{key1:val1}} } 4) responses:{ test123:{dur:30,refresh:false},res {{key1:val1},key2:val2} } similarly, want add test456 , more tests, how achieve this? use $set operator in update method follows: var schema= new mongoose.schema({ username: { type: string }, responses: { type: mongoose.schema.types.mixed } }); var thing = mongoose.model('thing', schema), query = { 'username': 'anonymous' }, update = { '$set': { 'response...

ruby - Rubocop RSpec Describes are failing -

actually i'm trying fix issues: do not use multiple top level describes - try nest them. the first argument describe should class or module being tested. i have 8 tests in format: describe 'publicancreatorscreate.init_docu_work' 'accesses directory , creates there initial documentation' publicancreatorscreate.init_docu_work(title, type, language, brand, db5) dir.exist?(title) :should == true end end but false? first argument contains tested class , method. normally such describe written as: describe publicancreatorscreate, '.init_docu_work' or describe publicancreatorscreate describe '.init_docu_work' it sounds rubocop-rspec expecting second form.

Compare values in a single array and return the key in php -

i have array this: $age=array("peter"=>43,"ben"=>67); . the array contains 2 key value pairs. first need check if values of these 2 keys same. if same returns key of these 2 value, otherwise return false. here value 43 , 67 not same should return false. if 2 values same : $age=array("peter"=>43,"ben"=>43); . it should return key "peter" , key "ben" , maybe store keys in array reason find if 2 people of same age if same age several other things. appreciate help. just unique values , see if there 1: if(count(array_unique($age)) === 1) { return array_keys($age); } else { return false; } because bored, here 2 others. assuming 2 elements: if(($v = array_values($age)) && $v[0] === $v[1]) { return array_keys($age); } else { return false; } also, should work multiples: if((array_sum($age) % count($age)) === 0) { return array_keys($age); } else { retu...

xcode - ioS Swift: Unexpectedly found nil while unwrapping optional value -

while trying read contents of file var: var mytext = "" ... println(downloadfilepath) mytext = string(contentsoffile: downloadfilepath, encoding: nsutf8stringencoding, error: nil)! i error: unexpectedly found nil while unwrapping optional value the file present, , generated earlier. size , contents of file may vary @ each run. same code works sometimes. could size of file (21k) or contents - cause this? trust me, compiler. know i'm doing. i'm taking off seatbelt , helmet. that's tell compiler when use force-unwrap operator, ! , or deal "implicitly unwrapped optional" type such string! . avoid @ costs. try restructuring code this: assert(nil != (downloadfilepath string?)) var error: nserror? = nil if let mytext = string(contentsoffile: downloadfilepath, encoding: nsutf8stringencoding, error: &error) { println("contentsoffile called successfully!") println("mytext: \(mytext)") } else { print...

java - How to output elements of an ArrayList as elements are being added? -

i making program analyzes set of student marks. user should able type in grade (for example, 92, 80, or 50) , should appear in textarea provided when press add button. i'm using arraylist of integers add these marks elements, , displaying them correctly , in ascending order. when try this, output displays number typed in, , replaces number once add new one. if try add number that's smaller, keeps number before. feel logic wrong. here code have far: private void addbuttonactionperformed(java.awt.event.actionevent evt) { integer grade; grade = integer.parseint(markinput.gettext()); //i convert string integer able add arraylist if (grade >=0 & grade <=100){ markslisting(); //this calls method displays items in arraylist } else { errorlabel.settext("invalid grade. please enter number between 0 , 100."); } } private void markslisting() { ...

html - Customizing default tooltip using css -

i know there lot of examples customizing tooltip of html element can't make working. i have simple anchor looks following: <a href="javascript:void(0)" class="tooltipitem" title="email address can used contact you." tabindex="-1" data-toggle="tooltip" data-placement="right">?</a> and created following css style (i copied example): a[title]:hover:after { content: attr(title); padding: 4px 8px; color: #333; position: absolute; left: 0; top: 100%; white-space: nowrap; z-index: 20px; -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; -moz-box-shadow: 0px 0px 4px #222; -webkit-box-shadow: 0px 0px 4px #222; box-shadow: 0px 0px 4px #222; background-image: -moz-linear-gradient(top, #1111ee, #cccccc); background-image: -webkit-gradient(linear,left top,left bottom,color-stop(0, #eeeeee),color-stop(1, #cccccc)); background-image: -webkit-linear-gradie...

c++ - passing an array of structs to a function and changing it through the fucntion -

so code wont compile reason. error 3 error c2036: 'pjs *' : unknown size error 4 error c2100: illegal indirection error 5 error c2037: left of 'size' specifies undefined struct/union 'pjs' void initarray(struct pjs* array) { (*array[1]).size = 1; } struct pjs{ char* name; int size; int price; }; int main(int argc , char** argv) { struct pjs array[10]; initarray(array); system("pause"); return (0); } following may help: struct pjs{ char* name; int size; int price; }; // safer use 1 of following declaration // void initarray(pjs *array, std::size_t size) // simpler // void initarray(pjs (&array)[10]) // more restrictive unintuitive syntax void initarray(pjs* array) { array[1].size = 1; } int main() { pjs array[10]; initarray(array); } definition of pjs should given before use (or requiring size). array[1] pjs *array[1] illegal (as pjs no have operator* ) ...

perl - How are hash keys sorted? -

until today , thought hash keys randomised when returned. however, entry in perldoc on keys suggests otherwise: hash entries returned in apparently random order. actual random order specific given hash; exact same series of operations on 2 hashes may result in different order each hash. there other entries on relate - pertinent accepted answer this question. the following code returns apparently randomised hash keys: %hash; $hash{$_}++ 1 .. 100; keys %hash; can me understand how not actually random? how hash keys sorted depends on version of perl using. should not depend on seeming order associated version. includes assuming somehow randomization involved appropriate used in other circumstances statistical qualities of randomness matters. from 5.18 hash overhaul : hash overhaul changes implementation of hashes in perl v5.18.0 1 of visible changes behavior of existing code. by default, 2 distinct hash variables identical keys , val...

excel - If two cells contains certain text put the text value of the adjacent cell into a new cell -

i wanted ask how in excel can match text value in 2 columns , if there match, copy/paste value of adjacent cell new cell. for example: b c l m gene_id gene value ... gene_id gene xloc001 top 20 xloc003 ? xloc002 high 5 xloc001 ? xloc003 left 45 xloc002 ? xloc004 right 10 xloc004 ? the formula in column m in first row in column l , find match in column a. if there match return value in column b. can copy/paste formula other rows in column m. the output be: b c l m gene_id gene value ... gene_id gene xloc001 top 20 xloc003 left xloc002 high 5 xloc001 top xloc003 left 45 xloc002 high xloc004 right 10 xloc004 right use display default message of ...

c# - AsyncPostback Trigger - Textbox value not getting sent back -

my updatepanel <form id="form1" runat="server"> <asp:scriptmanager id="scriptmanager1" runat="server" enablepagemethods="true"></asp:scriptmanager> <asp:updatepanel id="up1" updatemode="conditional" runat="server" childrenastriggers="false"> <triggers> <asp:asyncpostbacktrigger controlid="txtname" eventname="textchanged"/> </triggers> <contenttemplate> <asp:textbox id="txtname" runat="server" autopostback="true" ontextchanged="txtname_textchanged" /> <asp:textbox id="txtphone" runat="server" autopostback="true" /> </contenttemplate> </asp:updatepanel> </form> why isn't value of textbox (txtname) getting sent server when loses focus? a...

http - golang mux HandleFunc always 404 -

i try handle http request using mux instead of standart handlefunc net/http, because of reasons. http used work, mux doesnt. import ( _ "github.com/go-sql-driver/mysql" "github.com/gorilla/mux" _ "io/ioutil" "net/http" ) func init() { mx := mux.newrouter() //create poll mx.handlefunc("/poll", pollcreate) mx.handlefunc("/poll/{id}", loadpoll) mx.handlefunc("/poll/vote", castvote) http.listenandserve(":8080", mx) } the following post request localhost:8080/poll results in: info 2015-06-02 16:23:12,219 module.py:718] default: "post /poll http/1.1" 404 19 found solution. change http.listenandserve(":8080", mx) to http.handle("/", mx)

rename a string in a perl script eg name("this stays the same") -

perl -pi-back -e 's/actual_word\(`something`\)/expected_word\(`something`\)/g;' \ inputfile.txt i need "something" stay same. variable changes. i think should it? perl -pi-back -e 's/actual_word(.*)/expected_word($1)/g;' inputfile.txt you capture word in brackets , reuse via $1 in replacement. (you may need more brackets - it's unclear if additional required based on input).

javascript - Dropdown closes after every click -

dropdown closes after every mouse click. dropdown should close after hitting "close (x)" button. how can that? plunk: http://plnkr.co/edit/7mcboyfbrt3fnl2vjljh?p=preview <!doctype html> <html> <head> <link rel="stylesheet" href="style.css"> <script src="script.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> </head> <body> <h1>hello plunker!</h1> <div class="btn-group"> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false"> action <span class="caret"></span> </button> <ul clas...

Android Studio Gradle Sync error: configuration with name 'default' not found -

i using bottomsheet library create bottomsheet menu explained in google documentation. i added bottomsheet library project when sync gradle getting error message. tried answers listed @ error: configuration name 'default' not found in android studio , other solutions listed on stackoverflow issue still persists. here build.gradle , settings files of project: bottomsheet/build.gradle buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.2.3' } } allprojects { group = pom_group_id version = pom_version repositories { jcenter() } tasks.withtype(javacompile) { options.encoding = "utf-8" } } task wrapper(type: wrapper) { gradleversion = '1.12' } app/build.gradle apply plugin: 'com.android.application' android { compilesdkversion 21 buildtoolsversion "21.1.2" defaultconfig { ...

vb.net - Using LINQ to combine object and nested collection information into a new object -

using linq, possible combine properties both object , nested collection of object new object? each item in nested collection, want create new object has nested object information coupled parent object's info. using sample scenario, i'm trying this: teachers.select(function(item) new teacherrecord() {.teacherid = item.id, .teachername = item.name, .studentid = ? , .studentname = ?}).tolist() sample classes public property teachers list(of teacher) public class teacher public property id integer public property name string public property room string public property students list(of student) end class public class student public property id integer public property name string end class public class teacherrecord public property teacherid integer public property teachername string public proper...

python 2.7 - Submit Button Confusion and Request being sent Twice (Using Flask) -

i'm pretty trying create web app takes 2 svn urls , them. the code form simple, i'm using wtforms class svn_path(form): svn_url=stringfield('svn_path',[validators.url()]) i'm trying create 2 forms 2 submit buttons submit 2 urls individually test3.html looks this: <form action="" method="post" name="svnpath1"> {{form1.hidden_tag()}} <p> svn directory: {{form1.svn_url(size=50)}} <input type="submit" value="update"> <br> {% error in form1.svn_url.errors %} <span style="color: red;">[{{error}}]</span> {% endfor %} </p> </form> <form action="" method="post" name="svnpath2"> {{form2.hidden_tag()}} <p> svn directory: {{form2.svn_url(size=50)}} ...