Posts

Showing posts from March, 2014

javascript - Killing a "personalized" Interval -

i've made system users can login website , play game requires interval timing. when user done playing want kill interval. while seems running fine, there wrong killing interval. here problem whenever user done playing interval gets killed, not user playing everyone . might because i'm assigning variable interval , when user done playing game i'm killing interval , right kill other intervals well? here code i've written question, var user; //this variable has info user. (its not empty) var usersplaying = []; socket.on('game', function(game) { if(game.type == "start"){ usersplaying.push({ user_id: user.id }); var game = setinterval(function(){ if(finduser(user.id) !== undefined){ console.log('second passed!'); }else{ clearinterval(game); //stop interval } }, 1000); }else if(game.type == "stop"){ ...

java - db.delete deletes the first row instead of the row specified -

i want able delete specific column in sqlite database. i have tried pass id of column whereclause , keep getting error saying whereclause needs string value. i have combed so solution have not found answers question. have tried google search , have written question many different ways, no avail. here code delete button public void todeletenote(view view) { dbhelper dbhelper = new dbhelper(this); int deletedrows = dbhelper.deletedata(selectedid); if (deletedrows > 0){ toast.maketext(getbasecontext(), selectedname + " deleted successfully", toast.length_long).show(); } else { toast.maketext(getbasecontext(), "something went wrong!", toast.length_long).show(); } intent intent5 = new intent(editdata.this, mainactivity.class); startactivity(intent5); } } dbhelper delete method public int deletedata(int id){ string id = string.valueof(id); sqlitedatabase database = this.getwritabledatabase()...

how to write cursor alternative query in sql server -

i need implement without using cursor. below script using cursor , it's taking 5 hours 140k records. how improve performance in sql server? in orginal table have on 100k records. set nocount on create table #temp ( recordid int identity, address varchar(50), city varchar(30), state varchar(5), gpslat numeric(9,6), gpslong numeric(9,6), mapurl varchar(255)) insert #temp (address, city, state) values ('1033 southwest 152nd street', 'burien', 'wa') insert #temp (address, city, state) values ('11910 northeast 154th street', 'brush prairie', 'wa') insert #temp (address, city, state) values ('500 seaworld drive', 'san diego', 'ca') insert #temp (address, city, state) values ('1 legoland drive', 'carlsbad', 'ca') declare curgeo cursor local static select recordid, address, city, state #temp declare @recordid int declare @address varchar(50) declare @city varchar(30) declare @sta...

html - How to change the background colour of different components in Angular2? -

in angular2 app, there problem keep encountering, i.e, setting background colour or image of page. in app, if mention particular colour in styles.css background colour applied pages develop, since applies styles globally. if login page blue in colour , want change background colour of home page white, how go doing that? because in component homepage have : homepage.component.html , homepage.component.css . in homepage.component.css, css affects elements of homepage. cannot change colour of entire page or add image background entire page either since body { ... } not work there. neither @import url work. how can change background colours of different components in angular2 app? any appreciated. thanks. an other solution, little basic, works: style.css body, html{ padding: 0; width: 100vw; height: 100vh; } .my-container{ with:100vh; height:100vw; .... } home.component.css .my-container{ background-color: red; } home.component.html ...

http - Why does a directory exist and not exist on a web server simultaneously? -

while i'm sure title improved clarity, meaning thus: when fetching url file download @ http://example.com/dir1/dir2/file.zip , response code 200 , yet attempting access http://example.com/dir1 , or http://example.com/dir1/dir2 , elicits 404 response code. why this? urls don't correspond actual directories on server. path component of url name; server can translate name whatever wants on end. in case seems /dir1/dir2/ is directory on server, doesn't mean anything. server knows resource named /dir1/dir2/file.zip , doesn't know resource named /dir1 .

matlab: limiting erosion on binary images -

i trying erode objects in binary image such not become smaller fixed size. consider, instance, binary map composed of connected components (blobs), wherein 1 defines blob size either minimal or maximal antipolar (anti-perimetric) distance (i.e., distance between 2 points far 1 can on perimeter or contour of blob; if contour consists of n consecutively numbered points, distances evaluated between points 1 , n/2+1, points 2 , n/2+2, etc.). given such arrangement, seek erode these blobs until distance metric reaches specified limit. if blobs simple circles, effect realized ultimate erosion followed dilation fixed size; however, contour of irregular object lost such procedure. there way achieve such effect connected, irregular components using built-in functions in matlab? with no image , tried code presented can understand wrong, may iterative using bwmorph 'thin','skel' or 'shrink' you. while(cond < cond_threshold) bw=bwmorph(bw,...,1); %one ...

big o - could some one explain time complexity to me from this image -

Image
could 1 please explain why n >= 1 , not n >=0 since 0 true below argument n>=0 not ok, definition in introduction algorithms(clrs), requires n positive. think reason use big-o notation make approximation of algorithm, want input, , n=0 means no input, don't want involve in our calculation.

c# - Basic Conventional routing asp.net webapi -

i have simple query on asp.net web api routing. have following controller: public class customerscontroller: apicontroller { public list<someclass> get(string searchterm) { if(string.isnullorempty(searchterm)) { //return complete list } else { //return list.where (customer name contains searchterm) } } } my routing configuration (conventional) looks this: config.routes.maphttproute(name:"defaultapi", routetemplate:"api/{controller}/{id}" defaults:new {id = routeparameter.optional}); config.routes.maphttproute(name:"customersapi", routetemplate:"api/{controller}/{searchterm}" defaults:new {searchterm = routeparameter.optional}); if hit url: http://localhost:57169/api/customers/vi 404-not found if reverse order of routes, works. question in first case, matching first route (defaultapi)? if not, why not trying second route? thi...

Why some control in toolbox not worked? -

when drag control project in xamarin show error: bridge [resources.resolve] couldn't resolve resource @android:drawable/screen_background_selector_darkbridge [resources.resolve] couldn't resolve resource @android:drawable/scrollbar_handle_holo_darkbridge [resources.resolve] couldn't resolve resource @android:drawable/scrollbar_handle_holo_darkbridge [resources.resolve] couldn't resolve resource @android:drawable/text_select_handle_leftbridge [resources.resolve] couldn't resolve resource @android:drawable/text_select_handle_rightbridge [resources.resolve] couldn't resolve resource @android:drawable/text_select_handle_middlebridge [resources.resolve] couldn't resolve resource @android:drawable/text_cursor_holo_darkbridge [resources.resolve] couldn't resolve resource @android:drawable/scrollbar_handle_holo_darkbridge [resources.resolve] couldn't resolve resource @android:drawable/scrollbar_handle_holo_darkbridg...

autocomplete - how to implement Custom Auto suggestion in java like google -

how implement java based auto suggestion. suppose have different types of data firstname, rollnumber, address. my first requirement if user enter first character on text box, result should sorted on natural order based on firstname , 10 results should display. after space if use enter second character , if numbere rollnumber else lastname should sorted on natural order ascending. or if user type third character address should display on ascending order. there should no database, don't have implement solr or other api. how implement on pure java. here did not implement text-box,but took example demonstrate import java.util.*; import java.lang.*; import java.io.*; // class represent student. class student { int rollno; string name; string address; // constructor public student(int rollno, string name, string address) { this.rollno = rollno; this.name = name; this.address =...

css - Inline-block element next row not coming properly -

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> <style> .div1{ display: inline-block; width: 49%; border:1px solid red; height:250px; } .div2{ display: inline-block; width: 49%; border:1px solid red; } .div3{ display: inline-block; width: 49%; border:1px solid red; vertical-align:top; } .div4{ display: inline-block; width: 49%; border:1px solid red; } </style> <html> <head> </head> <body> <div class="div1"> content1 </div><!-- --><div class="div2"> content2 </div><!-- --><div class="div3"> content3 </div><!-- --><div class="div4"> content4 </div> <body> </html> there gap between column2 ,...

Adding a linebreak between elements HTML code breaks "parentnode" based javascript function -

this question has answer here: what difference between children , childnodes in javascript? 2 answers i have an html form simple javascript function meant send user different link based on option selected. <form> <select name="deliverytype"> <option value="123">item 1</option> <option value="456">item 2</option> <option value="789">item 3</option> </select> <p><a href="javascript:void(0);" onclick="javascript:addtocart(this);">submit</a> <script> function addtocart(t) { var dt = t.parentnode.parentnode.childnodes[1].value; alert(dt); // location.href = "http://linkprefix.com/?variable=" + dt; }</script> </form> it works expected. variable dt returns value of selected option. ...

jquery - i want to show button after select text, but if this happened button doesnot work in Javascript -

i want show button after select option button not work. if write button in body works.add_more_button button in code want use in js call add-more-field in js function. , show fields . <!doctype html> <html lang="en"> <head> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>laravel</title> <!-- fonts --> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css" integrity="sha384-xdybmnz/qjlh6ii4ogqctaijrfk87ip+ekijefzch0y+pvj8cdytes1ipdmporq+" crossorigin="anonymous"> <link rel="styleshee...

android studio local git -

i'm trying create local git android studio projects. how can import project project b library using local git without using github ? i create project , enable version control integration , commit , next step locally add project ? pull new updates library. is possible add local project project dependency ? what best way have local git ?

r - Two-way table with tables producing 1's -

i'm trying make simple two-way table tabluar() , i'm getting 1's in output. why estimates not showing , 1's instead? sample code pred.table <- structure(list(temp = structure(c(1l, 2l, 3l, 4l, 5l, 1l, 2l, 3l, 4l, 5l, 1l, 2l, 3l, 4l, 5l, 1l, 2l, 3l, 4l, 5l, 1l, 2l, 3l, 4l, 5l, 1l, 2l, 3l, 4l, 5l, 1l, 2l, 3l, 4l, 5l, 1l, 2l, 3l, 4l, 5l, 1l, 2l, 3l, 4l, 5l), .label = c("+1c", "+2c", "+3c", "+4c", "+5c"), class = "factor"), crop = structure(c(1l, 1l, 1l, 1l, 1l, 2l, 2l, 2l, 2l, 2l, 3l, 3l, 3l, 3l, 3l, 1l, 1l, 1l, 1l, 1l, 2l, 2l, 2l, 2l, 2l, 3l, 3l, 3l, 3l, 3l, 1l, 1l, 1l, 1l, 1l, 2l, 2l, 2l, 2l, 2l, 3l, 3l, 3l, 3l, 3l), .label = c("a", "b", "c", "d", "e"), class = "factor"), reg = structure(c(1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 1l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 3l, 2l, 2l, 2l, 2l, 2l, 2l,...

css - How to remove this extra space in the tabPane in JavaFX? -

Image
this space in tab pane next last tab option. using scenebuilder design app. this space depends tab pane header ,you have way hide using css .tab-header-background { -fx-background-color:transparent } .tab-pane{ -fx-padding: 0 -1 -1 0 } the result is:

ionic framework - how to add Android Path in mac -

i'm using ionic2 , want run android in mac: when used command: ionic cordova run android i had error: error running 1 or more of platforms: android sdk not found. make sure installed. if not @ default location, set android_home environment variable. may not have required environment or os run project although have sdk installed in location: /users/macbookpro/library/android/sdk and when write command in terminal: export android_home=/users/macbookpro/library/android/sdk and write: sudo nano /etc/paths i had these pathes only: /usr/local/bin /usr/bin /bin /usr/sbin /sbin what should add path correctly! i had similar problem , added directory /etc/paths.d sudo mkdir /etc/paths.d and created file android-sdk sudo vi /etc/paths.d/android-sdk add paths in file , save

c# - SQL Convert DateTime Error -

select dish_category.cat_name, order_items.oi_name, dish_management.d_price, order_items.oi_quantity, order_items.oi_price, order_management.o_time dish_category inner join dish_management on dish_category.cat_id = dish_management.cat_id inner join order_items on dish_management.d_id = order_items.d_id inner join order_management on order_items.o_id = order_management.o_id order_management.o_time = (convert(datetime, convert(datetime, convert(varchar, date, 103),103)) between @dsstart_date , @dsend_date) can please guide me query might wrong? error message is: error in list of function arguments ',' not recognized unable parse query text you've made many calls convert . need 2: 1 converting date column varchar , , 1 converting result datetime format. when calling convert(varchar, date) pass 2 argument, 103 date conversion, not varchar conversion. if want use today's date, use date(now()) did below: try this: select dish_category.ca...

php - Notice: Undefined Index in form submission to another page -

i new php , trying submit form using post. form element looks like <form action="<?php htmlspecialchars($_server["/php/somefunctions.php"]);?>" method="post"> both files have session_start(); declared @ top , form doesn't have required field. when open form in browser shows, notice: undefined index: /php/somefunctions.php in 'filepath' on line 31. line 31 above mentioned line. if ignore , fill in form , click on submit, gives me access forbidden! you don't have permission access requested object. either read-protected or not readable server. you should use server document root. $_server["document_root"]./path file also forgot add echo. without echo php won't display echo htmlspecialchars();

python 2.7 - Query an array of DNS records with dnspython, and proceed to the next element based on a custom timeout -

i'm querying bunch of dns records dnspython , seems timeout when no reply received ( dns.exception.timeout: dns operation timed out after 30.0006685256958 seconds ). here's function: def dnstest(domain): dnsrecords = [] record_types = ['a', 'aaaa', 'cname', 'mx', 'srv', 'txt', 'soa', 'ns'] dnsresolver = dns.resolver.resolver() record in record_types: dnsanswer = dnsresolver.query(domain, record) rdata in dnsanswer: dnsrecords.append(rdata) return(dnsrecords) print(dnstest("github.com")) whereas, if query dns records exist, answer received: dnsanswer = dnsresolver.query(domain, 'a') i'm guessing because records (such srv , aaaa etc.) doesn't exist github.com . however, exist other domains. there way can include timeout (like say, 5 seconds) per query within for loop? - if no response in 5 seconds, move next element in array...

How to attach a SQL Server database file from another server -

i have changed hard disk. databases on old hard disk. have attached old hard disk external hard disk. how can attach database files external hard disk new installed sql server? you use sql server management studio this: in sql server management studio object explorer , connect instance of microsoft sql server database engine, , expand instance. right-click databases , click attach . in attach databases dialog box, specify database attached, click add ; , in locate database files dialog box, select disk drive database resides , expand directory tree find , select .mdf file of database; source: https://msdn.microsoft.com/en-us/library/ms190209(v=sql.105).aspx please note need copy files new server's file system before can attach them. marc_s pointing out.

html - Navigation with <nav-ul-li> vs. navigation with <div> -

1. version ( <nav-ul-li> ): html: <nav> <ul> <li>1.1 menu</li> <li>1.2 menu</li> <li>1.3 menu</li> <li>1.4 menu</li> </ul> </nav> css: ul { padding: 0; } li { display: inline; width: 24%; float: left; border-style: solid; border-width: 1px; background-color: red; } 2. version ( <div> ): html: <div class="navigation"> <div class="menu">1.1 menu</div> <div class="menu">1.2 menu</div> <div class="menu">1.3 menu</div> <div class="menu">1.4 menu</div> </div> css: .navigation { width: 100%; float: left; margin-top: 5%; border-style: solid; border-width: 1px; background-color: green; } .menu { float: left; width: 24%; border-style: solid; border-width: 1px; background-color: green; } i have...

android - I need to make a simple TextWatcher calculator if it's possible -

i want create app contain 3 edittext. (nothing else) edittext1 edittext2 edittext3 now 1) if enter values edittext1 , edittext2 addition should performed between et1 , et2 answer should set edittext3.... (et1+et2=et3) 2) if enter values edittext1 , edittext3 subtraction should performed between et1 , et3 answer should set edittext2.... (et3-et1=et2) it's sounds crazy think, "not done before! not mean not done ever." @confused soul , found solution crazy question... xml edittext <edittext android:id="@+id/et_a" android:layout_width="0dp" android:layout_height="40dp" android:layout_weight="0.16" android:gravity="center" android:inputtype="number" /> <edittext android:id="@+id/et_b" android:layout_width="0dp" android:layout_height="40dp" android:layout_weight="0.16" an...

osx - Bring OpenCV window to front -

i open opencv result cv2.imshow(window_name, image_resized_scaled) sadly shown below terminal. want image in focus on top of other windows on screen. use following setup: python -i python 3.6.1 (default, mar 23 2017, 16:49:06) [gcc 4.2.1 compatible apple llvm 8.0.0 (clang-800.0.42.1)] on darwin type "help", "copyright", "credits" or "license" more information. >>> import cv2 >>> cv2.__version__ '3.3.0' i searched around answers ... opencv: how force image window appear on top of other windows? opencv window on top python opencv open window on top of other applications setting focus on window in opencv .. either c++ or not stating solution. does know how achieve on osx using opencv 3.3 python3? p.s.: source code used far available here .

excel - Calculating the running average in a pivot table -

Image
i have pivot table has following structure: row fields month (number 1 through 12) , values ( revenue , sqft , rev_per_sqft calculated field). show running total in based on month row. now, works revenue , sqft . but not work rev_per_sqft . formula field =revenue / sqft . works on individual monthly basis when running total in sums monthly values instead of doing average. selected both sum average , doesn't make difference. is there way show average? if hasn't been clear yet, here how table looks like: +-------+----------------------+---------+ | monat | werte | totals | +-------+----------------------+---------+ | 1 | revenue | 651.32 | | | sqft | 52.3 | | | rev per sqft | 12.45 | | | running revenue | 651.32 | | | running sqft | 52.3 | | | running rev per sqft | 12.45 | | 2 | revenue | 476.17 | | | sqft | ...

append - Combine 2 Excel tables into one appending the data? -

Image
i have 2 tables on 2 separate sheets of ms excel 2007 workbook, below: =========================== no. f_name l_name =========================== 13 little timmy 1 john doe 17 baby jessica --------------------------- =========================== no. f_name l_name =========================== 1 john tim 16 kyle joe 14 baby katy 22 qbcd wsde --------------------------- both have same columns, can have different data. i want combine data of both tables vertically i.e. single table data in 3rd separate sheet. if possible, want add column sheet name row came. =================================== sheetname no. f_name l_name =================================== sheet1 13 little timmy sheet1 1 john doe sheet1 17 baby jessica sheet2 1 john tim sheet2 16 kyle joe sheet2 14 baby katy sheet2 22 qbcd wsde ------------------...

A python game in easy way -

"i have small code of python easy implement small game,i have refered somewhere , posting there more easiest way tic tac toe game have small code of python easy implement small game,i have refered somewhere , posting there more easiest way tic tac toe game" #import import os import time import random #define board board = ["", " ", " ", " ", " ", " ", " ", " ", " ", " "] #print header def print_header(): print""" play tic-tac-toe, need 3 in row... choices defined, must 1 9... """ #define print_board function def print_board(): print " | | " print " "+board[1]+" | "+board[2]+" | "+board[3]+" " print " | | " print "---|---|---" print " | | " print " "+board[4]+" | "+board[5]+" | "+b...

python - Testing image on Tensorflow Mnist Model using checkpoints -

i newbie tensorflow.i got mnist train sample , want test image generating checkpoints.i referred tensorflow documentation , generated checkpoints , tried test sample image accessing softmax layer.but given image number-9 softmax gives me invalid one-hot-encoded array 'array([[ 0., 1., 0., 0., 0., 0., 0., 0., 0., 0.]], dtype=float32)' ,when tried access softmax using softmax = graph.get_tensor_by_name('softmax:0'). i tried testing different images,it didn't give proper result of them. 1.i asssumed, softmax give me array of probabilities.am right? 2.am saving model properly? 3.am accessing correct layer testing input? 4.is there further added in testing/training code? sorry posting here. this train code: from __future__ import division, print_function, unicode_literals import tensorflow tf time import time import numpy np import os import scipy.ndimage ndimage scipy import misc tensorflow.examples.tutorials.mnist import input_data mnis...

javascript - jQuery conflict between two libraries -

Image
i faced confuing problem on website. i using 2 jquery libraries 1 1.5.1 , other 3.2.1. latest version of jquery using noconflict mode <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> var inst = jquery.noconflict(); </script> everything ok, when customer choosing shiping method on website shows error , other scripts doesnt work. but jquery library 3.2.1 should in noconflict mode. , there no conflicts , errors on other pages of website. i dont know how can fix issue. thanks jquery .live() has been removed in version 1.9 onwards. so must change: .live(events, function) should map to: .on(eventtype, selector, function) below reference links: http://api.jquery.com/on/ http://api.jquery.com/off/ the page live() shows how convert on() : http://api.jquery.com/live/ updated: you can free jquery noconflict(true) . though, if take route, you'll want alias...

c++ - Mixing inline and macro functions -

i've decided try something. know macros evil , should avoided wanted see what's going happen if such thing. #include <iostream> using namespace std; inline void add(int x, int y) { cout << "inline: " << x + y << endl; } #define add(x,y) ( cout << "macro: " << x + y << endl ) int main() { add(3,5); } it outputs: macro: 8 if comment out #define line inline starts working, , output turns inline: 8 . my question is, why compiler decides use macro function instead of inline. thank you! i'm using linux mint 18.2 , g++ 5.4.0 , no parameters g++ -g t2.cpp -o t2 . macro substitution performed via pre-processor before compilation. compiler never sees add(3,5) - sees macro expansion.

Convert string to date format using javascript -

i have string value , need convert string value following date format using javascript. var strdate = "2016-11-20"; expected output is: 20-nov-2016 how can change this? a little workaround following, if have manipulate dates lot, recommend use moment.js library: https://momentjs.com/ var strdate = "2016-11-20"; var utcdate = new date(strdate).toutcstring(); var converteddate= utcdate.substring(utcdate.lastindexof(", ") + 1, utcdate.lastindexof(" 00:")); console.log(converteddate.trim().replace(/\s/g, '-')); pay attention implementation of method may change depending on platform. here official doc: the value returned toutcstring() human readable string in utc time zone. format of return value may vary according platform. common return value rfc-1123 formatted date stamp, updated version of rfc-822 date stamps.

java - Multiple tables with same structure - Sqlite -

i have table called messages.but want create separate table separate users. ex: if username ciddarth want table named ciddarth same structure messages public class dbhandler extends sqliteopenhelper { sqlitedatabase db; // static variables // database version private static final int database_version = 1; // database name private static final string database_name = "socialnetwork"; // contacts table name private string table_messages = "messages"; // contacts table columns names private static final string key_id = "id"; private static final string key_message = "message"; private static final string key_send = "send"; private static final string key_status = "status"; private static final string key_time = "time"; public dbhandler(context context) { super(context, database_name, null, database_version); //table_messages=name; } // creating tables @override public void oncreate(sqlitedatabase db)...

file upload - asp.net mvc-5 HttpPostedFileBase is null -

this question has answer here: httppostedfilebase return null in asp.net mvc 4 answers i messing around file uploading using asp.net mvc-5 httppostedfilebase showing me httppostedfilebase null after selecting image here code <input type="file" title="search image" file-model="profileimage" id="allfilepath" name="file" /> <button type="submit" class="btn btn-primary col-sm-5"> <span class="glyphicon glyphicon-plus"></span> </button> and controller [httppost] public actionresult insert(httppostedfilebase file, quotationcompany quotecomp) { var allowedextensions = new[] { ".jpg", ".png", ".jpg", "jpeg" }; if (file == null) { viewbag.message = ...

ckeditor 4.7.1 not saving youtube embed code -

i trying unsuccessfully insert embed code 4.7.1 ckeditor. click on source...paste embed code...click source again...the video shows , can play video. when go save "post" text , video thing remains text. iframe replaced <p>&nbsp;</p> . here config.js file: ckeditor.editorconfig = function( config ) { // define changes default configuration here. // complete reference see: // http://docs.ckeditor.com/#!/api/ckeditor.config // toolbar groups arrangement, optimized 2 toolbar rows. config.toolbargroups = [ { name: 'clipboard', groups: [ 'clipboard', 'undo' ] }, { name: 'editing', groups: [ 'find', 'selection', 'spellchecker' ] }, { name: 'links' }, { name: 'insert' }, { name: 'forms' }, { name: 'tools' }, { name: 'document', groups: [ 'mode', 'document', 'do...

javascript - How to Animate Splitting Different Layers of an Image (product image) in Landing Page -

i want animate splitting of product image when user scrolls section. i.e. when user scrolls down , enters product image section, want trigger animation of revealing different layers/composition of product. done here (scroll down second section after landing page): https://simbasleep.com/ a pure css3 solution preferred. however, library solutions such jquery, gsap, etc welcome. you can use scrollmagic lib http://scrollmagic.io/examples/expert/image_sequence.html docs example: // define images var images = [ "../../img/example_imagesequence_01.png", "../../img/example_imagesequence_02.png", "../../img/example_imagesequence_03.png", "../../img/example_imagesequence_04.png", "../../img/example_imagesequence_05.png", "../../img/example_imagesequence_06.png", "../../img/example_imagesequence_07.png" ]; // tweenmax can tween property of object. use object cycle through ...

python - Sum All elements of each array in an array of arrays -

i have dictionary: import numpy np dict={'w1': np.array([[ 1.62434536, -0.61175641, -0.52817175], [-1.07296862, 0.86540763, -2.3015387 ]]), 'b1': np.array([[ 1.74481176], [-0.7612069 ]]), 'w2': np.array([[ 0.3190391 , -0.24937038], [ 1.46210794, -2.06014071], [-0.3224172 , -0.38405435]]), 'b2': np.array([[ 1.13376944], [-1.09989127], [-0.17242821]]), 'w3': np.array([[-0.87785842, 0.04221375, 0.58281521]]), 'b3': np.array([[-1.10061918]])} i need sum elements of w1, w2, w3 after squared them, each 1 @ time of three. i used extract list keys w(i) l=[v k, v in dict.items() if 'w' in k] how sum of squared elements in each array? when taken each array separately do: np.sum(np.square(l[0]) 10.4889815722 l[0] i don't know though how sum them in 1 shot ...

c++11 - multiple inheritance with concept-based polymorphism c++ -

using concept-based polymorphism focuses on using value semantics , type erasure implement type polymorphism, how 1 implement multiple inheritance? an example of interface follows. defines type, serializable, require functions serialize , size appropriate signature. #include <iostream> #include <memory> using namespace std; class serializable { public: template <typename t> serializable(t x) : self_(new model<t>(move(x))) { } friend size_t serialize(const serializable& x, uint8_t* buffer, size_t buffersize) { x.self_->serialize_(buffer, buffersize); } friend size_t size(const serializable& x) { x.self_->size_(); } private: struct concept { virtual ~concept() = default; virtual size_t serialize_(uint8_t*, size_t buffersize) const = 0; virtual size_t size_() const = 0; }; template <typename t> struct model : concept { model(t x) : data_(move(x)) { } size_t serialize_(uint8_t* buffer...