Posts

Showing posts from July, 2014

php - retrieve email address (only) via lists method in Mailchimp API v3.0 -

i starting migration mailchimp api 2.0 - 3.0, , trying replicate methods used before. one task retrieve of members email addresses on particular list currently have $result = $mailchimp->get('/lists/'.$list_id.'/members/'); which returns members array, can't figure out how add fields parameter url retrieve fields want, (eg fname, email address) worked out, on first page http://developer.mailchimp.com/documentation/mailchimp/guides/get-started-with-mailchimp-api-3/ eg, id, email address , merge fields only,... $result = $mailchimp->get('/lists/'.$list_id.'/members?fields=members.id,members.email_address,members.merge_fields');

c++ - Encode Audio using Sink Writer -

i found this article explaing how encode video using media foundation. i trying encode audio using principle used in above link. i stuck on setting correct input media type sink writer. here part: if (succeeded(hr)) hr = mfcreatemediatype(&pmediatypein); if (succeeded(hr)) hr = pmediatypein->setguid(mf_mt_major_type, mfmediatype_audio); if (succeeded(hr)) hr = pmediatypein->setguid(mf_mt_subtype, mfaudioformat_float); if (succeeded(hr)) hr = pmediatypein->setuint32(mf_mt_audio_num_channels, cchannels); if (succeeded(hr)) hr = pmediatypein->setuint32(mf_mt_audio_samples_per_second, samplerate); if (succeeded(hr)) hr = psinkwriter->setinputmediatype(streamindex, pmediatypein, null); my code fails on last line while setting input media type. any help, how handle this? thanks. you need supply mf_mt_audio_bits_per_sample in media type. must set 16. check input types requirements here: https://msdn.microsoft.com/en-u...

algorithm - Distance of every possible path between all nodes in minimum spanning tree -

i want distance of nodes nodes. there few questions regarding none solves problem. appoach implementing recursive dfs , storing result of each path while backtracking problem having high running time , going through path n number of times (n being number of edges). as can see in code running dfs every possible node root. dont know how reuse path know answer in 1 iteration of dfs search. i think done in o(n) minimum spanning tree , there 1 path between pair of nodes. my code : vector<int> visited(50001); map< pair<ll,ll> , ll> mymap; map<ll, vector<ll> > graph; void calc(ll start,ll node) { visited[node]=1; vector<ll>::iterator it; (it = graph[node].begin(); != graph[node].end(); ++it) { if (!visited[*it]) { ans+=mymap[make_pair(node,*it)]; mymap[make_pair(start,*it)]=ans; calc(start, *it); ans-=mymap[make_pair(node,*it)]; } } } in main : for(i...

java - Parallel training for Apache MLlib Random Forest -

i have java application trains mllib random forest (org.apache.spark.mllib.tree.randomforest) on training-set 200k samples. i've noticed 1 cpu core utilised during training. given random forest ensemble of n decision trees, 1 think trees trained in parallel, , utilising available cores. there configuration option or api call or else can enable parallel training of decision trees? i found answer this. issue how set spark configuration using sparkconf.setmaster("local"). changed sparkconf.setmaster("local[16]") use 16 threads, per javadoc: http://spark.apache.org/docs/latest/api/java/org/apache/spark/sparkconf.html#setmaster(java.lang.string) now training running far quicker, , amazon datacentre in virginia hotter :) a typical case of rtfm, in defence use of setmaster() seems bit hacky me. better design add separate method setting number of local threads/cores use.

android - Why is created a RadioGroup duplicate object in my RecyclerView.ViewHolder? -

i have recyclerview several viewholder , viewholder specify radiogroup creating alternately 2 radiogrouds objects memory reference, when check 1 other checked too: my recyclerview.adapter: private class questionadapter extends recyclerview.adapter<recyclerview.viewholder> { private list<question> mquestions; private final int simple = 0; private final int binary = 2; private final int options = 3; private final int checkbox = 5; public questionadapter(list<question> questions) { this.mquestions = questions; } @override public recyclerview.viewholder oncreateviewholder(viewgroup parent, int viewtype) { recyclerview.viewholder viewholder = null; layoutinflater inflater = layoutinflater.from(parent.getcontext()); switch (viewtype) { case simple: view view = inflater.inflate(r.layout.question_simple_cell, parent, false); viewholder = new questionsimp...

swift - iOS function similar ti viewDidLoad() -

i search function (included in ios or external library) similar viewdidload(). difference should searched function used when app starts first time, means when user opened app. viewdidload() used every time when view loaded. searched function xy() used when view loaded first time in runtime. this normal version user opened app, view 1 opens -> viewdidload() of view 1 -> user opens view 2 .... -> user goes view 1 -> viewdidload() of view 1 i search this user opened app, view 1 opens -> viewdidload() of view 1 , function xy() -> user opens view 2 .... -> user goes view 1 -> viewdidload() of view 1 (this time not function xy() because view loaded in runtime) thanks help! you can place code need run once in dispatch_once block obj-c , use static var swift obj-c: - (void)viewdidload { [super viewdidload]; static dispatch_once_t oncetoken; dispatch_once(&oncetoken, ^{ // code place here run once ...

grammar - Determine if a string can be derived ambiguously in a CFG -

i know given specific context free grammar, check if ambiguous requires checking if there exists string can derived in more 1 way. , undecidable. however, have simpler problem. given specific context free grammar , specific string, possible determine if string can derived grammar ambiguously? there general algorithm check? yes, can use generalized parsing algorithm, such glr (tomita) parser , earley parser , or a cyk parser ; of can produce parse "forest" (i.e. digraph of possible parsers) in o(n 3 ) time , space. (creating parse forest bit trickier "parsing" (that is, recognition), there known algorithms referenced in wikipedia article. since generalized parsing algorithms find possible parses, can rest assured if 1 parse found string, string not ambiguous. i'd stay away cyk parsing algorithm because requires converting grammar chomsky normal form, makes recovering original parse tree(s) more complicated. bison generate glr parser , if requ...

sql - MySQL ERROR 1241 (21000): Operand should contain 1 column(s) on Aggregate Query -

i using mysql ver 14.14 distrib 5.5.52, debian-linux-gnu (armv7l) using readline 6.3 running on raspbian os on raspberypi 3. i run following query , following results. mysql> select -> sensormeasurements.sensormeasurementdate, -> min(sensormeasurements.sensormeasurementvalue) "minvalue", -> max(sensormeasurements.sensormeasurementvalue) "maxvalue", -> avg(sensormeasurements.sensormeasurementvalue) "avgvalue" -> sensormeasurements -> inner join usersystemsensors -> on sensormeasurements.usersystemsensorid = -> usersystemsensors.usersystemsensorid -> inner join sensors -> on usersystemsensors.sensorid = sensors.sensorid -> inner join usersystems -> on usersystemsensors.usersystemid = usersystems.usersystemid -> inner join users -> on usersystems...

android - How to change Drag shadow after start? -

Image
hi know question has been answered in here , problem don't know how use imagedragshadowbuilder , how start drag can change shadow drag(ball). have different shapes different colors , change drawable depending on event (action_drag_entered). have shape imageview ball onlongclicklistener. r.drawable.mood_ball.xml: <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval"> <solid android:color="@color/colorprimarydark"/> <size android:width="60dp" android:height="60dp"/> </shape> i have on view.ondraglistener , change ball depending on event action_drag_entered: unfortunately not with: imagedragshadowbuilder.fromresource(context context,r.drawable.mood_ball_red.xml); (start r.drawable.mood_ball , change r.drawable.mood_ball_red ) try fire event like here did not work. how...

algorithm - How to load balance n servers with following constraints? -

this 1 of interview questions asked me in campus placements. there 'n' servers assigned load(in integer). have find out min. time required balance them such each server has load 1 on it. each server can share load adjacent neighbors(left , right). total load on servers add n. ex. n=10 initially, 0,0,10,0,0,0,0,0,0,0 time 1 : 0,1,8,1,0,0,0,0,0,0 time 2 : 1,1,6,1,1,0,0,0,0,0 . . time 7 : 1,1,1,1,1,1,1,1,1,1 answer 7. initially, load on servers can present in fashion. not necessary present on 1 server in our current example. how solve it? couldn't come approach. thanks in advance i'm assuming sum of load no more number of servers. approach using binary search on time , complexity o(n * logn) . say, i'm going check if possible balance load in time t . , i'll prefer distribute loads of server s among it's left ones first. if not possible distribute load it's left (because maybe take more time t distribute loads left or...

javascript - Proper way to search for elements in divs with given class? -

<div class="therarepets"> <div class="rarepet"> <span>old</span> <a href="http://examplepetshop.com/abc">buy it.</a> </div> <div class="rarepet"> <span>new</span> <a href="http://examplepetshop.com/def">buy it.</a> </div> </div> <a href="http://examplepetshop.com/vwx">outsidelinkdontwant.</a> <div class="thegoodpets"> <div class="goodpet"> <span>old</span> <a href="http://examplepetshop.com/ghi">buy it.</a> </div> <div class="goodpet"> <span>new</span> <a href="http://examplepetshop.com/jkl">buy it.</a> <a href="http://examplepetshop.com/stu">canhavemorewantedlinks.</a> </div...

inheritance - How to observe an inherited property in Polymer without redefining property -

how can inherited property observed in polymer without redefining property? example, behaviour module called inheritedbehaviour has property called x , added custom module per below: <dom-module id="foo-bar"> <script> polymer({ is: 'foo-bar', behaviors: [ inheritedbehaviour ] }); </script> </dom-module> this property can observed in following way: <dom-module id="foo-bar"> <script> polymer({ is: 'foo-bar', behaviors: [ inheritedbehaviour ], properties: { x: { type: number, observer: '_dosomething' } }, _dosomething: function() { console.log('something!'); } }); </script> </dom-module> ...

javascript - angular.element(...).scope(...) is undefined in s3 -

<html ng-app="myapp" ng-controller="myctrl" id="myctrl"> <head> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script> <script type="text/javascript" src="scripts/controller.js"></script> </head> <body> on here </body> </hmtl> this inside script. $(window).load(function(){ angular.element($("#myctrl")).scope().gobottom(); settimeout(function() { $('#loading').fadeout( 400, "linear" ); }, 300); }); }); this controller.js var app = angular.module('myapp', ['nganimate']); app.controller('myctrl', function($scope, $http) { $scope.gobottom = function(){ alert("success"); }; }); in local machine working.but when upload in s3.it shows error angular.element(...).scope(...) ...

c++ - Program crash when calling OpenGL functions -

i'm trying setup game engine project. visual studio project setup have 'engine' project separate 'game' project. engine project being compiled dll game project use. i've downloaded , setup glfw , glew start using opengl. problem when ever hit first opengl function program crashes. know has glewinit though glew initializing (no console errors). in engine project, have window class where, upon window construction, glew should setup: window.h #pragma once #include "gl\glew.h" #include "glfw\glfw3.h" #if (_debug) #define log(x) printf(x) #else #define log(x) #endif namespace blazegraphics { class __declspec(dllexport) window { public: window(short width, short height, const char* title); ~window(); void update(); void clear() const; bool closed() const; private: int m_height; int m_width; const char* m_title; glfwwindow* m_window; private: ...

ios - Change Destination in Apple Maps App from Notification - Swift 3 -

i have app opens destination in apple maps user can use apples turn turn navigation. when app receives local notification should ask user if wants end current navigation navigate new destination. right works if app active uialertcontroller , not when it's running in background local notification. (only destination changing method doesn't work, other methods called clicking "navigate new destination" button work) is possible archive same functionality local notification? thanks michael uialertcontroller & apple maps app (works) local notification (doesn't work)

Alternative to goto in c# -

i given program employer, , asked find out wrong it. have heard bad things goto's, , not have experience them whatsoever. know how reprogram without goto's? absolute mess... class goto { public int solve(int limit) { int result = 1; list num = new list(); list usedprimes = new list(); alpha: int = 2; if (isprime(i)) { num.add(i); } i++; if (i <= limit) goto alpha; result = 1; beta: if (num.count == 0) goto gamma; int upper, value; int prime = num[0]; //system.out.println(prime); upper = (limit - 1) / prime; value = upper * prime; if (!(isprime(upper) && upper != 1)) goto epsilon; //addusedprime(upper, usedprimes); deletefromlist(upper, num); goto phi; epsilon: deletefromlist(prime, num); phi: if (checkfactors(value, usedprimes)) goto ...

python - find lists that start with items from another list -

i have manifold of lists containing integers. store them in list (a list of lists) call biglist. then have second list, eg [1, 2]. now want find lists out of big_list start same items small list. lists want find must have @ least items second list. i thinking done recursively, , came working example: def find_lists_starting_with(start, biglist, depth=0): if not biglist: # biglist empty return biglist try: new_big_list = [] # try: smallist in biglist: if smallist[depth] == start[depth]: if not len(start) > len(smallist): new_big_list.append(smallist) new_big_list = find_lists_starting_with(start, new_big_list, depth=depth+1) return new_big_list except indexerror: return biglist biglist = [[1,2,3], [2,3,4], [1,3,5], [1, 2], [1]] start = [1, 2] print(find_lists...

php - Decode Json data Array and insert in to mysql -

this question may asked here tried search couldn't find have json data below {"cityinfo":[{"citycode":"5599","name":"druskininkai"},{"citycode":"2003","name":"kaunas"},{"citycode":"2573","name":"klaipeda"},{"citycode":"1692","name":"vilnius"}],"starttime":"2016-11-05 07:20:34","endtime":"2016-11-05 07:20:34"} i tried extract these using php , inserted mysql db. not work me beginner in coding please solve this below tried $jsondata = file_get_contents($jsonfile); $data = json_decode($jsondata, true); echo $data['name']; echo $data['citycode']; $db->save($data, "tablename"); // found php app insert json db there problems in php code. code $data = json_decode($jsondata, true); indeed convert json data php array. if need extra...

php - Check the manual that corresponds to your MySQL server version for the right syntax: Update does not trasmit the data in the db because of this error -

in error tells error near 'update 'item' set price='120' itemname ='cebu - manila airpla' @ line `2` here php code adds entry database $updateentry1 ="set sql_safe_updates=0; update 'item' set price='120' itemname ='cebu - manila airplane ticket';"; retrievetable($updateentry1); here retrieve table function function stores info in db function retrievetable($query){ $config = parse_ini_file('/config.ini'); $connect = mysqli_connect($config['servername'], $config['username'], $config['password'], $config['database']); $filter_result = mysqli_query($connect, $query)or die (mysqli_error($connect)); return $filter_result;} three aspect firts sure can use 2 sql statemnts in single query sql driver $updateentry1 ="set sql_safe_updates=0; second... price should number , not string and thi...

Python madlib while loop issue -

my attempt @ python switch statement basically. cant loop work. prints same thing each time. choice = input("do want play game? (y) or (n)") while choice == "y": while true: print("1. fun story") print("2. super fun story") print("3. kinda fun story") print("4. awesome fun story") print("5. fun story") choice2 = int(input("which template of madlib play(enter number of choice")) if choice2 == 1: noun1 = input("enter noun: ") plural_noun = input("enter plural noun: ") noun2 = input("enter noun: ") print("be kind {}-footed {}, or duck may somebody’s {}".format(noun1, plural_noun, noun2)) else: print("goodbye") very easy create problems when using "while true". may want end program proper exit condition, few adjustments indentation , break statement solves problem. before, if conditional...

c# - When to use double slash in HtmlAgilityPack SelectNodes -

i want loop through rows in table , select in row. foreach (var r in table.selectnodes("tr")) { var paragraphs = r.selectnodes("//p"); } why have have use selectnodes("//p") , not selectnodes("p")? if later null. i'm wondering why don't "//tr" in foreach statement. as such written //p , in case, find "p" nodes located @ depth within html tree of tr element. if write /p search in root node of html tree of tr element example: with //p find 2 <p> elements, /p not find , null return. <tr> <div> <p></p> </div> <div> <div> <p></p> </div> <div> </tr> in case, if search /p, element found. <tr> <p></p> </tr>

java - Slider Not Updating Label -

im new swing, tried making program creates slider , label. slider moved (form 1 16), label changes. however, label doesn't updated, , instead thread exceptions , other errors when slide slider. here full code: package edu.cuny.brooklyn.cisc3120; import java.awt.*; import javax.swing.*; import javax.swing.event.changeevent; import javax.swing.event.changelistener; import java.awt.event.*; public class gui extends jframe { private static final int limit = 4; private static final int mininteger = 1; private static final int maxinteger = 16; private static jlabel currentguess; private static jslider slider; public gui() { setlayout(new flowlayout()); jslider slider = new jslider(jslider.horizontal, mininteger, maxinteger, 1); add(slider); slider.setmajortickspacing(1); slider.setpaintlabels(true); slider.setpaintticks(true); currentguess = new jlabel("current guess: 1"); a...

c# - connectionString server name not picked up -

as per reference ( modifying connection string variables ), app.config file line of interest: <connectionstrings> <add name="magiqdatabaseentities" connectionstring="metadata=res://*/unpalangimodel.csdl|res://*/unpalangimodel.ssdl|res://*/unpalangimodel.msl;provider=system.data.sqlclient;provider connection string=&quot;data source={0}\{1};initial catalog=magiqdatabase;integrated security=true;multipleactiveresultsets=true;app=entityframework&quot;" providername="system.data.entityclient" /> </connectionstrings> (note {0} , {1} ) i have following in .cs file: string connectionstring = string.format(configurationmanager.connectionstrings["magiqdatabaseentities"].connectionstring, "hppc", "newinstance"); the server hppc\newinstance as per reference ( can't make connection string in c# ), thought backslash problem. have tried double backslash, still can't...

java - Ovewrite CellList "Selected Item" style so It changes It's cell style -

i'm new uibinder , i've created custom cell looks like: .mystyle{ visibility: hidden; } <div> <div class="mystyle">...</div> . . . </div> what i'm trying ovewrite default celllist selected item css when 1 cell selected specific div class become visible. this: @sprite .celllistselecteditem .mystyle{ visibility: visible; } i passed resource celllist's constructor, works fine except says don't recognize ".mystyle" class, , should anotate "@external". if remove ".mystyle" celllist css definition, compiles fine.

How to change error message in ASP.NET Identity -

i have 1 question. i'm trying change error message in identity asp .net , don't know how it. want change error message - "login taken". createasync method return error message. please me. the microsoft.aspnet.identity.usermanager<tuser> class has public property called uservalidator of type iidentityvalidator<tuser> . constructor usermanager sets property instance of microsoft.aspnet.identity.uservalidator<tuser> . error messages see when calling createasync come resources embedded in microsoft.aspnet.identity.dll , added identityresult inside uservalidator. you provide own implementation of iidentityvalidator<tuser> , single method signature: task<identityresult> validateasync(tuser item) . you'd have implement own validations, you'd have control on messages come out. like: public class uservalidator : iidentityvalidator<applicationuser> { public async task<identityresult> validateasync(appli...

Create file through submitting a form -

hey guys i'm trying save file submitted users in php have customers submitting files through form so: <form action="mycontrollerurl"> <input type="file" name="sellerpermit"> </form> inside controller want save these files to: rootdir/media/documents/sellerpermits is there simple way this? if have questions let me know!

multithreading - Multi-thread in Python -

this question has answer here: no schema supplied , other errors using requests.get() 4 answers i'm following book "automate boring tasks python" , i'm trying create progrma downloads multiple comics http://xkcd.com simultaneously, has ran problems. i'm copying exact same program on book. here's code: # multidownloadxkcd.py - downloads xkcd comics using multiple threads. import requests, os ,bs4, threading os.chdir('c:\\users\\patty\\desktop') os.makedirs('xkcd', exist_ok=true) # store comics on ./xkcd def downloadxkcd(startcomic, endcomic): urlnumber in range(startcomic, endcomic): #download page print('downloading page http://xkcd.com/%s...' %(urlnumber)) res = requests.get('http://xkcd.com/%s' % (urlnumber)) res.raise_for_status...

sql - How to select the maximum of each type -

i have table describes how many fish, veg, or meat in each tray. tray | qty | type -------+-----+------- 1 | 5 | fish 2 | 6 | veg 2 | 2 | fish 2 | 5 | meat 3 | 8 | veg 3 | 3 | fish 3 | 9 | meat 4 | 10 | meat lets call table r (it sub table created in query). what want table says tray has highest number of each type this: type | tray -------+------ fish | 1 veg | 3 meat | 4 i tried write following query select type type1, tray (select ... bla bla) r r.qty in (select max(qty) r type = type1); the error r doesn't exist, how solve this? i approach using window functions: select r.type, r.tray (select r.*, row_number() on (partition type order qty desc) seqnum r ) r seqnum = 1;

.net - Can't load assembly I'm executing in -

i have case 2 c# projects need reference each other. assembly references assembly b. , assembly b uses reflection load a. works great in command line application. but in word com addin getting following error: could not load file or assembly 'windwardreports, version=15.0.142.0, culture=neutral, publickeytoken=34ffe15f4bbb8e53' or 1 of dependencies. system cannot find file specified. fusionlog === pre-bind state information === log: displayname = windwardreports, version=15.0.142.0, culture=neutral, publickeytoken=34ffe15f4bbb8e53 (fully-specified) log: appbase = file:///c:/program files (x86)/microsoft office/root/office16/ log: initial privatepath = null calling assembly : (unknown). === log: bind starts in default load context. log: using application configuration file: c:\\program files (x86)\\microsoft office\\root\\office16\\winword.exe.config log: using host configuration file: log: using machine configuration file c:\\windows\\microsoft.net\\framework\\v4.0.3...

objective c - Log Cocoapod dependancies and version in iOS -

i'd log cocoapods , related versions i'm using in project not sure how this. there method available can use write these values log file? i'm using objective-c project can port swift if needed. here's how did this. first, go build phases -> copy bundle resources , add podfile.lock (add other..) then use method return contents of file: -(nsstring *)getpodfilelockcontent { nsstring* podfilelockcontent = nil; nserror* error; nsurl* podfilelockurl = [[nsbundle mainbundle] urlforresource:@"podfile" withextension:@"lock"]; _podfilelockcontent = [[nsstring alloc] initwithcontentsofurl:podfilelockurl encoding:nsutf8stringencoding error:&error]; if (podfilelockcontent) { [nslog(@"error: failed read podfile.lock, make sure have added target in project (this needs done manually @ moment). %@", error]; return nil; } } return podfilelo...

java - How to add a String with a loop -

update 3: solved, thank you update 2: ok close isn't printing tails update dont want use stringbuilder havn't learned concept. cannot figure out wrong , how add 1 r hello trying figure out how assignment asked int user input , generate number of coin flips in string form resulting in pattern of hhththttthhhh etc depending on input user chose. final update solved: public class stringaddition{ public static void main(string[] args) { system.out.println(coinflip(8)); } public static string coinflip(int a){ string r =""; for(int = 0; < a; i++){ int coin = (int) (math.random() * 2); if (coin == 0) { string 1 = "t"; r+=one; } else if (coin == 1){ string 1 = "h"; r +=one; } } return r; } } you have declare empty string outside of loop, , add inside loop. += less efficient stringbuilder, here solution public static string coinflip(int a){ stringbuilder sb = new stringbuilder(); ...

python - convert csv to a string variable -

i beginner in python. need following i have comma separated csv file, eg a,b,c d,e,f g,h,i i need convert string variable eg s='a,b,c\n,d,e,f\n,g,h,i\n' i tried something, going wrong somewhere. import os import csv filename=r"c:\users\das\desktop\a.csv" z=open(filename, 'r') reader=csv.reader(filename.split('\n'),delimiter=',') def csv2str(): row in reader: v=','.join(row) a=csv2str() you don't need csv module that. call read method of file object read in lines 1 string: with open(filename) f: s = f.read() + '\n' # add trailing new line character print(repr(s)) # 'a,b,c\nd,e,f\ng,h,i\n' i'm printing repr of string because print of string i.e. print(a) not show newline character \n , show string in different lines.

html - PHP mail function doesn't complete sending of e-mail -

<?php $name = $_post['name']; $email = $_post['email']; $message = $_post['message']; $from = 'from: yoursite.com'; $to = 'contact@yoursite.com'; $subject = 'customer inquiry'; $body = "from: $name\n e-mail: $email\n message:\n $message"; if ($_post['submit']) { if (mail ($to, $subject, $body, $from)) { echo '<p>your message has been sent!</p>'; } else { echo '<p>something went wrong, go , try again!</p>'; } } ?> i've tried creating simple mail form. form on index.html page, submits separate "thank submission" page, thankyou.php , above php code embedded. code submits perfectly, never sends email. please help. there variety of reasons script appears not sending emails. it's difficult diagnose these things unless there obvious syntax error. without 1 need...

computer science - Neural Network to identify Seven-Segment Numerals -

i studying machine learning , working on first neural network project 1 of classes. programming network in java. point of network identify seven-segmented numeral (like on regular digital clock). network not have linked real sensors, needs work in theory based on inputs 0's , 1's in text form, not binary, correspond hypothetical sensor matrix laid across top of number. my question is, sort of output looking get? will binary output correspond same sort of matrix input or binary output supposed represent input number in binary such returning 111 7? if return matrix, point of network? the input seven-segment numeral (1 x 7) vector, 1 segments on , 0 segments off. as output, don't specify want be, let's assume want tell "which digit screen showing". since there 10 digits (0 through 9), have 10 possible answers. output (1 x 10) vector, each number corresponding 1 of digits. value represents how confident network correct answer (typically outpu...

javascript - Round One Side of D3 Arc -

i'm using d3.js's built-in arc function generate svg <path> s data. .attr("d", function(element, index) { var arc = d3.arc() .innerradius(ir) .outerradius(ir + 10) .startangle(element[1]) .endangle(element[2]) .cornerradius(isrounded ? cr : 0); return arc(); }); this works perfectly, i'd round 1 side (both corners) of arcs. when corner radius supplied .cornerradius() , however, rounds 4 corners. i know there various ways selectively round corners of rectangles , i'm hoping there's generic way arcs. i saw this question rounding corners of arc, has no answer (and d3 v4 has come out since posted). even v4 api, still no straight-forward way this. looking @ source code, cornerradius becomes fixed value calculation of whole arc (all 4 corners). easiest fix append 2 arcs every data point 2nd arc filling in corners. example, have nicely rounded arcs: var myarcs = [ ...

mysql - What is a good way to erase the entire data and load the new data in a service table? -

i new in mysql. i receive full metadata every day. however, not know data added, deleted , updated. i use mysql , size of data 1 million. what way erase entire data , load new data in service table? i think following methods. first option, run delete , insert in transaction. second option, rename table foo foo_old, foo_new foo please advise me how deal it. you can truncate table , import new data afterwards. dont need rename anything. query truncate: truncate table {tablename}; cli import: mysql -u {username} -p {database} < {importfile.sql}

data.table - create data frame based on unique values of two variables in R -

i create new data frame based on 2 unique values data frame. id <- c("a", "b", "b", "c") st.name <- c("tx", "tx", "ca", "ca") type <- c(21, 26, 29, 24) df <- data.frame(id, st.name, type) print(df) id st.name type tx 21 b tx 26 b ca 29 c ca 24 i create new data frame based on unique values of id , st.type. result like: new_id <- c("atx", "aca", "btx", "bca", "ctx", "cca") new_type <- c(21, na, 26, 29, na, 24) df2 <- data.frame(new_id, new_type) print(df2) new_id new_type atx 21 aca na btx 26 bca 29 ctx na cca 24 i have used dcast in previous projects, not sure how incorporate function here. we can complete , unite tidyr library(tidyr) complete(df, id, st.name) %>% unite(new_id, id, st.name, sep ...

python - Django template with 2 'inputs' -

i have simple django view, can (correctly) map coordinates (lat, lng) url, , wish pass them onto template named 'test.html'. right pass latitude along: #views.py ... def testview(request, lat, lng): return render(request, 'polls/test.html', {'lat':lat}) and works fine. my issue how pass longitude (lng) along. have learned how pass solo input official django documentation, can't find mention on how multiple inputs. just include in context dictionary first one: def testview(request, lat, lng): return render(request, 'polls/test.html', {'lat':lat, 'lng': lng}) # ^^^^^^^^^

c++ - Visual Studio wants to load symbols -

so have been using visual studio few years now, when got new computer , installed it keeps wanting things i've never seen need do. all did make regular win32 console app, following code (really didn't add drastic) #include "stdafx.h" #include <iostream> using namespace std; int main() { cin; return 0; } but when went run it, got this 'infpres.exe' (win32): loaded 'c:\users\admin\documents\visual studio 2015\projects\infpres\debug\infpres.exe'. symbols loaded. 'infpres.exe' (win32): loaded 'c:\windows\syswow64\ntdll.dll'. cannot find or open pdb file. 'infpres.exe' (win32): loaded 'c:\windows\syswow64\kernel32.dll'. cannot find or open pdb file. 'infpres.exe' (win32): unloaded 'c:\windows\syswow64\kernel32.dll' 'infpres.exe' (win32): loaded 'c:\windows\syswow64\kernel32.dll'. cannot find or open pdb file. 'infpres.exe' (win32): loaded 'c:\windows\syswow...

R-programming issue with ImageMagick -

i trying create animation using r , imagemagicks. here simple code plots 5 different values of x,y , z on 3dscatterplot. simulator=function() { library(scatterplot3d) for(i in 1:5) { png(paste(i,'plot.png',sep='')) scatterplot3d(i*10,i*10,i*10, main="quadcopter simulator", xlab = "x-axis", ylab = "y-axis", zlab = "z-axis", xlim=c(0,100), ylim=c(0,100), zlim=c(0,100), box=false) dev.off() } } after 5 .png images in working directory. then have manually open command prompt , type these commands: 1) cd c:/users/.... (location .png's are) 2)convert *.png -delay 1000 -loop 0 animation.gif this works , creates .gif of .png @ same location. when try same including in r script adding end: system('c:\program files\imagemagick-7.0.3-q16\convert.exe" -delay 80 *.png exa...

matlab - <ask> how to fix reshape error -

btw have sample code : [img_rgb, clrmap] = imread ('e:\foto\c360_2015-02-02-14-15-52-544.jpg'); [rows,columns,numclrchannels] = size(img_rgb); img_hsv = rgb2hsv(img_rgb); h_img=img_hsv(:,:,1); s_img=img_hsv(:,:,2); v_img=img_hsv(:,:,3); nsteps = 3; [center,u,obj_fcn]=fcm(h_img,nsteps); [~,cluster_idx] = max(u); subplot(1,2,1); imshow (img_hsv); subplot(1,2,2); imshow (v_mask,[]); pixel_labels = reshape(cluster_idx,rows,columns); imshow(cluster_idx,[]), title('image labeled cluster index'); i want label every cluster created on hsv image processed fcm function. but problem have error on displaying output of pixel_label saying : error using reshape reshape number of elements must not change. is there other way display hsv output image after hsv image has been processed fcm function properly? how fix error? thx before.

syntax - c++ - iterating through a map of 3 elements -

i'm new use of stl containers in c++. i have map of 3 elements (2 strings pair - acting key, , int acting value.) map<pair<string, string>, int> wordpairs; but when try iterate through this: (map<pair<string, string>, int> iterator = wordpairs.begin(); != wordpairs.end(); i++) { cout << i->first << " " << i->second << "\n"; } the compiler throwing errors: error: expected ‘;’ before ‘i’ (map<pair<string, string>, int> iterator = wordpairs.begin(); != wordpairs. ^ error: name lookup of ‘i’ changed iso ‘for’ scoping [-fpermissive] a7a.cpp:46:50: note: (if use ‘-fpermissive’ g++ accept code) error: cannot convert ‘std::map<std::pair<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >, int>::iterator {aka std::_rb_tree_iterator<std::pair<const std::p...

php - Laravel 5.2 to be logged in as a master account and an admin -

i have super admin , store admins login. had achieved entrust package. now, in super admin side, under listings of store admins, want provide button go dashboard (i.e. super admin can view, login store admin dashboard click condition super admin login (session) must remain , new tab opened store admin dashboard. i got laravel function \auth::loginusingid($store_admin_id); but close current session of super admin , admin loggedin. want maintain both sessions. on searching found 1 package olieread/multiauth , need exact solution laravel 4.2 version. i have session settings default. of i'm not using memcache or redis. if using of them can me? any suggestion appreciated. thanks

tkinter Text editor lines counter -

Image
*i not @ english. please understand awkward english. hello! i making text editor. but, want more perfect... so want making text line counter. look: what can use feature? class main: def __init__(self,master): (skip) self.__class__.editors.append(self) self.linenumbers = '' self.frame = frame(master, bd=2, relief=sunken) self.lntext = text(self.frame, width = 4, padx = 4, highlightthickness = 0, takefocus = 0, bd = 0, background = 'lightgrey', foreground = 'magenta', state='disabled' ) self.lntext.pack(side=left, fill='y') if self.__class__.updateid none: self.updatealllinenumbers() def getlinenumbers(self): x = 0 line = '0' col= '' ln = '' # assume each line @ least 6 pixels high step = 6 nl = '\n' linemask = ' ...