Posts

Showing posts from July, 2013

jekyll - How to use a variable included in a layout in posts using that layout? -

consider following 3 snippets specified files: <!-- _includes/my_var.html --> {% assign my_var = 'foo' %} and <!-- _layouts/default.html --> {% include my_var.html %} ... and post: --- layout: default --- i'd reference {{my_var}} the last 1 doesn't appear see variable defined in includes file. nil value of my_var . wrong expect should in scope? if so, what's alternative approach? you cannot layout variables page or post. but, looks configuration variable, can set in _config.yml , access anywhere site.my_var .

javascript - How to bind a $scope variable to a normal variable in AngularJS? -

in angularjs controller, have variable $scope.name assigned input's ngmodel . i wanted save value of $scope.name normal variable, process in controller without changing value of input box. so did var name = $scope.name the issue is, 2 seem linked... when change value of name , value of $scope.name changes, , changes value of input box. how can stop this? how can assign $scope variable normal variable, once, without continued binding? thank you! you need use angular.copy() like: var name; $scope.name = 'name'; function copy(){ name = angular.copy($scope.name); } see more

osx - Create a timestamp given date values columns in Excel -

Image
i have date in following format: column a: day (number form) column b: month (number form) column c: year (yy number form, in case 15 , 16 2015 , 2016) column d: hour (number form, 0 through 23) column e: minute (number form) how can convert timestamp (namely, timestamp representing number of minutes)? don't see kind of "dateserial" type function in excel (at least on mac version). you can formula: =date(2000+c1,b1,a1)+time(d1,e1,0) this number around 42000, need format in number format want. then if want time difference between 2 rows use: =f2-f1 and format cell custom format of [hh]:mm:ss note method excel stores date/time is: dates whole numbers each day since jan 1st 1900 in 42000's. time decimal based on 24 hours being 1. so both current time 42531.63956 or 6/10/2015 3:21:33 or so, when mask applied. excel uses method can math on values. method on how output displayed depends on format of cell in number resides.

data visualization - highcharts solidgauge - make it striped or 3D -

Image
i using highcharts solid gauge make donut charts. i want blue series 3d. want green series 3d. how do this? if not possible, want red series striped, not solid. thank help. please ignore bugs. based on can research, doesn't seem can apply 3d settings solid gauges. you can donut charts, however, can see in example: http://jsfiddle.net/brightmatrix/nxkv5woh/ . all added here following code: chart: { type: 'pie', options3d: { enabled: true, alpha: 45 } }, this result: as striped series, there highcharts plug-in pattern fills might helpful you: http://www.highcharts.com/plugin-registry/single/9/pattern-fill . if, however, wanted banded effect looks spokes on wheel, achieve "dummy" series of even-numbered data on separate series, each data point has alternate color. i hope information helpful.

java - How to transfer an <option> tag's element into an array in javascript? -

how should options inside dropdown list (under html) , convert array in javasctipt? code snippet comes jsp/ html. form.projectlist java object call <c:foreach items="${form.projectlist}" var="val"> <option ${form.project eq val.projectid?'selected="selected"':''} value="<c:out value="${val.projectid}"/>"><c:out value="${val.project}"/></option> </c:foreach> use id of select , jquery populate array. following var arr=new array(); $("#dropdwonid option").each(function() { arr.push($(this).text()); });

java - Spring boot component scan include a single class -

i using spring component scan auto detect beans as: @componentscan({"com.org.x, com.org.y"}) the issue want classes in com.org.x scanned want single class, com.org.y.someservice.class , alone scanned com.org.y how can achieve ? also apart using context scan, how can created bean , inject in application context ? you should define bean using method annotated @bean in configuration class, explained in the documentation .

android - qemu: hardware error: Can't set isa irqs with no isa bus present -

my english not good. firstly i'm sorry this. have problem android studio. operating system linuxmint. after updating v2.1.2, avd doesn't work. error output this: cannot launch avd in emulator. output: qemu: hardware error: can't set isa irqs no isa bus present. cpu #0: eax=00000000 ebx=00000000 ecx=00000000 edx=00000663 esi=00000000 edi=00000000 ebp=00000000 esp=00000000 eip=0000fff0 efl=00000002 [-------] cpl=0 ii=0 a20=1 smm=0 hlt=0 es =0000 00000000 0000ffff 00009300 cs =f000 ffff0000 0000ffff 00009b00 ss =0000 00000000 0000ffff 00009300 ds =0000 00000000 0000ffff 00009300 fs =0000 00000000 0000ffff 00009300 gs =0000 00000000 0000ffff 00009300 ldt=0000 00000000 0000ffff 00008200 tr =0000 00000000 0000ffff 00008b00 gdt= 00000000 0000ffff idt= 00000000 0000ffff cr0=60000010 cr2=00000000 cr3=00000000 cr4=00000000 dr0=00000000 dr1=00000000 dr2=00000000 dr3=00000000 dr6=ffff0ff0 dr7=00000400 efer=0000000000000000 fcw=037f fsw=0000 [st=0] ftw=00 mxcsr=00001f80 f

javascript for adobe acrobat form -

trying write script adobe acrobat xi form when user selects checkbox7 field should display value of 239 , if unchecked shows value of 0 have set mouse (is correct?) below code: var checkbox7value = this.getfield("checkbox7"); if (checkbox7value.isboxchecked(239)) var checkbox7value = 239 else var checkbox7value = 0 thanks in advance help! what return value of checkbox? default "yes", or else? however, code pretty messed up, must say… in first line, define field object, linked field checkbox7 in second line test whether 239th widget/occurrence of field checked. depending on result, redefine field object number. anyways, assuming don't have many calculations, , dependencies, , return value of checkbox field indeed "yes", add following calculate event of field result shall appear: if (this.getfield("checkbox7").value == "yes") { event.value = 239 ; } else { event.value = 0 ; } now if know checking check

C# Utility Class - Setting up for General Use and Compiling w/o Main -

okay, working on learning c#. great language, love working in general, i'm not understanding how on lack of utility classes. in essence, want set general utilities class can contained in folder , used project doing "using namespace globals/utilities/etc." command. in essence: using system; namespace globals { public static class commands { public static void waitforreturn() { console.writeline("press enter continue."); console.readline(); } } } similar above, such in other class can call functions including preprocessing directive. using system; using globals; namespace rectangledemo { <rectangle definition here> class demo { static void main(string[] args) { rectangle r = new rectangle(); rectangle s = new rectangle(5, 6); r.display(); s.display(); waitforreturn(); } } } as is, i'm trying compile 'ut

postgresql - Query two tables with one to many relationship -

i'm using 2 postgres tables have 1 many relationship. primary table called users , other table called files. the users table has following columns: id serial primary key, email varchar(128) not null, username varchar(128) unique not null, password_hash varchar(128) not null the files table has following columns: id serial primary key, user_id integer references users(id), title varchar(128) not null, url varchar(128) not null when log app, i'm querying files display doing cur.execute('select * files') and when want specific users files run cur.execute('select * files user_id = %i' % user_id) for query fetches files, i'd adjust username associated each file also. how should tailor execute statement make happen? try following. know syntax work other dbms': cur.execute('select f.*, u.username files f, users u u.id = f.user_id)

c# - Change specific word color in gridview -

i'm creating winforms application represents data user. in data, want highlight words specific colors. can in asp.net application adding style sheet , use in grid-view in answer . how can achieve same result in winforms gridview ? i'm using code below changes color whole cell, want change color of word. private void datagridview1_databindingcomplete(object sender, datagridviewbindingcompleteeventargs e) { foreach (datagridviewrow row in datagridview1.rows) { foreach (datagridviewcell cell in row.cells) { foreach( string word in wordss) if (cell.value.tostring().toupper().contains(word.toupper())) { cell.style.backcolor = color.red; } } } } you need use cellpainting event customize how cell drawn. check answer , hope you.

ios - GKTurnBasedMatch how to accept a new match invitation -

Image
what correct way programmatically accept match invitation gamekit's standard user interface? i seeing expectedstate="invited" foundstate="active" exception optional(error domain=gkerrordomain code=22 "the requested operation not completed because specified participant invalid." userinfo={gkserverstatuscode=5097, nslocalizeddescription=the requested operation not completed because specified participant invalid., nsunderlyingerror=0x14fa2cf70 { error domain=gkservererrordomain code=5097 "status = 5097, unexpected slot state expectedstate="invited" foundstate="active" the exception occurs under following scenario: player 1 - creates new match player 2 player 1 - makes first move player 2 - attempts load data turn based match & accept match invitation. i using ios' standard user interface match making. gkturnbasedmatchmakerviewcontroller requesting new match let matchrequest = gkmatchrequest() mat

javascript - Highcharts - tooltip zindex relative to series -

Image
i trying render tooltip behind series in solid gauge. have tried changing z-index , opacity in style parameter, not seem change anything. tooltip.js import $ 'jquery'; const tooltip = (props) => { let container = `#score-visual-${props.equation.eqid}`; return { usehtml: true, animation: false, borderwidth: 0, borderradius: 40, backgroundcolor:'white', shadow:false, style:{ fontsize: '14px' }, formatter: function () { return `<table> <tr><td style="font-size:1.6em; color:${this.point.color}; font-weight: bold; text-align: center"> ${this.y}${this.point.unit} </td></tr> <tr><td style="text-align: center""> ${this.series.name} </td></tr> </table>` },

java - Eclipse create new class take need time -

i newbie in eclipse. have problem. when create new class, eclipse needs long time loading, 10-20 seconds. when see friend, can create new class without loading. have try add more xms , xmx in eclipse.ini doestn't solve problem. fyi, use gnome ubuntu 16, eclipse 4.5.2, ram 4gb, proc quad-core 2.4ghz how make faster? you can see loading screen shoot here

javascript - use of async module in node.js -

i got know async module ,and talking it. know below code trigger callback when 2 db calls done. async.parallel([ function(){ dbcall() }, function(){ dbcall() } ], callback); but compulsory use async module? if wrap code can async too. wrote in controller var token = require('../models/token'); token.getalltokens(owner, function(err,callback){ var device_tokens = callback.token; gcm_call(device_tokens); //another ajax call }); above code work, tested it, gcm_call wait , run after getalltokens. why use async module? make code more readable? so why use async module? make code more readable? to degree, yes, make more readable. provides useful utilities write more readable , more performant code. but importantly, because it's solving common problems when using async functionality. showing example used single callback, async module example in first code block first waiting async stuff finish, calls callback function. how solve vanil

vb.net - Storing data in the textbox for future use -

i want store number of cattle in textbox updated frequently. every time when application executes textbox must display recent number stored in textbox before application closed. appreciate input, thanks in visual studio, can bind user setting control. settings automatically managed you. able find simple video demonstrates process. https://www.youtube.com/watch?v=cvcsrbfb8r4 this feature supper easy use , extremely powerful in sense class tagged serializable can used in utility; not basic types. good luck.

windows - Win32 Named pipe behavior -

win7, x64, c++, win32 api, console app, visual studio community 2015 i've scoured questions on named pipes , can't find answer need. i'm writing server broadcast data 1 way via named pipe multiple identical clients on same machine. sever , each client in own process (.exe). data sent when all clients have somehow signaled server ready (via named event or other mechanism). the documentation says multiple clients can connect single pipe instance, proceeds talk multiple instances . i have few questions pipe on server side: for small number of clients , low throughput, simplest: 1 thread, 1 pipe instance; 1 thread , multiple pipe instances; multiple threads , 1 instance per thread? if single thread connectnamedpipe multiple times on same instance of pipe, mean single writefile broadcast clients have connected particular instance of pipe? if multiple clients can connect particular instance of pipe, writing pipe server side block until all clients have re

recursion - python 3.4 recursive formula for an infinity series -

here's formula want implement: given x , y , define x+x^y , continue: ... + (x**x**y) that is: next term exponent of 2 anterior terms piling up. so get: x + [x**y] + [x**(x**y)] + [x**y]**[x**(x**y)] + ...

How to set all values in listview android -

i have created listview. values retrieved json response last values displayed in list.what displaying values in list view. sixfragment.movielist = new arraylist<movie1>(); (int i1 = 0; i1 < jsonarray3.length(); i1++) { try { jsonobject jsonobject = jsonarray3.getjsonobject(i1); review_rating = jsonobject.optstring("review_rating").tostring(); username_rate = jsonobject.optstring("username").tostring(); review_title = jsonobject.optstring("review_title").tostring(); review_desc = jsonobject.optstring("review_desc").tostring(); sleep = jsonobject.optstring("sleep").tostring(); location = jsonobject.optstring("location").tostring(); service = jsonobject.optstring("service").tostring(); rooms = jsonobject.optstring("rooms").tostring(); cleanliness = jsonobject.optstring("cleanliness").tostr

angular - Why apps built with Angular2 are so heavy? -

Image
recently planned revamp our existing web-app built in jmvc . , decided go angular-2. and test load size, did following: ng new test123 cd test123 ng build -prod and deployed dist folder content on apache , showed 1.0mb transferred . my entire jmvc application, business logic hardly 1.2mb when loaded in browser. what can decrease size of angular-2 app after deployment? as per comments, ng2 team working on reducing size of framework nearing release. prior this, following typical http conventions minimising js size main thing, i've found webpacks optimisations heavily reduce size of generated js substantially. thats 313kb entire angular2 code base entire app includes inline html , styling (i'm not sure result hello world example though). the webpack plugins can use webpack.optimize.occurenceorderplugin(true) webpack.optimize.uglifyjsplugin() webpack.optimize.dedupeplugin() hope helps!

Angularjs 1.5.5 with @Component decorator -

i having hard time finding code example of component using angularjs 1.5.5 ( not angular 2.0 ). angular 1.5.5 supports decorators @component or @injectable , if yes can please share code example ? also know how inter component communicaton works in angular 1.5.5 ? have @input decorator ? if willing use transpiler (babel or ts) can use ng-decorated provide angular 2 syntax angular 1.5 components. works @inject/service/input/output/etc

r - How can I get the pictures one by one rather than showing them together? -

Image
when entered code plot(x.logis) , output 4 pictures showing together, looking 1 of them. how plot them separately? here code: x<-c(2800,3260,66.5,195,420,840,1380,469,260,50,209.8,370,27,420,157) y<-log10(x) # load fitdistrplus package using fitdist function library(fitdistrplus) # fit logistic distribution using mle method x.logis <- fitdist(y, "logis", method="mle") plot(x.logis) this result of output: i guess need cdfcomp , denscomp , ppcomp , qqcomp cdfcomp(x.logis, addlegend=false) denscomp(x.logis, addlegend=false) ppcomp(x.logis, addlegend=false) qqcomp(x.logis, addlegend=false)

responsive design - MaterializeCSS how can i make row column height the same? -

i have basic grid on materializecss problem column not same height layout became mess. know has been ask on bootstrap none of solution works me in materializecss this jsfiddle https://jsfiddle.net/zrb46zr2/1/ <div class="row"> <div class="col m4 s6"> <img src="http://lorempixel.com/580/250/nature/1" class = "responsive-img"> <p> looooong looooong looooong looooong looooong text </p> </div> <div class="col m4 s6"> <img src="http://lorempixel.com/580/250/nature/1" class = "responsive-img"> <p> short text </p> </div> <div class="col m4 s6"> <img src="http://lorempixel.com/580/250/nature/1" class = "responsive-img"> <p>short text</p> </div> <div class="col m4 s6"> <img src="http://lorempixel.com/580/250/nat

virtual machine - Qemu using too much disk -

i using centos 7 on host, , qemu emulation windows server, create 15 gb disk, after week or so, disk goes 30 gb, there way stop this? using snapshots. there windows service may creating lots of files, or maybe hd being used ram imprive system? 15 gb 30 lot, , server's hd not bigger, it's big issue me. reinstalled , turned lot of things off, same thing happens again. little here. you don't mention kind of disk image you're using, , configuration is. i'm guessing description qcow2 image, since mention use of snapshots. snapshots stored inside qcow2 image increase size beyond visible guest os. eg if create qcow2 image has virtual disk size of 15 gb, possible consume more 15 gb on host if have saved multiple different snapshots in image , guest has been writing alot of data between each snapshot. when snapshots deleted, space consumed qcow2 won't released os normally. while seeing 30 gb of usage sounds quite large not totally unreasonable if using snaps

php - i moved opencart on another domain and error ini_set() is disable -

i moved opencart website on server, receiving following errors. warning: ini_set() has been disabled security reasons in /home/shoppin6/public_html/system/library/session.php on line 7warning: ini_set() has been disabled security reasons in /home/shoppin6/public_html/system/library/session.php on line 8warning: ini_set() has been disabled security reasons in /home/shoppin6/public_html/system/library/session.php on line 9warning: ini_set() has been disabled security reasons in /home/shoppin6/public_html/system/library/session.php on line 10warning: session_start(): cannot send session cache limiter - headers sent (output started @ /home/shoppin6/public_html/index.php:102) in /home/shoppin6/public_html/system/library/session.php on line 21 ive edited php.ini file this disable_functions = allow_url_fopen, escapeshellarg, escapeshellcmd, ini_alter, passthru, parse_ini_file, popen, proc_open, proc_close, proc_terminate, proc_get_status, proc_nice, readfile, show_source, system a

Python code to do GET request from pipedrive API -

i using python-pipedrive wrap pipedrive's api though doesn't quite work out of box on python3 (which i'm using) modified it. i'm having trouble http requests portion. this taught me how use httplib2: https://github.com/jcgregorio/httplib2/wiki/examples-python3 basically, want send request this: https://api.pipedrive.com/v1/persons/123?api_token=1234abcd1234abcd this works: from httplib2 import http urllib.parse import urlencode pipedrive_api_url = "https://api.pipedrive.com/v1/persons/123?api_token=1234abcd1234abcd" response, data = http.request(pipedrive_api_url, method='get', headers={'content-type': 'application/x-www-form-urlencoded'}) however, pipedrive returns error 401 'you need authorized make request.' if this: pipedrive_api_url = "https://api.pipedrive.com/v1/" parameters = 'persons/123' api_token = '1234abcd1234abcd' response, data = http.request(pipedrive_api_url + pa

Optimize Wordpress Database Design -

i'm using wordpress real estate theme. there many posts in post-meta table. each property post produces more 20 metas , go in post meta table. so, if have 1million properties there might more 20 millions rows in post meta table. and. think might take longer query post meta. there anyway maintain database better usual ways wordpress? a simple solution removing unnecessary posts , meta associated it! if want keep , work on database side, simple plugin wp-sweep in cleaning , optimising tables in database. remember: database before perform maintenance

jquery - Trouble with positioning of element with javascript -

i'm trying achieve navigation bar "catched" user scrolls it. semi achieving goal current attempt moving main content scroll not want achieve. here's have https://jsfiddle.net/abp1rwhp/ $(function(){ var navheight = $('#nav-bar').offset().top; console.log(navheight) $(window).on('scroll', function() { if(screen.width < 980) { } if($(window).scrolltop() > navheight){ $('#nav-bar').css({ 'top': $(window).scrolltop() > 0 ? '0px' : '0px', 'position': 'fixed' }) } if($(window).scrolltop() < navheight){ $('#nav-bar').css({ 'top': '', 'position': 'relative' }) } }); }) as can see content section moves down (i think 40px) when scroll, how go fixing issue? because nav-bar relative, pushes down contents section. when give position fixed, section

javascript - How to center map around area or markers? -

Image
i have map displays "check-ins" of user. need cater first-time display of map in 2 scenarios: the user has never checked in: in case zoom out such level display specific "area". area called "western cape, south africa". map , zoomed in red area on far edges of map , see that. if user has checked in 1 or more places, zoom in user sees close-up view of places has checked in. example: so red "blocks" area see on map. not whole nap. this how create map: mapdiv = document.getelementbyid('map'); map = new google.maps.map(mapdiv, { center: markerlocation, zoom: zoomlevel, }); and add "markers" checkins: marker = new google.maps.marker({ position: markerlocation, label: '', icon: 'img/map_marker.png', map: map }); so guess need focus on "zoom level". determines how of map shown. keep in mind, map responsive, height , width varies. furthermore, markers placed in k

reactjs - Passing image source to another navigation - React Native -

i build simple app school , have question regarding passing images source 1 navigation view navigation view. here code: class projekt2 extends react.component { render() { return ( <navigator initialroute={{id:'first'}} renderscene={this.navigatorrenderscene}/> ) } navigatorrenderscene(route, navigator) { _navigator = navigator; switch(route.id) { case 'first': return (<first navigator={navigator} title="first" />); case 'second': return (<second navigator={navigator} title="second" />) case 'third': return (<third navigator={navigator} title="third" />) } } }; class first extends react.component { // http://blog.paracode.com/2016/01/05/routing-and-navigation-in-react-native/ navsecond() { this.props.navigator.push({ id: 'second', }) } render() { //na sklad se da navigacijske slide, če

c++ - what is inside skipped memory address? -

we know integer variable take 4 (byte) memory address. wonder, if initialize integer variables , make pointer it. can value of pointer (which have address of variable: 0x22fef8 in computer). how memory address after 0x22fef8 0x22fef9, 0x22fefa, 0x22fefb? in there? value of variable if dereference address? how access them? thank you. you're right: in 32-bit computer integer takes 4 bytes. in c, can expressed following code: int = 0x12345678; int *p_i = &i;` if p_i gets value 0x22fef8 , p_i++ become 0x22fefc since point next integer. if want see what's in bytes make i , need use different pointer: typedef uint_8 byte; byte *p_b = (byte *)&i;` that means change pointer-to-int &i represents , typecast pointer-to-byte. still have value 0x22fef8 since that's first byte of i - if p_b++ change 0x22fef9 . , note if print out original value of *p_b (that is, byte pointing to), not give same value i . depending on computer, print out either f

winbugs - BUGs error message -

i new winbugs/openbugs , having difficulty de-bugging code. error message "expected variable name". not find variable, not defined. code follows: model { y[1:3]~dmulti(p[1:3],m) p[1:3]~ddirch(alpha[]) } list ( y=c(383465, 467074, 142852), m=993391 ) i have found errors follows: 1.the space can't follow "list". therefore, should be list( y=c(383465, 467074, 142852), m=993391 ) 2.the full codes should add definition alpha[] follows: model { y[1:3]~dmulti(p[1:3],m) p[1:3]~ddirch(alpha[]) (r in 1:3){alpha[r]<-1} } list( y=c(383465, 467074, 142852), m=993391 ) this seems small problem, occurs in newcomers!!

sql - Using DATEADD() within a cte -

Image
i'm trying use dateadd() function in code every 'week_number_ apply date , add 7 days next week number. issues i've had if try code: dateadd(day,(row_number() on (order leagueid)-1)*7,@startfixtureweek) fixturedate it displays new dates every row, , each week has 6 rows assigned them (the number of rows assigned change in future), instead of each row stating 'week_number' 1, , fixturedate '01-09-2016' , states first row of 'week_number' 1 has fixturedate '01-09-2016' , second row of 'week_number1' has fixturedate '08-09-2016' , on. it should fixturedate 'week_number' 1 '01-09-2016' , all of 'week_number' 2 '08-09-2016 , 'week_number' 3 '15-09-2016' , on. if try this: dateadd(day,(row_number() on (order leagueid, week_number)-1)*7,@startfixtureweek) fixturedate, no results displayed below code have dateadd() function applied (14th line bottom. virtually need workin

xamarin studio - Mvvmcross Android - Error finding resource ids for MvxBinding -

i'm trying follow firstdemo tutorial stuart's n+1 on xamarin studio. i'm getting following exception: [mono] unhandled exception: [mono] cirrious.crosscore.exceptions.mvxexception: error finding resource ids mvxbinding - please make sure resourcestocopy linked executable ---> system.invalidcastexception: cannot cast source type destination type. [mono] @ cirrious.mvvmcross.binding.droid.resourcehelpers.mvxandroidbindingresource..ctor () [0x000ed] in /users/stuartlodge/documents/github/mvx/mvvmcross/cirrious/cirrious.mvvmcross.binding.droid/resourcehelpers/mvxandroidbindingresource.cs:57 [mono] --- end of inner exception stack trace --- [mono] @ cirrious.mvvmcross.binding.droid.resourcehelpers.mvxandroidbindingresource..ctor () [0x00142] in /users/stuartlodge/documents/github/mvx/mvvmcross/cirrious/cirrious.mvvmcross.binding.droid/resourcehelpers/mvxandroidbindingresource.cs:72 [mono] @ cirrious.mvvmcross.binding.droid.resourcehelpers.mvxandroidbindingre

jquery - javascript zoom default image after change image src value -

there's problem javascript here. first, if click image zoom image. problem when image change different 1 , click, still zoom first image, not new one. my html (container show image , zoom it) <div class="col-md-8"> <span id='ex3' class="zoom"> <img class="img-responsive" id="myimage" width='750' height='550' src="<?php echo "./image/product/p1/". $row['item_image']. ".jpg"; ?>"> </span> </div> my html (next image want click , zoom) <div class="col-sm-3 col-xs-6"> <a href="#"> <img class="img-responsive portfolio-item subimage" onclick="changeimage1(); <?php $show1="./image/product/p1/". $row['item_image']. ".jpg"; ?>" src="<?php echo "./image/product/p1/". $row['item_image']. ".jpg";

javascript - How to refresh div after AJAX request in MVC? -

i'm not sure how refresh data after use ajax. here's have: frontend: @model tfu.model.db_user <div id="listtelnumbers"> @foreach (var item in model.db_user_phones) { <dl class="dl-horizontal"> <dt> @item.phone </dt> <dd> <button id="removebutton" class="btn btn-default" onclick="sendrequesttoremove('@item.user_id', '@item.phone')">usuń</button> </dd> </dl> } </div> script - fadeout works fine don't know should fadein . guess missing small part of code there. how can fadeout record removing instead list. <script> function sendrequesttoremove(id, phone) { var data = { "user_id": id, "phone": phone

java - How to put value in HashMap? -

this question has answer here: how initialize array in java? 9 answers i have map map<string,string[]> data = hashmap<string,string[]>(); and want put value in it. "key":["value1","value2"] i try error: data.put("key",["value1","value2"]);//syntax error you try using array initializer fixed size string arrays following map<string, string[]> data = new hashmap<>(); data.put("key", new string[]{"val1", "val2"}); this should work

github - Get full activity log (not commit log) for a local git repo -

i working on personal project gitty , unofficial client git. uses git command line output show necessary data. want plot graph gitk git repo using (gitgraphjs)[ http://gitgraphjs.com] , want output showing activities initial commit - master more commit - master created new branch develop #branch created more commits in master - master added bla bla - develop merged master , develop #branch merged commit - master i tried using git log --all --oneline , git reflog didn't gave necessary data when particular branch created. can parse git log --graph --oneline output don't think that's right way of doing it. i want know command should use or there others way plotting graph.

java - checking number is power of 2 for numbers greater than 2^64, implementation of manual division -

i trying check if number (input string ) power of 2. problem number might greater 2^64 (long long limit). if store in double cannot binary operations on (so trick v & (v - 1) == 0 not work). here solution stumbled upon: public class solution { public int power(string a) { string dividend = a; stringbuilder str; if (a == null || a.length() == 0) return 0; if (a.length() == 1 && a.charat(0) == '0') return 0; while (dividend.length() > 0 && !dividend.equalsignorecase("2")) { str = new stringbuilder(); int carry = 0; int n = dividend.length(); if (n > 0) { int num = dividend.charat(n - 1) - '0'; if (num % 2 == 1) return 0; } (int = 0; < n; i++) { char c = (char) (dividend.charat(i) - '0'); i

android - How to create users in/for apps -

i have question has straight forward answer, asking here make sure. if want develop app users (e.g. snapchat, wordfeud etc.), how do it? have use database of kind? users not have information stored them, nothing more username , score collection. can without using databases? , how set app having users? you need database. simplest, can set mysql database on server, , make queries it. you can follow tutorial: http://codewithchris.com/iphone-app-connect-to-mysql-database/

jquery - How to create readonly select box but I will post that value? -

i want readonly select box. post value element. when disabled select box can't post value. <select name="office_name" id="office_name" readonly> <option value="">----select office----</option> <option value="1">bengli</option> <option value="2">english</option> </select> readonly not work disabled work. need readonly not disabled. possible? you can like: just don't disable option want post else disable options so 2 value posted php now. <select> <option disabled="disabled">1</option> <option selected="selected">2</option> <!-- dont disable option want post else disable options--> <option disabled="disabled">3</option> </select>

javascript - show a page if user is logged in web application -

i used google plus service logging web app (using html button), , saving db passing in ajax server. now, want build different page user able post images , descriptions need know user posted information. how can that? save user auth token (or whatever you're identifying user with) in localstorage on client-side , send within ajax call; , validate on server-side.

Discrepancy while inserting data in MongoDB through pymongo -

i have json file 20 records. tried inserting data json mongodb through python(pymongo specific). following python code. from pymongo import mongoclient pprint import pprint import json # creating mongo db client , connecting # fantasyscout database. # inserting players in collection(table) # players. client = mongoclient() db = client.fantasyscout # reading data dumper json file open("c:\\team.level.json") db_data: data = json.load(db_data) # reading every element in json data , # inserting in db. print len(data) print data[str(20)] element in range(1,++len(data)): db.team_level.insert(data[str(element)]) the len(data) holds value 20 (confirmed printing in python). though after running script, no. of records inserted 19 , data["20"] not inserted. after changing range manually (1,21), script enters 20 records. missing trivial . please point out mistake. for loop 0 2, therefore running 3 times. for x in range(0, 3): print "we'r

java - url.openConnection(); is not actually invoked -

im building graduation project collage "smart homes, home automation system" implemented arduion on mock-up structure. to have full image, arduaio takes pin number via request switch on or of specific home device. its cool when send http request browser, when use openconnection(); method, it's never happens, when use data home rooms , devices it's working greatly. i gave app permission access internet. the code simple project made solve praticualy problem: mainactivity.java package com.bitsandbytes.xemma_pc.newprototype; import android.os.asynctask; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.util.log; import android.view.view; import android.widget.button; import java.io.ioexception; import java.net.httpurlconnection; import java.net.malformedurlexception; import java.net.url; public class mainactivity extends appcompatactivity { @override protected void oncreate(bundle savedinstancesta

mysql - PHP - Use Field Names as Variable -

i getting error "warning: mysql_field_name() expects parameter 1 resource, object given in... on line 28" i new php, trying accomplish read html file , replace custom tag value of record. tag structure |+field-name-record#+| example if sql returns 2 records "name" field following 2 tags |+name1+| , |+name2+| in html file , replace 2 returned values. adam , jim. below code have far. $c = '|+name1+|<br>|+name2+|'; echo(replacehtmlvariables(mysqli_query($con,"select * nc_names"),$c)); function replacehtmlvariables($results, $content){ while($row = mysqli_fetch_array($results)){ //define variable count record on $rnum = 1; //loop through fields in record $field = count( $row ); ( $i = 0; $i < $field; $i++ ) { //use field name , record number create variables replace current record value $content = str_replace("|+".mysql_field_name( $results, $i ).$rn

ruby - Rails 4.2 enum not working -

i trying use rails enum fields user status functionality in app enums don't seem working(i have used devise manage user login, registration .etc). result in rails console status appears status:0 instead of status:pending status:active status:suspended .etc user = user.first user load (1.6ms) select "users".* "users" order "users"."id" asc limit 1 => #<user id: 1, email: "email@gmail.com", encrypted_password: "$2a$11$tfsx2xkearxez1jlrtd6hocvj3scqyknkekrkqgyldx...", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 1, current_sign_in_at: "2016-06-10 22:57:03", last_sign_in_at: "2016-06-10 22:57:03", current_sign_in_ip: "::1", last_sign_in_ip: "::1", created_at: "2016-06-10 22:57:03", updated_at: "2016-06-11 10:59:41", first_name: "john", last_name: "smith", phone: nil, *

algorithm - Find best submatrix with least sum of differences between max element and other elements of size x*y of large matrix a*b -

given matrix a*b , find min sum of differences between max element , other elements of possible submatrixes of size xy eg 2 3 4 5 6 1 for submatrix of sizes 2*2 2 3 5 6 max = 6 sum of diffs = |6-2|+|6-3|+|6-5|+|6-6| = 8 3 4 6 1 max =6 sum of diff = |6-3|+|6-4|+|6-6|+|6-1| = 10 ans = 8 minimum surely brute force approach checking each possible submatrix , calculating diff between max , every element

javascript - html canvas: insert multiple images into separate canvas -

i have multiple canvases, each data-id attribute used retrieve dataurl in order draw image so: <canvas data-id='2' class='drawing-result> the following put them in last canvas: var $canvases = $(".drawing-result"); (var i=0; i<$canvases.length; i++){ var canvas = $canvases.get(i); var context = canvas.getcontext('2d'); var imageobj = new image(); imageobj.onload = function(){ context.drawimage(this, 0, 0); }; // skipping code retrieving dataurl using data-id imageobj.src = dataurl; i suspect may have shallow copying things, can't case because put var everywhere. javascript's var variable declaration function scoped, not block scoped. context being overwritten every time loop runs. instead of for-loop, use jquery's .each() function: $(".drawing-result").each(function (i, canvas) { var context = canvas.getcontext('2d'); var imageobj = new image(); imageobj.onload = fun

python - Assigning 2d array in vector of indices -

given 2d array k = np.zeros((m, n)) , list of indices in range 0, 1 .., m-1 of size n called places = np.random.random_integers(0, m-1, n) how assign 1 in each column of k in places[i] index running index. achieve in python compact style , without loops examples: n = 5, m =3 places= 0, 0, 1, 1, 2 then: k = [1, 1, 0, 0, 0 0, 0, 1, 1, 0 0, 0, 0, 0, 1] rslt = np.zeros((m, n)) i, v in enumerate(places): rslt[v,i]=1 full code: import numpy np n = 5 m=3 #places = np.random.random_integers(0, m-1, n) places= 0, 0, 1, 1, 2 rslt = np.zeros((m, n)) i, v in enumerate(places): rslt[v,i]=1 print(rslt) out [34]: [[ 1. 1. 0. 0. 0.] [ 0. 0. 1. 1. 0.] [ 0. 0. 0. 0. 1.]]