Posts

Remove a space before an argument, while adding '(' and ')' with VIM surround -

using vim plugin vim-surround pretty extensively, , happy it. however, there 1 replacement witch haven't found nice shortcut. the usage case, following. need : def function argument to become (when cursor in middle of 'argument') def function(argument) my attempts didn't fulfil need: i have try ysiw) => def function (argument) # don't space after function ysaw) => def function( argument) # don't space before argument since, there shortcut vim, asking communitity me satisfy style obsession... without vim on hand, think nmap <f6> f xyse) or nmap <f6> ysiw)f x should trick.

javascript - revert object and its properties -

i have object var obj = { prop1 : { dummy1 : 0, dummy2 : 0, dummy3 : 0 }, prop2 : { dummy1 : 0, dummy2 : 0, dummy3 : 0 } }; and need revert dummy becomes object , props becomes it's properties. so need object this var obj = { dummy1 : { prop1 : 0, prop2 : 0 }, dummy2 : { prop1 : 0, prop2 : 0 }, dummy3 : { prop1 : 0, prop2 : 0 } }; sorry if stupid question, i'm tired , stuck on this. every appreciated , reworded. this achievable 2 for..in loops var obj = { prop1 : {dummy1 : 0, dummy2 : 0, dummy3 : 0}, prop2 : {dummy1 : 0, dummy2 : 0, dummy3 : 0} }; // start of interesting code var a, b, o2 = {}; (a in obj) (b in obj[a]) { if (!o2[b]) o2[b] = {}; // if o2 doesn't have yet, make new obj o2[b][a] = obj[a][b]; // swap } o2; /* { "dummy1": {"prop1": 0, "pr...

Leaflet Layer Control: select Layer inside Layer Group? -

i have leaflet layer control can select 1 of base layers, , have base layer layergroup can select sublayers display. i'm thinking of setup click radio button select base layer (the layer group), , under see list of checkboxes layers within show. there way using stock layer control? i looked examples , thumbed through leaflet api didn't find this. there no leaflet support layer hierarchies beyond layergroup level. use leaflet.groupedlayercontrol plugin achieve basic grouping in layer control panel, not actual hierarchy.

asp.net - Gridview change select row to an image? -

is possible change gridview select column image? when user clicks on select opens pdf gridview. possible instead have small pdf icon instead of select link? @ same time still able call: protected sub gridview1_selectedindexchanged(sender object, e eventargs) handles gridview1.selectedindexchanged convert select column templatefield , change button inside imagebutton . make sure command="select" stays, because that's gridview uses fire , handle selectedindexchanged event.

asp.net mvc 4 - how to get user info in Forms Authentication Across Applications? -

i have application on main domain user can login domain , authenticate across sub domain use form authentication , works fine. but not know how retrieve users information on sub domain . must have user id or somethings use retrieve user information sql server. how can handle scenario , transfer useful information use on sub domains retrieve user information? my application on mvc4 razor , .net 4.5. if user can authenticate across of subdomains, , leveraging forms authentication, can username in subdomains same way can in main domain: httpcontext.current.user.identity.name

java - Should ServletResponse isCommitted Always Be Checked Before Modifying The Response -

the title speaks itself, valuable check iscommitted() on type servletresponse ? particular example in using filter following if user isn't authorized perform action (csrf checks specific): if (!httpresp.iscommitted()) { httpresp.senderror(httpservletresponse.sc_unauthorized); } in case, feels overkill i've checked response. filter @ top of chain, there should nothing before commit response (let alone allow filter chain continue if did), can't feel assumption in name of defensive programming shouldn't making. feel it's practice check status of response. so, of being said, valuable check response @ point in time? , maybe extend further, practice check every time response modified? in case, can hardly find reason support other exception being thrown when csrf token not match (assuming happen in attack scenario). in general, based on when code executed know response has not been committed. not add check everywhere. some places add it:- a ...

android - CameraUpdateFactory zoom to does not zoom map -

i have method zooms map user's specified zoom level not zoom using cameraupdatefactory.zoomto(9f); however zoom correctly if this cameraposition position = new cameraposition.builder().target(location).zoom(9).build(); map.animatecamera(cameraupdatefactory.newcameraposition(position)); but requires have location zoom to. according docs looks access zoomto method statically when nothing happens. am using first method incorrectly? the method cameraupdatefactory.zoomto not directly alter map, instead returns cameraupdate value . value have new zoom level set , other parameters target, bearing, etc retained are. value take effect, need apply cameraupdate map using animatecamera(cameraupdate) or movecamera(cameraupdate)