Posts

Showing posts from August, 2011

html - how to horizontally center a responsive div? -

trying center div contain responsive adsense code. example : <div class="wrapper"> <div class="adsense">adsense code here</div> </div> i can center div if type exact measurement of ad. 728x90 max want. @ moment have img temp placement , works fine. problem if type in exact px wont responsive. any ideas please? ok actual code... <section class="main-content"> <div class="top-banner"> <img src="img/ad_top.jpg"> </div> </section> (img there placeholder notepad++) .main-content { float: left; width: 75%; } .top-banner { margin:0 auto; } this places img left , not center. what talking about? horizontal centering done margin: 0 auto; doesn't matter size container has.

Deleting Duplicate with PHP and MySQL -

need code: $sql = "select distinct `numero_presentation_technique` tab_num_tache "; $result1 = mysqli_query($mysqli,$sql); $donnees = mysqli_fetch_array($result1); $m_pres_tech = $donnees['numero_presentation_technique']; so here i'm asking server unique data table , after display on page. problem => shows first data of table , repeats time. when using sql request on domain page, works... in advance! when loop fetch = array ( [0] => 0039nzr4 [numero_presentation_technique] => 0039nzr4 ) when use mysqli_fetch_all() = shows number , repeats you have loop through results , fetch while($donnees = mysqli_fetch_array($result1)) { print_r($donnees); echo "<br>"; }

mysql - Insert current date on insert -

i have table following structure: +----+-------------+----------------+------------+------------+ | id | column | column | inserted | edited | +----+-------------+----------------+------------+------------+ | 1 | ... | ... | 2014-08-15 | 2016-03-04 | | 2 | ... | ... | 2015-09-16 | 2016-10-07 | | 3 | ... | ... | 2016-10-17 | 2016-11-16 | +----+-------------+----------------+------------+------------+ when new entry inserted, current date should added column inserted . should never changed. when entry edited, current date should added column edited , should update every time entry edited. my approach define datatype date in both cases , change standard value curdate() . instead, inserts curdate() string. update example query: create table `test`.`testtab` ( `id` int not null auto_increment, `some column` varchar(100) null, `another column` varchar(100) null, `ins

javascript - my isStopWord function thinks "cat" and "catnip" are the same words -

i'm trying write simple function takes in word , stopword see if same words. return true if are. far, doing this, function isstopword(word, stopwords) { return (stopwords.indexof(word) !== -1); } console.log(isstopword("cat", "cat")); returns true, doing this console.log(isstopword("cat", "catnip"); also returns true... now, don't think know enough how ".indexof" works figure out why returns true in both cases. can me fix function knows if it's same word , not first 3 letters? because doing this, console.log(isstopword("catnip", "cat"); returns false, i'm little bit confused. thanks! the string.prototype.indexof() method returns position of first occurrence of specified value in string. cat has 1 occurence inside catnip index returned !== 1 if want check 1 word one. use following snippet. function isstopword(word, stopwords) { return stopwords === word; }

escaping - Grep invalid reference for Escape character -

i trying execute following command var1="/home/backup.sh -f /home/conf -d 1 >> /home/backup_ date +"\%d\%b\%y" .log 2>&1" var2="xxxxxx" grep "$var1" "$var2" flashing invalid reference. it works if remove escape character before %. need adding command cronjob upon condition check , getting invalid reference error grep.

ios - changing layout anchors of view on an action -

i have 1 upperlabel, 1 view , button. in viewdidload() method have given layout constraints view. on tap of button need update constraints(i.e view should move downwards). how can that. here code that. not working. let keyview = uiview() override func viewdidload() { keyview.frame = cgrect(x: 0, y: 0, width: 100, height: 30) keyview.backgroundcolor = uicolor.cyan keyview.translatesautoresizingmaskintoconstraints = false containerview.addsubview(keyview) keyview.topanchor.constraint(equalto: upperlabel.bottomanchor , constant: 10).isactive = true keyview.leadinganchor.constraint(equalto: containerview.leadinganchor, constant: 20).isactive = true keyview.trailinganchor.constraint(equalto: containerview.trailinganchor, constant: -20).isactive = true keyview.bottomanchor.constraint(equalto: keyview.topanchor, constant: keyview.frame.size.height).isactive = true } code in action follows. func buttonaction(sender: uibutton!) { keyview.t

visual studio - Build: Cannot find type definition file for 'q' -

followed instructions here: https://angular.io/docs/ts/latest/cookbook/visual-studio-2015.html had problems restoring package, worked after restarting computer. but have "build: cannot find type definition file 'q'" error when building.

kendo ui angular2 - Shared Tooltip in the Chart Component doesn't appear -

in chart wanted have shared tooltip multiple panes doesn't appear. elements highlighted i leave below code <kendo-chart *ngif="series.length >0"> <kendo-chart-value-axis> <kendo-chart-value-axis-item *ngfor="let item of values; trackby: item?.name" [name]="item.name" [pane]="item.pane" [visible]="false"> </kendo-chart-value-axis-item> </kendo-chart-value-axis> <kendo-chart-panes> <kendo-chart-pane *ngfor="let item of panes; trackby: item?.name" [height]="altura" [name]="item.name" [clip]="false" [margin]="{ top: 27, bottom: 9 }" [border]="{ color: '#b6b6b6', width: 0 }"></kendo-chart-pane> </kendo-chart-panes> <kendo-chart-category-axis> <kendo-chart-category-axis-item *ngfor="let i

ruby - How to get private variables of instance object without calling method -

is possible call specific method (or getting instance variables) without instance method instance object in ruby? class foo def initialize(arg) @bar = arg end end f = foo.new('test') p f #=> "test" (in case, @bar variable without instance method) for instance, if example class defined, ex = example.new ex #=> #<example:0x00000000000000> i want do, this. ex = example.new('hello') ex #=> "hello" you can use inspect p , to_s puts class foo def initialize(arg) @bar = arg end def inspect @bar end def to_s @bar end end f = foo.new('test') puts f #=> "test" p f #=> "test"

c# - How to wait for callback event return value -

eidreader eidobj; static fancypopup fancyobj; calss uipdate { uiupdate() { eidobj = new eidreader();//only contact card eidobj.devicearrival += eidobj_devicearrival; eidobj.datareceived += eidreader_datareceived; } } bool eidobj_devicearrival(stirng name) { //device arrived , notifyicon = new taskbaricon(this); notifyicon.icon = resources.led; notifyicon.tooltiptext = devicename + " reader application"; notifyicon.visibility = visibility.visible; fancyobj = new fancypopup(); notifyicon.traypopup = fancyobj; } bool eidreader_datareceived(string[] carddata, string[] publicdata, system.drawing.image imgphoto) { if (carddata != null) { fancyobj.clickcount = publicdata[(int)eidreader.ecardinfo.csnvalue]; // here fancyobj null, rising exception. , dont know why becomming null. } retu

ruby on rails - Serialize an ActiveRecord instance, and all subrecords -

hi i'm working on project users can manage own forum, , i'd when when new user logs in given pre populated demo forum can play test projects features. seems me best way take existing record, serialise , sub records , deserialize each new user. if forum.serializable_hash attributes of forum , not records belong forum. is there way me this?

jquery - Javascript Block Form action on "enter" submit -

i'm working in laravel framework, , have form: view {!! form::open() !!} <input type="text" name="puntata" id="puntata"> <button id="registro" type="button" class="btn-primary">punta</button> {!! form::close()!!} js var button = d.getelementbyid('registro'); function puntata() { ....my code... } var submit = button.onclick = puntata; when insert value in input "puntata" , click on button "registro" call function js, work well. but if insert value in input "puntata" , "enter" in keyboard submit form without call function javascript. how can block this? i on event "enter" call function puntata() , not submit form. thank help! you should use jquery's keydown this: $(document).ready(function() { $(window).keydown(function(event){ if(event.keycode == 13) { // -- 13 enter key event.preventde

db2 - SQLBindParameter with variable length strings -

how use sqlbindparameter write array of strings varchar field in db2 in memory-efficient way? the example in db2 docs this sqlchar description[num_prods][257] = { "aquarium-glass-25 litres", "aquarium-glass-50 litres", "aquarium-acrylic-25 litres", "aquarium-acrylic-50 litres", "aquarium-stand-small", "aquarium-stand-large", "pump-basic-25 litre", "pump-basic-50 litre", "pump-deluxe-25 litre", "pump-deluxe-50 litre", "pump-filter-(for basic pump)", "pump-filter-(for deluxe pump)", "aquarium-kit-small", "aquarium-kit-large", "gravel-colored", "fish-food-deluxe-bulk", "plastic-tubing" }; rc = sqlbindparameter(hstmt, 2, sql_param_input, sql_c_char, sql_varchar, 257, 0, description, 257, null); i can work without issues isn't efficient since each string stored using 2

subtraction from previous value in mysql -

i have table like id_indicator value trend date_data 1 0 0 2011-08-18 09:16:15 1 2 1 2011-08-18 10:16:15 1 1 -1 2011-08-18 11:16:15 1 2 1 2011-08-18 12:16:15 2 21 0 2011-08-18 13:16:15 2 21 0 2011-08-18 14:16:15 2 21 0 2011-08-18 15:16:15 3 3 0 2011-08-18 16:16:15 3 4 1 2011-08-18 17:16:15 3 4 0 2011-08-18 18:16:15 4 4 0 2011-08-18 19:16:15 i need find out difference between previous values based on id_indicator , add column in right , input value. example as id_indicator value trend date_data difference 1 0 0 2011-08-18 09:16:15 0 1 2 1 2011-08-18 10:16:15 2 1 1 -1 2011-08-18 11:16:15 -1 1 2 1 2011-08-18 12:16:15 1 2 21 0 2011-08-18 13:16:15 0 2 21 0 2011-08-18 14:16:15 0 2 21 0 2011-08-18 15:16:15 0 3 3 0 2011-08-18 16:16:15 0 3 4 1 2011-08-18 17:16:15 1 3 4 0 2011-08-18 18:16:15 0 4 4 0 2011-08-18 19:16:15 0 thanks

Problems with starting On-Screen-Keyboard from VB.NET -

i have strange problem when trying start on-screen-keyboard vb.net application (created vs2010). have 2 different application both using same code, is: wow64enablewow64fsredirection(false) proc = process.start("osk") wow64enablewow64fsredirection(true) in first app runs fine, in other following exception: "an attempt made reference token not exist" obviously problem hidden inside project settings of second app, cannot locate problem. appreciated. update i found reason myself. strange behaviour caused third-party-component used in second app. nothing project settings.

c# - converting datatable to xml giving outofmemory exception -

while trying converting datatable data xml through stringwriter. si giving outof memory exception. my datatable contains 20000 records. below code trying datatable dt = getdata();// contains 20000 records. stringwriter sw = new stringwriter(); dt.writexml(sw); xmldocument sd = new xmldocument(); sd.loadxml(sw.tostring()); can me please. you try using file stream instead of string writer. filestream stream = file.openread(path); xmldocument doc = new xmldocuemnt(); doc.load(stream);

php - which is better every user have a table or just a row -

i making android app part of user upload videos , inter details , stuff , choose videos favorite , found videos uploaded in 1 place , better making every user table or row in table create row every user in table. details , other stuff should in rows in other tables , linked via primary key , foreign key. if create table every user take space , not that, have access different table every user, makes complicated. in rows can access single user primary key of corresponding row.

regex - Regular Expression Vs. String Parsing -

at risk of open can of worms , getting negative votes find myself needing ask, when should use regular expressions , when more appropriate use string parsing? and i'm going need examples , reasoning stance. i'd address things readability , maintainability , scaling , , of performance in answer. i found question here had 1 answer bothered giving example. need more understand this. i'm playing around in c++ regular expressions in every higher level language , i'd know how different languages use/ handle regular expressions that's more after thought. thanks in understanding it! edit: i'm still looking more examples , talk on response far has been great. :) it depends on how complex language you're dealing is. splitting this great when works, works when there no escaping conventions . not work csv example because commas inside quoted strings not proper split points. foo,bar,baz can split, but foo,"bar,baz&qu

networking - Docker Swarm Mode: Not all VIPs for a service work. Getting timeouts for several VIPs -

description i'm having issues overlay network using docker swarm mode (important: swarm mode, not swarm). have overlay network named "internal". have service named "datacollector" scaled 12 instances. docker exec service running in same swarm (and on same overlay network) , run curl http://datacollector 12 times. however, 4 of requests result in timeout. run dig tasks.datacollector , list of 12 ip addresses. sure enough, 8 of ip addresses work 4 timeout every time. i tried scaling service down 1 instance , 12, got same result. i used docker service ps datacollector find each running instance of service. used docker kill xxxx on each node manually kill instances , let swarm recreate them. checked dig again , verified list of ip addresses task no longer same. after ran curl http://datacollector 12 more times. 3 requests work , remaining 9 timeout! this second time has happened in last 2 weeks or so. previous time had remove services, remove overla

mysql - Get all Items attached to sellerId - SQL -

when execute query 1 item attached sellerid instead of 2. know how can say? select name of item , re seller each item belongs re seller. rating higher 4? current query: select items.name, sellers.name items inner join sellers on items.id=sellers.id rating > 4 order sellerid the query tables inc. data: create table sellers ( id integer not null primary key, name varchar(30) not null, rating integer not null ); create table items ( id integer not null primary key, name varchar(30) not null, sellerid integer references sellers(id) ); insert sellers(id, name, rating) values(1, 'roger', 3); insert sellers(id, name, rating) values(2, 'penny', 5); insert items(id, name, sellerid) values(1, 'notebook', 2); insert items(id, name, sellerid) values(2, 'stapler', 1); insert items(id, name, sellerid) values(3, 'pencil', 2); you've got wrong join, here's corrected query; select items.name, sellers.name items i

rotation - Recalculate the rotating angle in android -

i rotate , scale image view . after took matrix valve image using method getimagematrix() in order apply same scaling , rotation image view recalculated rotating angle using expression float[] v = new float[9]; matrix.getvalues(v); float rangle = math.round(math.atan2(v[matrix.mskew_x], v[matrix.mscale_x]) * (180 / math.pi)); but gives -ve of original rotation. example if original rotation +90 recalculated angle -90, why happing ?

synchronization - Sync external folders with Box among different PCs -

i have 2 pcs (win8.1 , win10), both have c:\xampp\htdocs folder , want keep them syncronized. until did using cubby, free accounts no longer available. i'm thinking switch box, have 50gb account. box, dropbox , others, allows sync folder, i've thought use symlinks. i installed box on 1 pc (pc1 win10) , i've added symlink inside box folder refers c:\xampp\htdocs on pc1. box syncronized content of folder. now problem: how can keep syncronized c:\xampp\htdocs folder on pc2 1 on pc1?

vb.net - SSH.net How to Get the Screen -r output -

i want text of console made didnt work. using ssh = new sshclient(server, user, password) ssh.connect() ssh.runcommand("script /dev/null") dim wfile system.io.streamwriter dim log = ssh.runcommand("screen -r minecraft") wfile = my.computer.filesystem.opentextfilewriter(application.executablepath & "test.txt", true) wfile.write(log) wfile.close() end using

php - Get outerHTML from a website and put it into a string. I'm lost -

there (dynamic) websites source code not equal outerhtml of site. example, source code of site of interest is: <table> <tr> <td class="tname-home logo-enable"> <span class="tname"> <span style="display: none" class="dw-icon ico">&nbsp; </span> <a href="#" onclick="window.open('/team/unics-kazan/rtwgehhr'); return false;">unics kazan</a> </span> </td> <td class="current-result"> <span class="scoreboard-divider">- </span> </td> <td class="tname-away logo-enable">

html - Why can't I click a link to open a file from an MVC web page -

Image
i've got simple mvc web page pops dialogue box list of hyperlinks files. they're prefixed "file://" , links work if copied clipboard , pasted browser window. however, within dialogue, clicking on linked files returns... nothing. nothing @ happens. behavior identical in firefox, internet explorer, , chrome. no warnings, errors, etc. visually dialogue looks this: if "inspect element" on 1 of links, example, top 1 "javascript notes.txt", looks this: this valid hyperlink . mentioned above, can copy link address bar of browser , linked file opens fine. can copy full html of element notepad, wrapped in tags , save .html file, , link works fine there. links don't work in dialogue--from browser. i'm displaying links in kendo grid currently. thinking might problem, got rid of grid temporarily , tried displaying them in plain html . same problem--clicking on links produces no result @ all. am fighting deeper here? like,

pivot table - Conditional Filters in a PivotField Excel -

what want do . did paint since otherwise not asking community, here's how think should going. i have 1 question multiple choices each followed consequential question. real set far more complex, respondents can answer every question if should have answered one, why merely filling blanks merging desired columns 1 not option me. instead, have tried visualize creating pivottable each question column, , plot result. leads me dirty chart annoying non-answers because of 'impossible' , blank answers. i filter each response "if first answer a" "filter out data conditional question answer b that's not supposed there" , "if first answer b" "filter out data that's not supposed there". if know of way around problem, or different solution altogether, feel free lead me in right direction! thank much,

java - Cannot read file with same URL and same file structure on different computer -

so wrote small application uses string represents filepath can create file , buffered image. have omitted irrelevant code example: public class morphimage { private final string url0 = "pic1.jpg"; //.... url url = getclass().getresource(url0); file file = new file(url.getpath()); bufferedimage img = imageio.read(file); my file structure follows: projectname src package1 morphimage.java pic1.jpg on laptop running windows 10, works fine, using exact same project on windows 8 pc, iioexception: can't read file! on last row. both computers use same eclipse version , same jdk version. i'm not sure here. have tried many different filepaths on windows 8 machine throws np instead, path correct. edit: solution below: url defaultimage = morphimage.class.getresource(url0); file file = new file(defaultimage.touri()); bufferedimage img = imageio.read(file); try resource

javascript - Using D3.js to convert map projections on canvas -

what i'm doing: i have way upload image onto canvas. then, i'm using d3's map projections allow selection of different map projection convert image to. the problem: the conversion works if original image equirectangular projection. example, if upload equirectangular earth map, tell convert robinson projection, works fine. if upload robinson map image, try convert equirectangular projection, fill in transparent data color (i.e. doesn't work). the code i'm using: function updatemapprojection(selection) { var projection = options[selection.selectedindex].projection; //projection var 'd3.geo.robinson()` var projcanvas = document.getelementbyid('projectioncanvas'); var projctx = projcanvas.getcontext('2d'); projctx.clearrect(0, 0, projcanvas.width, projcanvas.height); var tempimage = new image(); if (mapfile.indexof("imgur.com") > -1) { tempimage.crossorigin = "anonymous"; }

grand central dispatch - How does DispatchQueue.main.asyncAfter(deadline: .now() + 5.0) work in Swift 3? -

in swift 3 syntax of gcd has changed quite bit. a call dispatch_after() looks this: dispatchqueue.main.asyncafter(deadline: .now() + 5.0) {//do something} that code invoke block 5 seconds after it's called. how work? docs deadline parameter dispatch_time_t , typealias uint64. assume it's mach time in nanoseconds. however, .now() + delay syntax adding decimal seconds value. doesn't dispatchtime.now() return uint64 ? if so, adding decimal seconds should not work. if anything, expect value added .now() treated nanoseconds, not useful. (in swift 2 used have multiply value constant number of nanoseconds per second.) ok, found answer own question in thread: how write dispatch_after gcd in swift 3? apparently there override of + operator takes dispatchtime , double, treats double decimal seconds, , returns resulting dispatchtime .

swift3 - How do I create a circle packing algorithm for circles with unequal sizes in iOS? -

Image
i trying pack bunch of round uiviews in hexagonal pattern. have different sizes. first randomly generate uiviews , put them on screen shown: have algorithm arranges views in circular pattern around center. algorithm: func arrangeviews() { let viewcenter = self.view.center let radius: double = 50?? <- put here? views has different radius? var currentdistfromcenter: double = (radius * 2) var nummoved = 0 let amountofviews = views.count nummoved += 1 while nummoved < amountofviews { var numbertofit = double(m_pi / asin(radius / currentdistfromcenter)) if numbertofit > double(amountofviews - nummoved) { numbertofit = double(amountofviews - nummoved) } in 0 ..< int(numbertofit) { let currentview = views[nummoved] let angle = double(m_pi * 2.0 * double(i) / numbertofit) let x = double(viewcenter.x

javascript - Generating json object with specific format from a collection -

i'm trying use jquery bracket plugin ( http://www.aropupu.fi/bracket/ ). as can see, plugin asks specific format in json object. example here: var minimaldata = { teams : [ ["team 1", "team 2"], /* first matchup */ ["team 3", "team 4"] /* second matchup */ ], results : [ [[1,2], [3,4]], /* first round */ [[4,6], [2,1]] /* second round */ ] } i have collection of games scores, players names (home , away), round, etc. i'm pulling server side; games json pretty "raw data". as can see, jquery bracket json needs property "teams" going used on first round , here, making bracket depending on scores. results property divided rounds , has follow same order teams property. i've been trying create object raw data. main point here, know results, i'm using plugin print tournament bracket. my raw data object is: [{"id":"160058",&quo

html - how to place icon inside input tag in asp.net mvc5? -

i new asp.net mvc5. trying put search icon inside search bar appears outside bar. can 1 tell solution? here snapshot , code. enter image description here and code here.. <div class="banner-g"> <div class="container"> <div id="user-info"> <div class="navbar-form navbar-right"> <form action="/home/browse" id="searchform" method="get"> <div class="inner-addon left-addon"> <a href="#" id="submitsearch" style="text-decoration: none; right: 14px; color: rgb(204, 204, 204); top: 6px; "> <i class="glyphicon glyphicon-search"></i></a> <input class="form-control input-sm" data-val="true" data-val-length="the field search must string maximum leng

sprite kit - swift spritekit update not getting accurate or constant reading -

im using update track moving node. when using update function not getting constant or accurate numbers. what code doing first declares current position , endpostion. node moves.in update function track nodes position whiles moving. if reaches endposition , user did not touch screen updates endposition. , until user touches screen. my code doing want. except update function jumps reading 10.9 12.7 30.75. not constant when node stops, position offset 2-3 points. don not want. any suggestions make more accurate or code way? code: override func didmove(to view: skview) { curpos=bear.position.y+(bear.size.height/2) endpos=bear.position.y+(boxsize+boxsize/2) print(curpos,endpos) let moveup=skaction.moveby(x:0,y:boxsize,duration:0.7) let rep=skaction.repeatforever(moveup) bear.run(rep) } override func update(_ currenttime: timeinterval) { count=bear.position.y if endpos <= count { endpos=count+boxsize print(endpos) i

relational database - Rails 5 Active Record Associations -

i learning how work ruby on rails , want find best way solve issue. have searched through many forums , rails documentation, haven't been able understand solution yet, hoping might able help! my app has 3 controllers- users, user_addresses, , invoices. each user can have multiple user_addresses, , multiple invoices. added user_id column primary key user_addresses table , user_id , address_id column primary keys in invoices table. when create invoice , select address assign to, save it, cannot figure out how populate both user_id , address_id, can 1 or other save. in example below getting user_id save, not sure both user_id , id address save invoice. i have user model set has_many :user_addresses , has_many :invoices. both invoice , useraddress model belongs_to :user. have read, think may need make use of :through extension, lost , not sure do. or guidance appreciated! invoices form <div class="form-group"> <%= label_tag(:user_id, "cu

javascript - Script injected with innerHTML doesn't trigger onload and onerror -

i trying bind onload , onerror events of script tag. works fine when loading src. given following function: function injectjs(src, inline) { var script = document.createelement("script"); if (inline) { script.innerhtml = src; } else { script.src = src; } script.onload = function() {console.log("success!");}; script.onerror = function() {console.log("error!");}; document.body.appendchild(script); } i can know whether script has loaded: > injectjs("https://code.jquery.com/jquery-3.1.1.min.js"); success! > injectjs("https://raw.githubusercontent.com/eligrey/filesaver.js/master/filesaver.js"); error! but when injecting inline js, innerhtml, script doesn't fire events: > injectjs("console.log(\"yes!\");", true); yes! > injectjs("console.log(\"loaded error...\"); error;", true); loaded error... success! hasn't been

javascript - Can someone explain how to use an event listener in the most simple of terms? -

i beginner coder in high school programming class, trying edit html/javascript game found online , update function called acceleration: function accelerate(n) { mygamepiece.gravity = n; } with keypress or keydown/up event. make box accelerate or down whether spacebar pressed. issue event listener examples can find use buttons, , game works using acceleration button: <button onclick="" onkeydown="accelerate(-.5)" onkeyup="accelerate(.5)">start game</button> the issue want window / document (i don't know is) detect if user inputting spacebar key , update acceleration function accordingly. appreciate willing give, thank :d you can (and should) use addeventlistener . it's better way of setting event handlers since isn't mixed in html, can done on dynamic elements , allows multiple handlers single event. document.addeventlistener('keydown', function(e) { // prevent space causing page scroll e

Accessing a django model in middleware (django>1.7) -

i'm upgrading django 1.6.5 django 1.9, , in process upgrading several middleware classes. of middleware classes use models during process_request or process_response phases. however, i'm getting appregistrynotready: apps aren't loaded yet. error attempting use them. is there way import models during middleware? should move import statements process_request / process_response methods? traceback (most recent call last): file "/usr/local/lib/python2.7/dist-packages/newrelic-2.50.0.39/newrelic/api/web_transaction.py", line 1329, in _nr_wsgi_application_wrapper_ result = wrapped(*args, **kwargs) file "/usr/local/lib/python2.7/dist-packages/newrelic-2.50.0.39/newrelic/api/web_transaction.py", line 1329, in _nr_wsgi_application_wrapper_ result = wrapped(*args, **kwargs) file "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 158, in __call__ self.load_middleware() file "/usr/local/lib/

Powershell validation of read-host data entry in while loop with nonewline -

i have function inserts y or n menu when called within powershell scripts. uses while loop validate either y or n value entered. works fine, new line created each time error made. use cls , redisplay everything, not ideal solution. instead, find way redisplay read-host prompt on same line while clearing entered answer. here existing code: # begin function display yes or no menu function ynmenu { $global:ans = $null write-host -foregroundcolor cyan "`n y. [yes]" write-host -foregroundcolor cyan "n. [no]`n" while ($ans -ne "y" -and $ans -ne "n"){ $global:ans = read-host "please select y or n" } } # end function ynmenu i have few other dynamically populated menus leverage methodology. finding solution resolve issue well. i don't think there's simple way that. but yes/no response, can use $pscmdlet.shouldcontinue($query, $caption) instead, long scope you're in (function, script, et

javascript - NPM not working (Cannot find module 'internal/fs' - nodejs) -

npm error on update. update node version 7.x. npm not working. i unable locate error, may due - npm err! cannot find module 'internal/fs' . following when run sudo npm update -g - npm err! linux 3.13.0-101-generic npm err! argv "/usr/bin/nodejs" "/usr/bin/npm" "update" "-g" npm err! node v7.1.0 npm err! npm v3.10.8 npm err! code module_not_found npm err! cannot find module 'internal/fs' npm err! npm err! if need help, may report error at: npm err! <https://github.com/npm/npm/issues> my /etc/profile.d/nodejs.sh has following contents: node_path=/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript export node_path you should able remove npm directory (typically /usr/local/lib/node_modules/npm) , reinstall 1 of official node tarballs, includes npm (you can find latest http://nodejs.org/dist/latest-v7.x/ ). did upgrade older version of node? if so, part of reason why having issue. old

ios - (Swift) Expand and Collapse tableview cell when tapped -

good morning i created custom tableviewcell, internally has collectionviewcell , directional arrow. able make cell expand , collapse when expand 1 cell , click on 1 previous collapse. example: if cell expanded , cell tapped, want cell contract , cell expand @ same time. 1 cell can in expanded state in given moment changing targeting arrow. example: if cella expanded , cellb tapped, want cella contract , cellb expand @ same time. 1 cell can in expanded state in given moment changing targetting arrow. my code: func tableview(_ tableview: uitableview, didselectrowat indexpath: indexpath) { switch(selectedindexpath) { case nil: let cell = mytableview.cellforrow(at: indexpath) as! tableviewcell cell.arrowimagem.image = uiimage(named:"content_arrow2") selectedindexpath = indexpath default: if selectedindexpath! == indexpath { let cell = mytableview.cellforrow(at: indexpath) as! tableviewce

android - Sqlite Autoincrement -

i'm trying update id column in table of memos. if memo id of 3 gets deleted, row underneath becomes id of 3. sqlitedatabase.execsql("create table " + table_name + "(" + "id integer primary key autoincrement, memo text, urgency text)"); to create table, works fine i'm getting sqlite error "near autoincrement". db.execsql("alter table " + table_name + " autoincrement = (select max(id) " + table_name + ");"); autoincrement not work guess expecting. if column has type integer primary key autoincrement different rowid selection algorithm used. rowid chosen new row @ least one larger largest rowid has ever before existed in same table.

excel - Pseudoinverse computation using VBA and C++ DLL -

i want pseudoinverse big degenerate matrix using vba in excel (analog of wide-known "pinv" function). understand excel tools can't deal degenerate matrices. i found nothing better try implement c++ dll library , link vba. faced following problems: my configuration is: windows 10 x64, office 16 x64. create dll vs 2015 x64 dll. have managed create , link simple dll , pass , double arrays. when came use math libraries such armadillo dynamically linked blas, mess arose. any working , debugged code uses blas x64 dll in case being wrapped dll , invoked vba crashes excel. checked dependencies , put blas/lapack dlls every suitable folder. crashes don't use passed parameters. proc monitor shows dependencies ok. looks when excel calling function dll prevents external calls dll. possibly little late , not asked finished writing vba subroutine calculates moore-penrose pseudoinverse of matrix might still helpful you. follows similar processes matlab's "

javascript - How to reset the margin of an image for animation using jquery easing? -

i'm trying animate image using jquery easing (see http://gsgd.co.uk/sandbox/jquery/easing/ ) allow image fly right left on click on link ('rates' in case) on navbar. problem is, i'm not able reset left margin of image, if ckick more once, image shifts every time click on rates. tried initalleftmargin = initalleftmargin + 285; in order reset margin. but, no luck. suggestion appreciated. js $("#section-rates-go").click(function gorightease(){ var initalleftmargin = $( ".innerliner" ).css('margin-left').replace("px", "")*1; var newleftmargin = (initalleftmargin - 285); // 2 border $( ".innerliner" ).animate({ marginleft: newleftmargin }, 4000, 'easeoutbounce'); }) css .animation-mycontainer{ box-sizing: border-box; white-space: nowrap; overflow-x: hidden; width: 280px; } .animation-box{ box-si

bash - Docker Entrypoint Why I get the wrong parameter -

i making custom docker image having dockerfile # dockerfile moodle instance. # forked jonathan hardison's <jmh@jonathanhardison.com> docker version. https://github.com/jmhardison/docker-moodle php:7.0-apache maintainer dimitrios desyllas <ddesyllas@freemail.gr> #original maintainer jon auer <jda@coldshore.com> volume ["/var/moodledata"] expose 80 # let container know there no tty env debian_frontend noninteractive # moodle info env moodle_url http://0.0.0.0 env moodle_admin admin env moodle_admin_password admin~1234 env moodle_admin_email admin@example.com #database settings #supported 'pgsql', 'mariadb', 'mysqli', env moodle_db_type 'mysqli' env moodle_db_host '' env moodle_db_user '' env moodle_db_password '' env moodle_db_name 'moodle' env moodle_db_port '3306' run echo "installing php , external tools" run apt-get update && \ apt-get -f -