Posts

Showing posts from August, 2014

javascript - How do I indent my code with the tab-space key? -

Image
for example, how can type js code looks firefox console: if (10 > 5) { alert("hello world!"); alert("how doing today?"); alert("i'm doing great, thanks!") } without resorting using space bar or operating system's clipboard? i'd able use tab key indent code in firefox console. whenever press tab, firefox goes through elements of browser , web page without indenting code. i'm using console provided ctrl+shift+k shortcut. you use scratchpad . better-designed multi-line code editing, , supports using tab character indent code. you can find under developer tools menu. tools > web developer > scratchpad on os x, , menu > developer > scratchpad on other platforms. you can add toolbox under toolbox options (the settings gear), , checking scratchpad checkbox.

apache spark - PySpark Create Multi Indexed Paired RDD with function -

a little while ago asked question organizing , structuring rdd multiple keys. see pyspark suggestion on how organize rdd each object in current rdd contains start_time , end_time , id , , position . i want group objects id , time . group 2 or more objects if have both same id or overlapping times. the logic finding overlap pretty easy: if x1.start_time > x2.start_time , x1.start_time < x2.end_time if x2.start_time > x1.start_time , x2.start_time < x2.end_time i don't quite how go creating paired rdd logic though. any suggestions appreciated, thank you! i think simplest way join on id , filter result (if there aren't many same id). i'd start mapping rdds (id, record) , doing join.

monodevelop - C# not outputting to console -

i'm sure there's simple answer, none of other stack overflow posts has helped me. code not log console, , it's hard useful state of affairs. using system; using system.diagnostics; namespace learning { class mainclass { public static void main (string[] args) { debug.log ("this?"); debug.print ("how this?"); console.writeline ("work"); console.readline (); } } } i've been able write console before, don't know why it's being persnickety now. probably because code doesn't compile. log() static method of debugger, not debug, , takes 3 arguments: level, category, , message. public static void main (string[] args) { system.diagnostics.debugger.log(1, "category", "this?"); system.diagnostics.debug.print ("how this?"); console.writeline ("work"); console.readline (); } it...

Listening to the HTML5 file system in a Chrome Application -

i working on google chrome app reads , writes sandboxed local file system. i accessing file system invoking window.webkitrequestfilesystem || window.requestfilesystem this large application, , have code components creating , deleting files (call them producers), , other code components displaying files (the consumers). for clean separation of code, don't want producers , consumers know 1 another. consumers watch file system, , react appropriately when files created or modified. sadly, appears framework provides no way add listener local file system. am correct in saying that? it looks in works , may land within next few months. see relevant issue tracker

perl - Using HTTP::Server::Simple::CGI, how do I get the headers? -

basically, question similar how access http request headers in http::server::simple::cgi? the answer use parse_headers(), there no example how use properly. tried use parse_headers() i'm not getting result, stops @ parse_headers() program stucked. couldn't add comment on question above since don't have enough rep so, created new question. below sample code, example code cpan added parse_headers: #!/usr/bin/perl { package mywebserver; use http::server::simple::cgi; our @isa = qw(http::server::simple::cgi); use data::dumper; %dispatch = ( '/hello.cgi' => \&resp_hello, # ... ); sub handle_request { $self = shift; $cgi = shift; $path = $cgi->path_info(); $handler = $dispatch{$path}; $header = $self->parse_headers(); open f,qq{>>~/mywebserver.log}; $dump = data::dumper->dump([$header], [qw($header)]); print f $dump; close f; if (ref($handler) eq "code") { print...

css - Centering a variable based title that is positioned absolutely -

alright have page that's title changes based on person logged in (their name title of page). because of fact name going different means needs positioned via center of text expand out horizontally both ways. i'm uncertain how approach , have tried few things due variable length of title none of suggestions have panned out. give basics of i'm @ code wise: #profteamname{ position:absolute; text-align:center; top:220px; left: 550px; color: white; text-shadow: 1px 1px 2px black, 0 0 1em blue, 0 0 0.2em darkblue; text-decoration:underline; i wouldn't against using relative positioning. long expand horizontally. (prefer use absolute positioning long story there take can get) thank guys time. rather positioning div left side of page, stretch across entire window (or container div on page) using width:100%; . it'll take entire width , align text - regardless of length - in middle of div. css .header { position:absolute; text-align:center; top:5...

mysqlbinlog - How to read a mysql binlog -

i want write service tail mysql bin log notifications database changes. is there open source library reads , parses mysql bin log in row format? use mysqlbinlog . the server's binary log consists of files containing “events” describe modifications database contents. server writes these files in binary format. display contents in text format, use mysqlbinlog utility. can use mysqlbinlog display contents of relay log files written slave server in replication setup because relay logs have same format binary logs. source: https://dev.mysql.com/doc/refman/5.6/en/mysqlbinlog.html

asp.net mvc - Orchard CMS modules are disabled after remote deployment - How can I fix this? -

i new orchard cms , trying familiar deploying shared hosting service, smarterasp.net hosting service. when asked smarterasp tech support why happening, said not experts in orchard cms , cannot me. i looking other hosting services, have feeling making beginner mistake. my problem occurs when deploy web app remote web site. in local app, changed theme , enabled single module,. after deployment, upon starting app, runs, pages appear original thememachine theme , enabled modules disabled. i found similar posting (on orchardpros.net) named: "module not working when published" sfmskywalker asked if module (oforms) had been added solution project. researching how add newly installed module solution file. below, have included details deployment procedures , results. any suggestions appreciated. thanks. i working in windows 7 ultimate , using visual studio 2013 community. i using orchard source code version 1.8.1 , sql server express 2014 database. the c...

Excel ADOB SQL Recordsets, ORDER BY works on one xlsx file but not on others? -

why order work on xlsx files , not on others? i build sql statements (using adob) move data closed workbooks (i need speed , use sql sort data) active workbook. below 2 strings use , both work associated files. mysql = "select * [" & sourcesheet$ & "$" & sourcerange$ & "] order " & targetsortcolumn & ";" 'this works data dictionary. mysql = "select * [" & sourcesheet$ & "$" & sourcerange$ & "];" 'this works cost file. i cannot find fundamental differences between 2 files. trying copy worksheet each closed workbook current workbook , sort order by. i jump error trap, when using order on cost file. when hit second statement below triggers error trap. set con = createobject("adodb.connection") set data = createobject("adodb.recordset") i have used debugger check , parameters passed procedu...

javascript - jQuery Tree Up Traversal -

simple question. i'm trying target 'i' tag panel-indicator class in tree. additionally need remove 'hide' class panel-edit 'i' tag. here's html: <div class="panel panel-default"> <div class="panel-heading" role="tab" id="headingone"> <i class="panel-indicator glyphicon glyphicon-chevron-down pull-right"></i> <i class="panel-edit glyphicon glyphicon-pencil pull-right hide"></i> <h4 class="panel-title" id="-collapsible-group-item-#1-"> <a data-toggle="collapse" data-parent="#collapseone" href="#collapseone" aria-expanded="false" aria-controls="collapseone" class="collapsed">system details</a> <a class="anchorjs-link" href="#-collapsible-group-item-#1-"><span class=...

javascript - CSP unsafe-eval using Google Maps API -

getting script-src 'unsafe-eval' error when trying use google maps' api. <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script> here's console error: uncaught evalerror: refused evaluate string javascript because 'unsafe-eval' not allowed source of script in following content security policy directive: "script-src 'self' ' *.gstatic.com *.googleapis.com *.google-analytics.com *.google.com". you think google wouldn't have unsafe-eval triggers in libraries. incase side code below: js function initialize() { // create map. var mapoptions = { zoom: 4, center: new google.maps.latlng(37.09024, -95.712891), maptypeid: google.maps.maptypeid.roadmap, zoomcontrol: true, streetviewcontrol: false }; var map = new google.maps.map(document.getelementbyid('map-canvas'), mapoptions); google.maps.event....

android - Softkeyboard overlaps EditText -

Image
my root layout is: <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <include layout="@layout/toolbar" /> <framelayout android:id="@+id/content" android:layout_width="match_parent" android:layout_height="match_parent"/> </linearlayout> content framelayout being replaced layout: <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" tools:ignore="unusedattribute"> <framelayout android:id="@+id/messa...

php - What does the security implications for default character set in mysqli_real_escape_string() means? -

in php documentation mysqli_real_escape_string(), written that caution security: default character set the character set must set either @ server level, or api function mysqli_set_charset() affect mysqli_real_escape_string(). source mysqli_real_escape_string in further link character set, mentioned that the character set should understood , defined, has affect on every action, , includes security implications. suource character sets why necessary set character set sake of security , security implications include? can anyone, explain concept behind lines ? thanks in advance how sql queries parsed dependent on connection character set. if did query: $value = chr(0xe0) . chr(0x5c); mysql_query("select '$value'"); then if connection character set latin-1 mysql see invalid: select 'à\' whereas if character set shift-jis, byte sequence 0xe0,0x5c interpreted double-byte character: select '濬' add st...

regex - Truncate words within each element of a character vector in R -

i have data frame 1 column character vector , every element in vector full text of document. want truncate words in each element maximum word length 5 characters. for example: a <- c(1, 2) b <- c("words longer 5 characters should truncated", "words shorter 5 characters should not modified") df <- data.frame("file" = a, "text" = b, stringsasfactors=false) head(df) file text 1 1 words longer 5 characters should truncated 2 2 words shorter 5 characters should not modified and i'm trying get: file text 1 1 words longe 5 chara shoul trunc 2 2 words short 5 chara shoul not modif i've tried using strsplit() , strtrim() modify each word (based in part on split vectors of words every n words (vectors in list) ): x <- unlist(strsplit(df$text, "\\s+")) y <- strtrim(x, 5) y [1] "w...

What image information is considered a good idea to store in a MySQL database for example? -

i going store images in folders , not in database. information images stored in database. image table looks this: drop table if exists database.image; create table if not exists database.image ( id int(11) unsigned not null auto_increment primary key, filename varchar(255) not null, extension varchar(10) not null, created int(11) unsigned not null, user_id int(11) unsigned not null, deleted int(1) not null default 0 ) character set utf8; alter table database.image add index (user_id); is there point of saving example size of image future? or maybe storing dimensions idea? considered worth saving information future in image table this? i need store kind of thumbnails too. input appreciated. the data save should depend on how plan use data in future. if need show list of images sorted name filename enough. in case want add advanced image filtrat...

ios - How to partially mock external object -

i have class method test dependant object (keys object) apirouter.m + (nsurl*)apiurlwithpath:(nsstring*)path { mykeys *keys = [mykeys new]; nsstring *url = [nsstring stringwithformat:@"%@?api_key=%@", path, [keys apikey]]; return [nsurl urlwithstring:url]; } i trying partially mock keys object , return "my_api_key" value test method fails , returns real api key (e.g. as78d687as6d7das8da). apirouterspec.m describe(@"apirouter", ^{ it(@"should return url api", ^{ keys *keys = [keys new]; id keyspartialmock = ocmpartialmock(keys); ocmstub([keyspartialmock apikey]).andreturn(@"my_api_key"); nsurl *url = [apirouter apiurlwithpath:@"http://www.api.com/v1/events"]; expect([url absolutestring]).to.equal([nsstring stringwithformat:@"http://www.api.com/v1/events?api_key=my_api_key"]); }); }); maybe work you: somewhere outside test method: st...

java - Anybody implement saml 2.0 service provider with opensaml 2.5.1 -

i have implement saml 2.0 on code base has opensaml 2.5.1 (older version of cas) , unfortunately cannot make use of spring saml security extension (which uses new version of newer opensaml). have looked @ how spring extension handles authorization request/response , have reversed engineered extent. able make call sp idp (sso circle) , attempt login, 500 error upon submit: reason: unable single sign on or federation. is there sample java opensaml 2.5.1 code might shed light on doing wrong? or there other suggestions/ideas overlooking? thanks it turns out assertionconsumerservice url sending in request, different assertionconsumerservice value in metatada (sp.xml) , hence causing 500 errors

android - Should I use a Cursor or a CursorLoader? -

i have android app in have login system , other stuff communicate server. web server confirmation , lot of data. far using simple database. today implemented content provider working far. data contentprovider used cursor cursor = getcontentresolver().query(); , saw there option use cursorloader. difference between them ? in case should use ? saw have implement in every class cursorloader, can't make single class , call when it's needed ? as documentation states, cursorloader implements loader protocol in standard way querying cursors, building on asynctaskloader perform cursor query on background thread not block application's ui. this biggest advantage of using loaders, i.e. asynchronous. of other important advantages mentioned here . they provide asynchronous loading of data. they monitor source of data , deliver new results when content changes. they automatically reconnect last loader's cursor when being recreated after c...

javascript - Invisible to Transparent HTML/CSS Button? -

ok. i'm trying re create cool looking button found. example @ http://gyazo.com/cafe378e8340d71c341b7c52857b2689 see how first invisible it's faded little bit? here version far. -> please try on this! <3 html <button>metro 5.2</button> css body { background-image: url(http://p1.pichost.me/i/39/1624496.jpg); text-align: center; } button { border: 1; background: transparent; border-style: solid; border-color: #fff; border-radius: 1px; padding-left: 60px; padding-right: 60px; padding-top: 15px; padding-bottom: 15px; cursor: pointer; font-size: 1em; font-weight: 400; text-transform: uppercase; margin: 0; outline: 0; transition: .2s ease-in-out; color: #fff } button:hover { padding-left: 80px; padding-right: 80px; background-color: #bdc3c7; background: 0.4; } index.html: <button>metro 5.2</button> and css .. style.css: body { background-image: url(http://p1.pichost.me/i/39/162...

arrays - IntegerList help in Java -

so in class follow lab manual instructions. able step 1 , two, need step three. lab manuel instructions: add method void removefirst(int newval) integerlist class removes first occurrence of value list. if value not appear in list, should nothing (but it’s not error). removing item should not change size of array, note array values need remain contiguous, when remove value have shift after down fill space. remember decrement variable keeps track of number of elements. add option menu in integerlisttest test new method. integerlist public class integerlist { private int count; private double totalint; int[] list; //values in list //------------------------------------------------------- //create list of given size //------------------------------------------------------- void addelement(int newval) { if (count == list.length) increasesize(); list[count] = newval; count++; } void removefirs...

Create List of strings from the string inputted by the user c# -

i have method: public list<string> advmultikeysearch(string key) { string[] listkeys = key.split(','); string[] orsplit; list<string> joineddashkeys = new list<string>(); list<string> joinedsearchkeys = new list<string>(); (int = 0; < listkeys.length; i++) { orsplit = listkeys[i].split('|'); joineddashkeys.add(string.join(",", orsplit)); } (int = 0; < joineddashkeys.count; i++) { string[] split = joineddashkeys[i].split(','); (int j = 0; j < split.length; j++) { joinedsearchkeys.add(string.join(",", split[i])); } } return joineddashkeys; } i trying create method receives string keyword composed of words,comas, , '|' character. example, user enters glu|sal,1368|1199 and method should produce/return list of strings: "glu,1368", "glu,1199", "sal,1368...

html - Javascript onchange validation so that :valid and :invalid CSS selectors work -

this seems simple thing do, have not been able find this. how can use following: // html: <input type="text" onchange="validate()"> function validate(e) { e.preventdefault(); if(isvalid(this.value)) { // make valid somehow } else { // make invalid somehow } } so following css works might expect: input:valid { background: green; } input:invalid { background: red; } click "run code snippet" see! you can create custom validator , use setcustomvalidity function on element allow use of these selectors. this article describes how use html5 constraint api achieve this. example: #inputfield:valid { background-color: green; } #inputfield:invalid { background-color: red; } <html> <body> type value (must 'abc'): <input id="inputfield"> <button>check it!</button> <script type="text/javascript"...

ssis - Start new instance of job in sql server agent X minutes after last run was completed? -

is possible create sql server job run ssis project (or project) x minutes after last instance completed? for example: 1) run ssis job first time @ 3:10pm. 2) job runs 35 minutes. 3) once job ends, restart job 5 minutes after has completed. we had similar task scheduler: basically, set repeat task every 5 minutes do not start new instance . meant task executed 5 minutes after previous job instance completed , 2 instances not run in parallel. the reason want move sql server agent because today task remained "running" , way stop restart server. meant other running jobs affected. sql server agent have more control of actual package. also if job running , it's schedule tells run again ignores new request.

json - how to turn off power save mode in ILCE-QX1 camera using SDK? -

i using sony sdk develop solution using ilce-qx1 camera. need keep camera powered @ times camera power down if network connection has glitch. there no way in sdk have found tell camera not power down. using camera ac adapter camera has power.

c# - ASP MVC DropDownListFor Set Selected Value to Dictionary Value -

i have dropdownlistfor in markup: @html.dropdownlistfor( m => m.mydictionary[dictionarykey], model.myselectlist selectlist); and dictionary property in view model: public dictionary<keytypes, string> mydictionary { get; set; } myselectlist list of values, 1 through 5. in controller, right before return view, set dictionary value: _myviewmodel.mydictionary[dictionarykey] = "3" when page loads, selected value "1", not "3". however , if change dictionary string in view model , markup, dropdown has "3" selected on page load. how bind dropdown dictionary value instead of string? update i made partial view own dynamically filled model. model contains following properties: public string selectedvalue { get; set; } public myenum enumvalue { get; set; } public selectlist valuerange { get; set; } my partial view typed model, , contains dropdownlistfor: @html.dropdownlistfor( m => m.selectedvalue , ...

c++ - K-means and EM algorithms -

how can implement k-means & em algorithms without calling opencv functions image segmentation? i begin code : #include opencv2/highgui/highgui.hpp #include iostream using namespace cv; using namespace std; int main() { mat img = imread("testimage.png", 0); mat label_img; label_img.create(img.cols, img.rows, cv_8uc1); } how can continue ? k-means work iterating 2 steps till convergence, e-step , m-step. initialization: assign each pixel, @ random, 1 of k clusters. is, each entry in label_img choose number [0..k-1] @ random. expectation (e-step) given assignment of pixels clusters ( label_img ), can compute center of each cluster (simply mean of pixel values assigned cluster). @ end of stage you'll have k vectors pointing @ centers of k clusters. maximization (m-step) once have k clusters, compute distance of each pixel k centers , assign (by changing respective entry in label_img ) center closest pixel. @ end of sta...

python - A variable in my code won't define properly -

this code maths program making high school. struggling @ moment because can't figure out i've done wrong, says sum1 isn't defined. if please take time go through code , sort out grateful. my error on line: (line 130) message_to_screen("what is: " + str(sum1) + " + " + str(sum2), black, -100, "medium") do let me know if need clarify anything. thanks! # below importing modules need import pygame import random import time pygame.locals import * # initiates pygame pygame.init() # these defined colours white = (255,255,255) lightgrey = (200,200,200) black = (0,0,0) grey = (100,100,100) red = (255,0,0) yellow = (200,200,0) green = (34,177,76) # sets display width , height display_width = 800 display_height = 600 gamedisplay = pygame.display.set_mode((display_width,display_height)) pygame.display.set_caption('major league mathematics') clock = py...

networking - Windows 7 - "Local Area Connection" and IP address not found on startup? -

i running application on startup needs computer's ip address. when noticed ip address not found, wrote following batch script run on startup, runs ipconfig every few seconds. ipconfig timeout 3 ipconfig timeout 3 ipconfig timeout 3 ... i discovered minute, "ethernet adapter local area connection" found. ipconfig gives following result, number <32268.... 0243> registry key corresponding local area connection 1: tunnel adapter isatap.<32268...... 0243> media state . . . . . . . . . . . . . . : media disconnected connection-specific dns suffix . : tunnel adapter local area connection* 10: media state . . . . . . . . . . . . . . : media disconnected connection-specific dns suffix . : my 2 ethernet connections named "local area connection" , "local area connection 1", , "local area connection 1" disabled. after minute of ipconfig , timeout calls, "local area connection" shows correct ip address. thoughts ca...

c# - .net large for loop slowing down -

i have large for-loop (30k max iterations) seems consistently slowing down: the first thousand iterations take 1.34s after 12k iterations, next thousand take 5.31s after 23k iterations, next thousand take 6.65s the last thousand iterations take 7.43s in order gain little performance switched foreach loop for loop, , tried release configuration, can't find else in this question applies me. loop in async method why loop slow down? can avoided? for(int iter = 0; iter < largelist1.count; iter++) { var cl_from = largelist1[iter]; if(largelist2.any(cl => cl.str.contains(cl_from.str))) { datetime dt1 = //last write time of file datetime dt2 = //last write time of different file if(datetime.compare(dt1, dt2) > 0) { try { copyfile(//kernel32 copyfile file overwrite); globals.filex++; } catch(exception filexx) { ...

multidimensional array - Can you define a variable in MATLAB like a set? -

i want able deal 3d structures in matlab. i'm new matlab, , haven't seen answer question after googling it. if want define specific sphere explicitly, without using built in sphere function, how work? example, there way define variable r = (1,1,1) in xyz coordinate system, , define new variable/set s = {all s: distance (r,s) <= radius)}. immensely handy if that, i'm not sure how matlab deal that, involve infinite set of points, matlab have have defined maximum resolution. possible? great able define 3d structures in way. thank if all s: distance (r,s) <= radius) you mean all s in r 3 : distance (r,s) <= radius) then answer is: no, can't define set by extension (that is, enumerating elements), because set has uncountably infinitely many elements . but can define set s by intension . means can build rule (a function) that, given value x in r 3 , tell if x in s or not. namely, rule can built using anonymous function fo...

c# - How to optimize SipHash for 32-bit architecture -

so new siphash provides fast secure prf (aka keyed hash function). use ch-siphash , seems fastest c# implementation around. quite amazing performance (1140 mb/s) on i7 3630qm in 64-bit, when switch 32-bit, performance drops 316 mb/s, (for purposes) terribly slow. siphash makes heavy use of 64-bit operations, maybe it's not surprising, know how can optimize algorithm 32-bit processors (notably intel , arm). sha512 makes heavy use of 64-bit operations, yet on same pc 294 mb/s in 64-bit app, , 192 mb/s on 32-bit app, drop near significant. so cool tricks , optimizations can make siphash perform better on 32-bit architectures? best implement hash in c++ dll (using sse), looking managed (portable - needs work on mobile phones desktop) solution. some have implemented 32-bit version using sse3, performance not great either, maybe specific implementation done better. there exists chaskey , prf heavily based on siphash, designed microcontrollers (32-bit , less). unlike siphash...

c++ - OpenCV sparse matrix: how to get the indices of non-zero elements in a row/column -

is there way indices of non-zeros of specific row of 2d sparsemat, without looping on row? the following code, using loop, print results y-th row. for(int x = 0; x < sparse_mat.size(1); x++) { if(sparse_mat.ref<int>(y,x) != 0) std::cout<<x<<std::endl; } thank in advance suggestions! i don't have opencv, reading documentation found example: // prints elements of sparse floating-point matrix // , sum of elements. sparsematconstiterator_<float> = sparse_mat.begin<float>(), it_end = sparse_mat.end<float>(); double s = 0; int dims = sparse_mat.dims(); for(; != it_end; ++it) { // print element indices , element value const sparsemat::node* n = it.node(); printf("("); for(int = 0; < dims; i++) printf("%d%s", n->idx[i], < dims-1 ? ", " : ")"); printf(": %g\n", it.value<float>()); s += *it; } printf("ele...

c# - Programatically creating LookupAttributeMetadata in Dynamics CRM 2015 -

i migrate dynamics crm 2011 on premise instance dynamics crm 2015 online. i'm using current dyanmics crm sdk (current version 7.1) , have managed migrate custom attributes, except virtual , lookup ones, can't created via createattributerequest . now next, need migrate relationships. far i've been able necessary onetomanyrelationshipmetadata , manytomanyrelationshipmetadata . however, onetomanyrelationshipmetadata need pass lookupattributemetadata createattributerequest . onetomanyrelationshiprequest request = new onetomanyrelationshiprequest() { lookup = new lookupattributemetadata() { schemaname = "new_topicid", displayname = new label("subject", 1033), description = new label("subject description", 1033) }, onetomanyrelationship = new onetomanyrelationshipmetadata() { referencedentity = "subject", referencedattribute = "subjectid", refere...

go - route a PUT request without a third party routing library -

in this youtube video (at around 15:29) of golang talk blake mizerany, talks how build router without using third party package, covering in detail how construct route has variable component, such id. handler uses, first line showing how variable component of route (i.e. key) func producthandler(w http.responsewriter, r *http.request){ key := r.url.path[len("/products/":] switch r.method{ case "get": //do stuff case "post" //do stuff default: http.error(w, "method not allowed", 405) } } it's not clear presentation though actual route looks like. i'm trying build route handles put request id. when click element on page, sends put request route http://localhost:8080/products/1433255183951 i have route this http.handlefunc("/products/{id}", dosomethingwithproduct){ } and of course have func func dosomethingwithproduct(res http.responsewriter, req *http.request{ ...

c# - Async/Await handling group of HttpResponseMessage -

i previously posted question using httpclient async/await. i'm trying figure out how in such way make post calls execute @ same time while still being able handle resulting httpresponsemessage . this i've come with. however, being noob await/async, i'm still unsure if i'm doing correctly or not. verify proper way ... or @ least proper way. public async task processasync() { //query lists list<member> list = dbcontext.users.where(u => u.ismember).tolist(); //add members mailing list through web service await addmembersasync(list); } private async task addmembersasync(list<member> members) { using(var _client = new httpclient()) { //initialize http client ... var responses = await task.whenall(members.select(x => postmemberasync(x,_client))); await task.whenall(responses.select(r => processresponseasync(r,client))); } } private async task<httpresponsemessage> postmember...

Why can't NUnit file or assembly be found (C# dll)? -

Image
even when main empty, have following error while loading c# dll nunit: system.io.filenotfoundexception : not load file or assembly 'nunit.framework, version=2.6.3.13283, culture=neutral, publickeytoken=96d09a1eb7f44a77' or 1 of dependencies. system cannot find file specified. i don't understand why can't find it, have no clue start search. you can set reference copy local , example:

html - How to check if a check_box in simple_form has been checked -

here's html produces f.check_box :tos produces <input name="user[tos]" type="hidden" value="0"> <input id="user_tos" name="user[tos]" type="checkbox" value="1"> what need in controller check if it's been checked? assuming mean want find out if checked upon submission , it's value via params[:user][:tos] . submitted data form stored in params hash, , location equivalent name attribute of input. instance: if params[:user][:tos] == "1" # whatever here if checked else # whatever here if unchecked end if need react state of being checked on web page, cannot done controller, , must use javascript. like: if (document.getelementbyid('user_tos').checked == 1){ // whatever here if checked } else { // whatever here if unchecked } addendum when receiving parameter via controller, don't use value create new object (i.e. thing.create( thi...

python with Quickbooks Online API v3 -

i need implementing python app accesses quickbooks api. have written several apps use apis, once oauth world, bit lost. at rate, found quickbooks-python wrapper here: https://github.com/troolee/quickbooks-python but there 0 examples of working code showing how implement properly. imagine more experienced python programmer figure out how make work without instructions, seems i'm missing basics. if connected, work there... it seems documentation on github jumps around , more experienced programmer, make perfect sense. i'm not following... from quickbooks import * consumerkey = "fromapiconsole" consumersecret = "fromapiconsole" callbackurl = "https://quickbooks.api.intuit.com/v3" qbobject = quickbooks( consumer_key = consumerkey, consumer_secret = consumersecret, callback_url = callbackurl ) authorize_url = qbobject.get_authorize_url() # create service, , further set qbobje...

node.js - Hosting my MEAN stack web app on github pages -

i have project here on github. created gh-pages branch make hosted on github pages. link gave me hosted site here . i pretty new web apps , new mean stack web apps. question - how can access web app hosted via github? hosted link gives 404 error because don't have index.html file in root of project. "html" have in project in views folder , has "ejs" file extension (index.ejs). to run app on local machine start npm server: npm start then navigate http://localhost:3000/#/home in browser see app. is possible host app on github pages? need modify project in way make work? - know have change mongoose database pointer database portion work. pointers in right direction appreciated! github not host nodejs instances.

javascript - giving an input a dynamic value emeberjs -

so have each loop iterates on ember model: {{#each model.product.variants |variant|}} {{input type="radio" value=variant.id name="product_id" action="radiochecked" on="focus-in"}} {{/each}} what im trying set value of each input id of variant , part right here value=variant.id . seems works because example of html being rendered: <input id="ember821" name="product_id" type="radio" value="34"> i removed ember classes above input make fit in 1 line. now i'm trying when form submitted grab value of radio button checked. did give radio button action, action="radiochecked" on="focus-in" , try set product property on controller. here controller: export default ember.controller.extend({ selectedproduct: null, actions:{ radiochecked: function(){ console.log('action worked'); this.set('selectedproduct', valu...

c# - Extending member-access expression -

i have expression of type expression<func<towner, object>> created using lambda (syntax). has member-access expression somewhere in body. create expression selects property of mentioned expression's result. i terms of c# should this: expression<func<myclient, object>> exstartingpath = x => x.address; expression<func<myclient, object>> exextendedpath = extendselection(exstartingpath, "street"); //exextendedpath should equivalent x => x.address.street how should extendselection(...) implemented? should decompose existing expression , compose new 1 using traversing technique or there api can 'append' member selection? just grab body of lambda, apply member access that, , wrap whole thing new lambda. public static expression<func<tsource, ttarget>> extendselection<tsource, ttarget>( expression<func<tsource, ttarget>> expression, string member) { var body = expression...

git - Asana and SVN Integration -

asana has api out calling "rest" api. https://blog.asana.com/2012/04/announcing-the-asana-api/ some people have made post-commit script git allows add "#task-id" message section when make commit , add comment asana task adds message commit , provides link code file. has done svn? can't seem find online thought ask first before spending ton of time trying make svn and/or trying learn git , adding post commit script. if haven't found solution yet, bugify wrote py script creates json object send api (which comments/closes... bugs). need download product see they've done (the script comes tar - basic account free). don't think license authorizes use code if know python can @ script , write own connects asana api instead, correct parameters. see simple, , example gives name of functions call post data (mostly using subprocess.popen). http://support.bugify.com/kb/integrations/getting-started-with-scmvcs-integration .

javascript - How to show 'Please wait' GIF image on Ajax load -

am using ajax send request web server, show user gif image indicating them wait till request completed. can please me modify code load gif image on sending request. jquery(document).submit(function(e){ var create_acct_form = jquery(e.target); if(create_acct_form .is("#createacctform")){ // check if form want (delete check apply forms) e.preventdefault(); jquery.ajax({ type: "post", url: create_acct_form .attr("action"), data: create_acct_form .serialize(), // serializes form's elements. success: function(data) { console.log(data); if( data.status == 'error' ) { // error handling, show data.message or want. } else { // same above success $("#createacctform")[0].reset(); $("#create_acct-info").html(data) }...