Posts

Showing posts from May, 2010

javascript - Dynamic id assign to collapsible div -

i have set of records stored in sql database pull , display these on page using php , html. i'm trying create collapsible div hide of information record. when trying divs close records , not single record, question how assign unique id each individual div (say named each record name pulled database. here have far: $chnumber = $record['ch_number'];?> <div id="prof_prod" <!--style="display: none;"-->> <div class="groupbox showgraph"> <div class="header"> <div class="title-container"> <div class="title">part number: <i id="partnumber"></i><?php echo $record['ch_number'] ?></div> <div class="title">serial number: <i id="serialnumber"></i><?php echo $record['serial_number'] ?></div> <div class="t...

delphi - DCEF3 TChromium : iterate the DOM and click buttons / fill inputs -

because internet explorer dead, i'm in (long) process replace twebbrowser tchromium in applications. with twebbrowser had complete , documented interface access dom through ihtmlelement interface. since dcef3 documentation inexistent, i'm searching examples of how (if possible) iterate , manipulate dom in tchromium : select / element's html source click on button fill input focus control is there native interface it, or way using javascript directly ? any appreciated. thanks in advance ! realized through js code (fill input): if assigned(chromium.browser) , assigned(chromium.browser.mainframe) begin jscode:= 'document.forms[0].quick_email.value="email";'; chromium.browser.mainframe.executejavascript(jscode, 'about:blank', 0); jscode:= 'document.forms[0].quick_pass.value="pass";'; chromium.browser.mainframe.executejavascript(jscode, 'about:blank', 0); jscode:= 'document.forms[0].submit(...

How to structure an efficient points logging system in PHP/MySQL -

i have points system on blog type website, users can earn points contributing in different ways (commenting/ voting on posts/ voting on comments etc). how go logging points earned user in mysql database efficiently. currently i'm thinking of having following fields in it's own table: post_id, giving_user_id, receiving_user_id, type, date_added now, if site grows , have 1 million ... 500 million... 1 billion rows, approach , structure able hold without taking forever run, providing data types set correctly? i'll inserting table, want able show previous 20 (example) points award/deducted in future, similar stackoverflow user stats pages. is there more efficient structure better me? updated info yes stackoverflow in functionality, 1 user gets 1 vote per postid. @paul gregory after rethink removing receiving_user_id may better idea related post. assuming can use post_id identify specific comment, , using type sensibly (as number other ids), approach...

asp.net mvc 3 - How to use DotNetZip Library -

i unziped file donwloaded. how , library access in asp.net mvc 3 app able unzip file contains multiple files? my controller code: public actionresult upload(scormuploadviewmodel model) { if (modelstate.isvalid) { if (model.scormpackagefile != null) { string zipcurfile = model.scormpackagefile.filename; string fullpath = path.getdirectoryname(zipcurfile); string directoryname = path.getfilenamewithoutextension(zipcurfile); directory.createdirectory(path.combine(fullpath, directoryname)); using (filestream zipfile = new filestream(zipcurfile, filemode.open)) { using (gzipstream zipstream = new gzipstream(zipfile, compressionmode.decompress)) { streamreader reader = new streamreader(zipstream); //next unzip file? how library need? } } thanks

Lossless grayscale JPEG "color" inversion? -

imagemagick can invert colors of jpeg so: mogrify -negate image.jpg however, that's not lossless. intuition says color inversion should doable in lossless fashion, @ least grayscale images, know hardly jpeg. hence questions: is lossless jpeg grayscale inversion possible in theory? if so, libjpeg or other software out there able it? jpeg encodes images series of entropy coded deltas across mcus (minimum coded units - 8x8 blocks of dct values) , entropy coded quantized dct coefficients within each mcu. inverting pixel values (even if grayscale) involve decoding entropy coded bits, modifying values , re-encoding them since can't "invert" entropy coded dct values. there isn't 1 one matching of entropy coded lengths each value because bits encoded based on statistical probability , magnitude/sign of quantized values. other problem coded dct values exist in frequency domain. i'm not mathematician, can't sure if there simple way invert spat...

How to embed a plot directly into a Window (python; QT;) -

i wanna embed matplotlib plot directly window, qmainwindow. should part of program more complex gui. ;) the way found add figure widget qtabwidget. see sample code below. lost link webpage inspired me. is there way embed figure directly windows other elements (buttons, textfield, textarea, ...)? import sys pyqt4.qtgui import qapplication, qmainwindow, qdockwidget, qvboxlayout,qtabwidget, qwidget matplotlib import pyplot matplotlib.backends.backend_qt4agg import figurecanvasqtagg = qapplication(sys.argv) w = qmainwindow() t = qtabwidget(w) tab1 = qwidget() t.addtab(tab1, '1st plot') t.resize(1280, 300) x = [1, 2, 3] fig1 = pyplot.figure(); plot = fig1.add_subplot(111); plot.plot(x) plot.grid(); layout = qvboxlayout(); layout.addwidget(figurecanvasqtagg(fig1)); tab1.setlayout(layout); w.showmaximized() sys.exit(a.exec_()) thank much. figurecanvasqtagg qwidget of other controls mentioned. main difference being doesn't allow pass parent in constructo...

scope - How to access private variable of Python module from class -

in python 3, prefixing class variable makes private mangling name within class. how access module variable within class? for example, following 2 ways not work: __a = 3 class b: def __init__(self): self.a = __a b = b() results in: traceback (most recent call last): file "<stdin>", line 1, in <module> file "<stdin>", line 3, in __init__ nameerror: name '_b__a' not defined using global not either: __a = 3 class b: def __init__(self): global __a self.a = __a b = b() results in: traceback (most recent call last): file "<stdin>", line 1, in <module> file "<stdin>", line 4, in __init__ nameerror: name '_b__a' not defined running locals() shows variable __a exists unmangled: >>> locals() {'__package__': none, '__name__': '__main__', '__loader__': <class '_frozen_importlib.builtinimporter...

plsql - Oracle PL/SQL where condition: not equal to 0 or null -

i selecting id cannot equal 0, nor can value (null) . wrote: where id not null (+) , id not in ('0') i got 2 errors error(9,5): pl/sql: sql statement ignored error(38,119): pl/sql: ora-00933: sql command not ended change to: where id not null (+) , id not ('0') same errors occurred. should write where clause? you can simplify condition just: where id != 0 because comparisions null (using both = or != operators) evaluates null (which treated in sql "false" in conditions), therefore null != 0 evaluates false , can skip part in condition whre id != 0 , id not null braiam's answer where nvl(id,0)<>0 , although correct, prevent database using index on id column, , have bad impact on performce.

Using Core Data in IOS6 (delete/edit) -

i saving latest internet request of tableviewdata in (core data) entity, have problems error exceptions "faults". have 2 methods 'loaddata' gets latest 'ordersitems' loaded in tableview , 'loadthumbnails' try cache thumbnail core data entity. problem occurs when managedobject gets deleted , thumbnail method still tries access it. though made variable stopthumbnails stop loadthumbnails method, problem keeps occurring. what proper ios 6 way lazyload images , save them coredata check if object has not been deleted? found core data multi thread application useful newbie understanding of core data still limited , have problems writing code. read apple docs http://developer.apple.com/library/ios/#documentation/cocoa/conceptual/coredata/articles/cdconcurrency.html hard understand completely. i want @ least http request load asychronous (but preferably as possible) came following: -(void)viewdidload { nsfetchrequest *fetchreq = [nsfetchrequest...

visibility - Opacity over Flash doesn't works -

i'm trying make animation on youtube video. problem when flash not activated, works fine, when activate flash, div goes below video can't see it. tried use z-index, doesnt works. here videos ilustrate: this how animations should look: https://mega.co.nz/#!ivnexixl!x_kxdwhtipchrnz-mef_kq499qeluuc0rr-fhtyjun0 and happens when activating flash: https://mega.co.nz/#!fzk03j6d!kby6ct7ktwnog4a42k-uqx7vggnxz1zinazni8ipkme here code used: #div { left:698px; top:65px; width:320px; height:390px; visibility:visible; animation:open 6s reverse ease-in; } @keyframes open { 0% {left:698px;opacity:0;visibility:collapse;} 50% {left:338px;opacity:1;visibility:visible;} 100% {left:698px;opacity:0;visibility:collapse;} } thanks. you need specify opaque wmode parameter when embed flash object on page. other value wmode might relevant transparent . can read them here . both of these allow layer things on top of or behind flash app. note, using these wmode values makes f...

objective c - NSBitmapImageRep -initWithFocusedViewRect is doubling size of image -

i have following objective-c function meant resize nsbitmapimagerep designated size. currently, when working image of size 2048x1536 , trying resize 300x225, function keeps returning nsbitmapimagerep of size 600x450. - (nsbitmapimagerep*) resizeimagerep: (nsbitmapimagerep*) anoriginalimagerep totargetsize: (nssize) atargetsize { nsimage* thetempimagerep = [[[nsimage alloc] initwithsize: atargetsize ] autorelease]; [ thetempimagerep lockfocus ]; [nsgraphicscontext currentcontext].imageinterpolation = nsimageinterpolationhigh; nsrect thetargetrect = nsmakerect(0.0, 0.0, atargetsize.width, atargetsize.height); [ anoriginalimagerep drawinrect: thetargetrect]; nsbitmapimagerep* theresizedimagerep = [[[nsbitmapimagerep alloc] initwithfocusedviewrect: thetargetrect ] autorelease]; [ thetempimagerep unlockfocus]; return theresizedimagerep; } debugging it, i'm finding thetargetrect of proper size, call initwithfocusedrec returns bitmap of 600x450 p...

Python: Concatenating sublists between different lists -

i have 2 lists of lists, of equal length, this: lsta = [[1,4,5,6],[4,5],[5,6],[],[],[],[],[]] lstb = [[7,8],[4,5],[],[],[],[2,7,8],[7,8],[6,7]] and want concatenate sublists @ each index position such make single sublist, this: newlst = [[1,4,5,6,7,8],[4,5],[5,6],[],[],[2,7,8],[7,8],[6,7]] ideally, new sublists remove duplicates (like in newlst[1]). converted integers strings, , attempted this: for in range(len(lsta)): c = [item + item item in stra[i], strb[i]] but adds each item each list before adding other list, resulting in this: failedlst = [[["1","4","5","6","1","4","5","6"],["7","8","7","8"]],[["4","5","4","5"],["4","5","4","5"]]...etc] and still doesn't join 2 sublists, makes new sublist of 2 sublists. appeciated! making list concatenating item...

swift - Randomizing through number range -

i'm trying part of app work user clicks button , label prints randomly generated number between 1-12. i've been able that, want not repeat random numbers have been printed. what i've tried doing putting printed number array, , checking array each time generates new number. i've gotten work in playground, cannot working real project. here code project. var usednumbers = [int]() var randomconv = 0 func randomize() { lblrandom.text = "\(arc4random_uniform(12) + 1)" randomconv = int(lblrandom.text!)! } @ibaction func btnrandompressed(sender: anyobject) { randomize() if usednumbers.contains(randomconv) { randomize() } else { usednumbers.append(randomconv) } if usednumbers.count == 12 { btnrandom.hidden = true } } and here code playground. var lblrandom = "\(arc4random_uniform(12) + 1)" var randomconv = 0 var usednumbers = [int]() func randomize() { lblrandom ...

node.js - Why Npm is installing different 40+ modules other other computer but few packages on one -

Image
i dont know why npm has started downloading 40+ modules on npm install package.json contains following dependencies. "devdependencies": { "typescript": "^1.6.2", "vscode": "0.10.x" }, "dependencies": { "fs": "^0.0.2" } following list started. besides these modules there double of number downloaded , added below didnt show here. is there way reset. have tried remove modules folder , install again started adding again. yesterday when run these dependencies on other pc. headcode correct. npm3 installs dependencies in flat way. from docs : while npm2 installs dependencies in nested way, npm3 tries mitigate deep trees , redundancy such nesting causes. npm3 attempts installing secondary dependencies (dependencies of dependencies) in flat way, in same directory primary dependency requires it. so, if using npm v2.x on 1 machine, , npm v3.x on ...

javascript - Running server-side python in JS: difficulty with pico -

i have webpage needs run computation on start up. want keep computation on server side client cannot access source code. discovered pico , module supposed "a bridge between server-side python , client side javascript". i have test.py: import pico def hello(): return "hello world" my javascript simple: pico.load("../../../test.py"); pico.main = function() { var displaymessage = function(message){ console.log("hello2"); console.log(message); } test.hello(displaymessage); } "../../../test.py" relative location of python script pico folder i run "python -m pico.server" on command line. when go web page, open inspector, , go console error: "uncaught syntaxerror: unexpected token i". 'i' presumably first line import. note same error happens if don't run pico.server command. any great, suggestions alternative methods of doing serverside vs clientside. i...

ruby on rails - Using rails_admin to display dropdown list on belongs_to association -

Image
i using rails_admin manage data in rails application. i have class: class activity < activerecord::base attr_accessible :content, :title, :category_id belongs_to :category, :inverse_of => :activities end and other end is: class category < activerecord::base attr_accessible :title, :category_id, :activities_ids has_many :activities, :inverse_of => :category end my rails_admin initialiser activity looks this: config.model activity edit field :title field :content, :text bootstrap_wysihtml5 true end field :category end end now, in form renders category this: it supposed render names of categories, right? missing here? i've been looking quite while. nice autocomplete dropdown add: config.model activity edit field :category, :belongs_to_association end end

python - How to convert array to list? -

this question has answer here: converting numpy array python list structure? 4 answers examples from array: [ 8.85145037e+02 -1.24294207e+02 -1.42830519e+01 -8.62776672e+01 -8.66725361e+01 -7.96623643e+00 1.23582408e+01 2.84470918e+01 ] to list: [[885.1450370958278],[-124.29420748608811],[-14.283051875003691],[-86.27766716541419],[-86.67253605552324],[-7.966236427390702],[12.358240800052027],[28.447091751843175]] when using tolist () result is: [885.1450370958278, -124.29420748608811, -14.283051875003691, -86.27766716541419, -86.67253605552324, -7.966236427390702, 12.358240800052027, 28.447091751843175] thanks in advance if need list nested that, can do: in [2]: x out[2]: array([ 0. , 0.5, 1. , 1.5, 2. , 2.5, 3. , 3.5, 4. , 4.5, 5. ]) in [3]: x.reshape(-1, 1).tolist() out[3]: [[0.0], [0.5], [1.0], [1.5], [2.0], [2.5], [...

Many to many where_in syntax for Laravel Eloquent ORM -

i'm struggling make join query using laravel's eloquent orm i have 2 classes have many many relationship class type extends eloquent { public function activities() { return $this->has_many_and_belongs_to('activity'); } } class activity extends eloquent { public function types() { return $this->has_many_and_belongs_to('type'); } } in database have types, activities, , activities_types tables i'm trying recreate following sql query select . * activities join activities_types @ on a.id = at.activities_id at.type_id in ( 1, 2, 4 ) group a.id i haven't grasped orm syntax. i've tried $activities = activity::types().where_in("id", $types)->get(); but error "non-static method activity::types() should not called statically, assuming $this incompatible context" thanks pointers relationships not defined static method. therefore can't use them ::type() . add...

Emulating Curl --user --insecure in c# -

i have following curl call works. curl --insecure --user user@applicationname:password "https://someurl" i cannot life of me httpwebrequest emulate this. currently trying var httpwebrequest = (httpwebrequest)webrequest.create("https://someurl); httpwebrequest.contenttype = "application/json"; httpwebrequest.accept = "*/*"; httpwebrequest.method = "post"; httpwebrequest.headers["authorization"] = "basic " + convert.tobase64string(encoding.ascii.getbytes("user@account:password")); i getting error authentication failed because remote party has closed transport stream i guessing has curl command having insecure option cannot life of me see how in request. do network restrictions/policies cannot download restsharp or other 3rd party libraries... add line before doing request system.net.servicepointmanager.servercertificatevalidationcallback = (obj, x509...

Dimming the screen with Delphi -

Image
i looking create effect similar lightbox effect seen on many website background of screen fades out , content want emphasize not. best way go creating such effect in delphi ? the content want emphasize in case movable panel located on form , want fade out area of screen not directly under panel. thanks. oscar create new form , add code formcreate method. change properties using properties inspector, i'm choosing show relevant properties using code: unit unit1; // full screen partially transparent black form. interface uses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, extctrls; type tform1 = class(tform) procedure formcreate(sender: tobject); procedure formshow(sender: tobject); procedure formclick(sender: tobject); end; var form1: tform1; implementation uses unit2; {$r *.dfm} procedure tform1.formcreate(sender: tobject); begin borderstyle := bsnone; self.windowstate := wsmaximized; alphablen...

asp.net - 410 gone error response from IIS -

i've come accross issue iis responding 410 status code when request query string exceeds 500 characters. the application asp.net web app using classic managaged pipline. i've tried increasing maxrequestlength, maxurllength, , maxquerystringlength max of 2097151 no avail. i don't understand why server respond 410 status code. any or insight appreciated.

android - Match a google maps route using distance range -

i'm trying match if given location nearby given route or within range, im using django backend framework, found http://google-maps-utility-library-v3.googlecode.com/svn/trunk/routeboxer/docs/examples.html works javascript, there way can run on django server, or there similar can use django?

asp.net web api - How to get the correct webapi description for customized route -

i created customized httpcontrollerselector class support area in asp.net webapi, e.g. route template "api/{area}/{controller}/{action}/id" can reflected controller class named xxx.controllers.area.dummycontroller. use below statement api description, globalconfiguration.configuration.services.getapiexplorer().apidescriptions but found relativepath property in apidescription not correct, miss area, e.g. url: api/dummyarea/dummycontroller/list corresponding relativepath api/dummycontroller/list. do know how correct relativepath?

I have upgraded to mysql 5.7. but the service does not start -

i have upgraded mysql 5.5 5.7.10 service not start. try enter systemctl enable mysqld.service , systemctl start mysqld.service or systemctl enable mariadb.service , systemctl start mariadb.service , keep getting output job mysqld.service failed because control process exited error code. see "systemctl status mysqld.service" , "journalctl -xe" details. any doing wrong ? install "mysql-devel" package because provide shared , necessary libraries if want compile. sudo dnf install mysql-devel , start mysql server

windows - Visual SVN Server - service start logon failure due to disabled account -

i'm working visual svn server. reason service stopped. when tried restart it, failed due logon error. i found, guy set earlier has left organization , account on server disabled. svn server using account credentials start service , failing. i need change authentication credentials, not able figure out. ideas? see technet article "configure how service started" detailed instruction: start , click in start search box, type services.msc , , press enter , in details pane, right-click visualsvn server service, , click properties , to specify user account service can use log on, click log on tab, , there can specify account. visualsvn server works under network service default can run under dedicated account. you may want check these articles if create new service account: "permissions required run visualsvn server" , "configuring visualsvn server service run under dedicated user account" .

Yii2 - How to update textInput Value from DropDownList -

please got problem on yii2: want insert value textinput field based on changes in selected option dropdownlist. here code: <?= $form->field($model, 'course_taken')->dropdownlist(arrayhelper::map(courses::find()->all(),'course_code','course_code')) ?> <?= $form->field($model, 'course_details')->textinput(['maxlength' => true]) ?> so when user selects course dropdownlist, textinput display course details of selected row. both course_taken , course_details columns same database table. in advance. you can of javascript. 1) create action ajax request getting course details id in controller , set response format json. prefer use contentnegotiator instead of setting right before render: use yii\web\response; ... yii::$app->request->format = response::format_json; but can use approach alternative. use yii\web\response; ... /** * @inheritdoc */ public function behaviors() { return...

vue.js - How to remove hashbang from url? -

how remove hashbang #! url? i found option disable hashbang in vue router documentation ( http://vuejs.github.io/vue-router/en/options.html ) option removes #! , put # is there way have clean url? example: not: #!/home but: /home you'd want set history true . var router = new vuerouter({ history: true }); make sure server configured handle these links, though. vue-router docs link specifically: http://readystate4.com/2012/05/17/nginx-and-apache-rewrite-to-support-html5-pushstate/ for vue.js 2 use following: const router = new vuerouter({ mode: 'history' }) and can see server configuration here: https://router.vuejs.org/en/essentials/history-mode.html

PowerShell and ServiceNow REST API Dot-Walking Not Working -

i can specify value in body (ex: "sys_updated_by"="jsmith") , return specific record $url = "https://domain.service-now.com/api/now/v1/table/sc_item_option_mtom" $headers = @{"authorization"="basic 12345678900987654321"} $body = @{ "sysparm_limit"="1" "sys_updated_by"="jsmith" } (invoke-restmethod -headers $headers -method -uri $url -body $body).result request_item : @{link=https://domain.service-now.com/api/now/v1/table/sc_req_item/cc6f59d4c0779100925cad13165a7325; value=cc6f59d4c0779100925cad13165a7325} sc_item_option : @{link=https://domain.service-now.com/api/now/v1/table/sc_item_option/d37c591cc0779100925cad13165a7397; value=d37c591cc0779100925cad13165a7397} sys_updated_by : jsmith sys_tags : sys_updated_on : 2014-03-27 16:26:24 sys_id : 006f555cc0779100925cad13165a7377 sys_mod_count : 0 sys_created_on : 2014-03-27 16:26:24 sys_created_by : jsmith i cannot ret...

c# - Select Tag Helper in ASP.NET Core MVC -

i need select tag helper in asp.net core. i have list of employees i'm trying bind select tag helper. employees in list<employee> employeeslist , selected value go employeeid property. view model looks this: public class myviewmodel { public int employeeid { get; set; } public string comments { get; set; } public list<employee> employeeslist {get; set; } } my employee class looks this: public class employee { public int id { get; set; } public string fullname { get; set; } } my question how tell select tag helper use id value while displaying fullname in drop down list? <select asp-for="employeeid" asp-items="???" /> i'd appreciate this. thanks. using select tag helpers render select element in view in action, create object of view model, load employeelist collection property , send view. public iactionresult create() { var vm = new myviewmodel(); vm.employeeslist = new list<empl...

c# - How do I prevent undefined values from serializing to 0 for float values in .Net? -

i have rather large object class defined bunch of primitive attribute values (int, float, bool, string). getting object client application json string deserialize c# .net class can save them sql database. problem having serializer giving me default value of 0 float parameters breaks app undefined values need handled differently value of 0. (note: 0 values acceptable if user has defined them 0, can't assume undefined value 0.) i have literally hundreds of these primitive attributes, i'm hoping there way make work globally instead of having write custom attribute type objects. here's how i'm deserializing json string c# object using system.web.script.serialization; // note: used deserialize json objects using newtonsoft.json; using newtonsoft.json.linq; rootobject obj = jsonconvert.deserializeobject<rootobject>(jsonobjectfromclient); and here's object class public class seatdefinition { public string definitionid { get; set; } public string r3_tol...

c# - How to pass parameter via ajax mvc? -

i have problem follow : click button delete , show modal popup , in modal, have 1 button "ok", when click button "ok" , process event click of button "ok", such call action delete via ajax. code snippet. @foreach (var item in model) { <tr> <td> @ajax.actionlink(" delete", "", "", new { id = @item.userprofileid }, new ajaxoptions() { httpmethod = "get", insertionmode = insertionmode.insertafter, updatetargetid = "", onsuccess = "showmodal()" }, new { @class = "fa fa-times btn btn-danger btn-xs", @id = "bt_del_profile" }) </td> </tr> ...

php - Flip text vertically retaining case of the text -

is there way flip text vertically retaining case sensativness using javascript/php not css because want support old browsers too. i don't think need rely on js or php support old browsers (unless mean really old browsers ie4 or something, , js support bad enough that wouldn't either). internet explorer 5.5+ has filter called rotation should want. http://msdn.microsoft.com/en-us/library/bb554293(v=vs.85).aspx source

javascript - OnBeforeUnload behavior is different on second page in Google Chrome -

i'm testing onbeforeunload behavior using code snippet answer . var onbeforeunload = (function(){ var fdum = new function, affirm = function(){ return true; }; var _reg = function(msg,opts){ opts = opts || {}; var pid = null, pre = typeof opts.prefire == 'function' ? opts.prefire : fdum, callback = typeof opts.callback == 'function' ? opts.callback : fdum, condition = typeof opts.condition == 'function' ? opts.condition : affirm; window.onbeforeunload = function(){ return condition() ? (pre(),settimeout(function(){ pid = settimeout(callback,20); },1),msg) : void 0; } window.onunload = function(){ cleartimeout(pid); }; } var _unreg = function(){ window.onbeforeunload = null; } return { register : _reg, unregister : _unreg }; })(); codes same. if developer console, output follow (make sure tick ...

include - Change active link inside JavaScript inlcude file -

i'm using javascript(js) includes render tab menu in few html pages. js includes working fine - tabs render. however, change background color of tab when page active. know how this? of files external files (i.e. external css , js files). the provided snippet of code. suggestions appreciated. // javascript document document.write('<ul id="tabmenu">'); document.write('<li><a id="sbac" href="sbac_courses.html"><img src="../images/rlbm.png" width="149" height="52" /></a></li>'); document.write('<li><a id="nbm" href="nbm.html"><img src="../images/nbm.png" width="149" height="52" /></a></li>'); document.write('<li><a id="sbo" href="sbo.html"><img src="../images/sbo.png" width="149" height="52" /></a>...

sublimetext2 - Python code runs but doesn't ask for user input, in Sublime Text -

this question has answer here: running code in sublime text 2 ( mac os x ) 1 answer this first line of program: def main(): country = input('\nplease enter country> ') i selected python build, , when click ctrl-b compiles fine, , tells me how long took. why doesn't print line , ask me input? i assuming haven't called function main anywhere in code. can solve adding if __name__ == '__main__': main() @ end of code.

css - Firefox: calc() invalid property value -

i have element line-height set calc() : line-height: calc(3rem / 2); demo: http://codepen.io/ghodmode/pen/vlxzzd it works fine in chrome, firefox's developer tools says it's invalid property value. i'm sure i'm missing should obvious. just reference: https://developer.mozilla.org/en/docs/web/css/calc http://caniuse.com/#search=calc thank you. this known issue. firefox not support calc() values on properties accept either lengths or numbers, of line-height 1 such property. see bug 594933 . since 3rem / 2 1.5rem can hardcode amount instead workaround.

datetime - Unexpected results using strptime in R -

last year, used code below convert character string datetime , worked, unexpected results after running strptime . data <- structure(list(time = c("12:00 am", "1:00 am", "2:00 am", "3:00 am", "4:00 am", "5:00 am", "6:00 am", "7:00 am", "8:00 am", "9:00 am", "10:00 am", "11:00 am")), .names = "time", class = "data.frame", row.names = c(na, -12l)) why give me expected results strptime: strptime(data$time[1:10], format="%l:%m %p") # [1] "2013-03-01 00:00:00" "2013-03-01 01:00:00" "2013-03-01 02:00:00" # [4] "2013-03-01 03:00:00" "2013-03-01 04:00:00" "2013-03-01 05:00:00" # [7] "2013-03-01 06:00:00" "2013-03-01 07:00:00" "2013-03-01 08:00:00" # [10] "2013-03-01 09:00:00" but when try replace existing data new data forma...

Is empty case of switch in C# combined with the next non-empty one? -

with following code: case "getsites": case "sitesetup": messagebox.show("help! suffering air-conditioned nightmare!!!"); // ... will messagebox.show executed either switch value "getsites" or "sitesetup" ? or only if switch value "sitesetup" ? since "getsites" has no break, i'm thinking yes, not sure. update i guess way should have worded question as: are these 2 code fragments semantically equivalent? fragment 1 case 0: case 1: // bla bla bla; break; fragment 2(pseudo code) case 0, 1: // bla bla bla; break; what describing having 2 labels same case. c# allow this. cannot, however, fall through next case statement in same way c allows, is, label cannot have code, fall through next case statement. forbidden , cause compilation error.

python - A better way to aggregate data and keep table structure and column names with Pandas -

suppose have dataset following df = pd.dataframe({'x1':['a','a','b','b'], 'x2':[true, true, true, false], 'x3':[1,1,1,1]}) df x1 x2 x3 0 true 1 1 true 1 2 b true 1 3 b false 1 i want perform groupby-aggregate operation group multiple columns , apply multiple functions 1 column. furthermore, don't want multi-indexed, multi-level table. accomplish this, it's taking me 3 lines of code seems excessive. for example bg = df.groupby(['x1', 'x2']).agg({'x3': {'my_sum':np.sum, 'my_mean':np.mean}}) bg.columns = bg.columns.droplevel(0) bg.reset_index() is there better way? not gripe, i'm coming r/data.table background nice one-liner like df[, list(my_sum=sum(x3), my_mean=mean(x3)), by=list(x1, x2)] you use @happy01 answer instead of as_index=false add reset_index end: in [1331]: df.groupby(['x1', 'x2'])['x3'].a...

Why would logout using devise + omniauth + google-oauth2 + rails work in dev but not in prod -

the logout feature in rails application appears working when run app locally using localhost:3000 ; however, when logout on production server directing me http://example.com/users/logout , when go http://example.com still logged in. i pushed changes git repo , both dev / prod both running same source code. not sure why prod box isn't logging user out when click logout link. development.rb rails.application.configure # settings specified here take precedence on in config/application.rb. # in development environment application's code reloaded on # every request. slows down response time perfect development # since don't have restart web server when make code changes. config.cache_classes = false # not eager load code on boot. config.eager_load = false # show full error reports , disable caching. config.consider_all_requests_local = true config.action_controller.perform_caching = false # don't care if mailer can't send. co...

ExtJS mvc loading view after successfully logged in -

i trying develop application in extjs using mvc. aim of design application something: 1. create log in page authentication 2. after successful log in have show 3 grids in single page. these 3 grids have different stores , models. i able design login page, facing problem in going fwd next view after logged in. =====> controller/login.js ext.define('myapp.controller.login', { extend: 'ext.app.controller', views: ['login'], refs: [ { ref: 'viewportmain', selector: 'viewportmain' } ], init: function () { this.control({ 'viewport > panel': { render: this.onpanelrendered }, 'button[action=submitlogin]': { click: this.submitloginform } }); }, onpanelrendered: function() { console.log('the panel rendered'); }, submitloginform: function (butto...

numpy - python structured/recarray type conversion behaviour -

i'm confused behaviour of type conversion when constructing structured/recarray: this simple example takes in numerical fields defines type string: data = [(1.0, 2), (3.0, 4)] np.array(data, dtype=[('x', str), ('y', int)]) which produces: array([('', 2), ('', 4)], dtype=[('x', 's'), ('y', '<i8')]) so values converted empty strings not expect from: str(1.0) which produces string '1.0' . what's causing behaviour? you need specify string width, e.g. 'a3': >>> np.array([(1.0, 2),(3.0,4)],dtype=[('x','a3'),('y',int)]) array([('1.0', 2), ('3.0', 4)], dtype=[('x', 's3'), ('y', '<i4')]) just using str means string field of 0 bytes - of course small hold string rendition of float.

Atomic operations with DerbyJS -

are there atomic operations derbyjs? from documentation seems there no operations mongodb addtoset ? how 1 implement this? there model.setnull , model.setdiff operations. there no equivalent addtoset .

MYSQL - update each row from a table to set a column with other specific value on other table -

i have 2 tables this: table a ces | reg | year | inc | ouc --------------------------------------- c1   | usa   | 2015   | 0     | 0 c2   | uk     | 2014   | 0     | 0 c3   | br     | 2015   | 0     | 0 c1   | ru     | 2016   | 0     | 0 c1   | usa   | 2016   | 0     | 0 table b ces | reg | year | val   | dis(%) ----------------------------------------- c1   | usa   | 2015  | 100    | 10 c1   | usa   | 2015  | 200    | 20 c1   | ru     | 2016  | 200    | 10 c1   | usa   | 2016  | 500    | 20 c2   | uk     | 2014  | 200    | 20 c2   | uk     | 2014  | 500    | 10 c3   | br     | 2015  | 1000  | 30 c3 ...

jump to the next python class or function in vim -

i'm trying jump next python class or function in vim following commands: autocmd filetype python nnoremap <buffer> [[ ?^class|^\s*def<cr> autocmd filetype python nnoremap <buffer> ]] /^class|^\s*def<cr> but doesn't work. vim prompted: error detected while processing filetype auto commands "python": e492: not editor command: ^\s*def<cr> how fix this? after lots of trying, found following code worked. need add \\ before | autocmd filetype python nnoremap <buffer> [[ ?^class\\|^\s*def<cr> autocmd filetype python nnoremap <buffer> ]] /^class\\|^\s*def<cr> as alternative way, found putting 2 lines in ~/.vim/ftplugin/python.vim more convenient nnoremap [[ ?^class\|^\s*def<cr> nnoremap ]] /^class\|^\s*def<cr>

javascript - AngularJS image preview -

i have following input file: <div class="col s12"> <h6>foto</h6> <div class="file-field input-field"> <div class="btn pink darken-2 waves-effect waves-light"> <span>archivo</span> <input type="file" name="image" id="image" file-model="picture.image" custom-on-change="renderpreview"> </div> <div class="file-path-wrapper"> <input class="file-path" type="text" readonly> </div> </div> </div> when directive custom-on-change triggers, file input ( console.log() works here) want next preview of image selected: $scope.renderpreview = function(event){ var picture = event.target.files; console.log(picture); $('#image-preview').attr('src', pictur...