Posts

Showing posts from September, 2010

python - How to handle variable sized input in CNN with Keras? -

i trying perform usual classification on mnist database randomly cropped digits. images cropped following way : removed randomly first/last and/or row/column. i use convolutional neural network using keras (and tensorflow backend) perform convolution , usual classification. inputs of variable size , can't manage work. here how cropped digits import numpy np keras.utils import to_categorical sklearn.datasets import load_digits digits = load_digits() x = digits.images x = np.expand_dims(x, axis=3) x_crop = list() index in range(len(x)): x_crop.append(x[index, np.random.randint(0,2):np.random.randint(7,9), np.random.randint(0,2):np.random.randint(7,9), :]) x_crop = np.array(x_crop) y = to_categorical(digits.target) sklearn.model_selection import train_test_split x_train, x_test, y_train, y_test = train_test_split(x_crop, y, train_size=0.8, test_size=0.2) and here architecture of model want use from keras.layers import dense, dropout keras.layers.convolutiona

git workflow - Replace all existing files in git repository with a different remote branch except the ones in .gitignore -

i have several repositories have merge 1 core repository into. core repository setup remote repository in every repository. generally, workflow update repositories goes this: git reset --hard origin/master git pull origin master git fetch core master i git merge --squash core/master , fix conflicts before pushing repository remote . this fine, except little redundant because aside in .gitignore file each repository, in these repositories should technically same core repository. as number of repositories expand, i'm wondering more efficient way of pulling core branch these repositories given need replace existing files except ones mentioned in .gitignore every 1 of them while maintaining integrity in git history , logs. you can combination of git , bash. i've written sample script show how can done. can modify , make better. i've provided explanation also. file called adder.sh . #!/bin/bash # $1 -> files branch want (core) # $2 -> branc

How to Split strings with fgets or fscanf in C? -

i understand how read in text file , scan/print entire file, how can line split several strings? also, can variables assigned strings called later? code far: #include <stdio.h> #include <stdlib.h> #include <string.h> int main() { file *fpointer; fpointer = fopen("p1customer.txt", "r"); char singleline[150]; int id; while (!feof(fpointer)){ fscanf(fpointer, "%d", &id); printf("%d",id); } fclose(fpointer); return 0; } example text file read: 99999 john doe basketball example output: john doe has id number 99999 , plays basketball i attempting split/tokenize strings , assign them variables (idnumber, name, sport) , print output in new file. you can use library function strtok(str,chrs) function. sequence of calls of strtok(str,chrs) splits str tokens, each delimited character chrs . the first call in sequence non null str .it finds first token in

javascript - What is the best approach to bring a Scroll Pagination in jQuery to React? -

i on react http://jsfiddle.net/dlcwc/1/ should use plain javascript or create component, etc? i confused on how incorporate react thing likes: $(document).ready(function() { resizediv(); //scrolltocurrent(); }); $(window).scroll(function(event) { ... the on document ready, guess fit on componentdidmount(). but scroll event big incognita me. any guide or tutorial know terrific. thnks

azure - EventHub Trigger to Functions cardinality with one causing higher timeouts -

when select many "cardinality" in function bindings, works fine. { "bindings": [ { "type": "eventhubtrigger", "name": "eventhubmessages", "direction": "in", "path": "sessions", "connection": "connectionstring", "cardinality": "many", "consumergroup": "group1" } ], "disabled": false } when select "one" in function bindings, getting higher timeouts. "cardinality": "one", when @ console, see there multiple functions started, 2017-09-12t19:37:49.645 function started (id=f0ef1cd5-8331-448e-86c6-84c745bbab13) 2017-09-12t19:37:49.956 function started (id=26629395-54b8-4f83-9852-b3d55307318b) is cardinality "many" single threaded, , "one" getting processed parallely. while have no problem parallel proces

angularjs - ngMap javascript maps v3 : Prevent map from panning outside world edges -

my problem pretty simple. how avoid user panning outside world edges (both east , west, north , south). in android, happens automatically. in javascript, able pan outisde world edge. east / west, shows repetitive map. north / south, shows grey area. reproducing problem https://developers.google.com/maps/documentation/javascript/adding-a-google-map https://ngmap.github.io/ on these sites, if zoom out example maps maximum , try panning beyond eadge, displays grey area. what want https://maps.google.com/ here cannot pan out beyond edge what have read i have tried searching through number of questions : can prevent panning leaflet map out of world's edge? : not using leaflet. don't know is. how limit panning in google maps api v3? : feel problem should have simpler solution. please help. edit please note looking ngmap related solution

javascript - THREE.js custom vr/cardboard effect -

Image
i'm trying create custom vr panorama viewer using three.js. i've managed create: 2 scenes, 2 materials , meshes (different images loaded left , right eye), renderer scissors (2 perspective cameras). the result looks this: everything looks fine me add kind of "black vr cardboard frame" both cameras. i'm not quiet sure how effect called, here example: can please give me tips? that word looking "barrel distortion" . can see working implementation of in webvr-polyfill here . depending on how understand raw webgl might bit difficult read though. so here basic steps of versatile approach using 2 render-passes: that split-image have rendered framebuffer ( see here example) instead of rendering screen. framebuffer used texture in second renderpass. setup scene , camera second renderpass. camera should orthographic camera ranging -1 1 on x-axis (something like this ). setup 2 meshes (based on planebuffergeometry ) 2 viewports ,

firebase - android TextWatcher with ListView refresh everytime -

i'm trying highlight row in listview every time changes realtime database (firebase). works semi correctly, because when change on position "1" highlight correct, next change e.g. position "2", , both positsions (1 , 2) highlighted, etc. rather comparing (current object field charsequences) in if statement incorrect, think so, have no idea how properly. public view getview(final int position, view convertview, final viewgroup parent) { ... ... public void ontextchanged(charsequence s, int start, int before, int count) { if ((user.name.equals(s.tostring())) == false) { finalconvertview.setbackgroundcolor(color.green); new countdowntimer(500, 100) { public void ontick(long millisuntilfinished) { } public void onfinish() { finalconvertview.setbackgroundcolor(color.white); } }.start();

Programmatically click on button camera Android -

i need program click on android camera button on tablet, code, , works fine, need done program; thank much. private void sacofotoingresolocal() { intent takepictureintent = new intent(mediastore.action_image_capture); // ensure there's camera activity handle intent if (takepictureintent.resolveactivity(getpackagemanager()) != null) { // create file photo should go file photofile = null; try { photofile = createimagefile(); } catch (ioexception ex) { // error occurred while creating file } // continue if file created if (photofile != null) { uri photouri = fileprovider.geturiforfile(this,"com.example.android.fileprovider", photofile); takepictureintent.putextra(mediastore.extra_output, photouri); startactivityforresult(takepictureintent, requerimeinto_tomar_foto); } } } there no "camera button" on devices,

c# - Unable to get the entire Image in web Api while doing Post from the MVC controller? -

actually, sending image memory stream mvc controller web api memorystream, while downloading image in web api, getting half image instead of full image. please find sample output image in link my mvc controller: public actionresult index(formcollection formcollection) { foreach (string item in request.files) { httppostedfilebase file = request.files[item] httppostedfilebase; if (file.contentlength == 0) continue; if (file.contentlength > 0) { memorystream ms = new memorystream(); file.inputstream.copyto(ms); ms.position = 0; httpclient client = new httpclient(); client.baseaddress = new uri("http://localhost:35221"); client.defaultrequestheaders.accept.add(new system.net.http.headers.mediatypewithqualityheadervalue("application/octent-stream")); httpcontent

modx - How to create ContentBlock with multiple text inputs? -

Image
i'm using contentblocks modmore , , trying figure out how create new content block has input allows user enter title , source url. goal expose these fields can edited resource, in following image, second text field being red square indicator is. this has been bugging me while, appreciate if can this. first of all, can support contentblocks , other modmore extras via helpdesk (support@modmore.com) or our own forum ( https://forum.modmore.com ). don't monitor stackoverflow, luckily received alert question. there's couple of options you're trying do. 1) add field setting "iframe" field. can contentblocks component under extras > contentblocks. right click field update it, , on settings tab, add text setting key/name of choice. go templates tab, , use [[+placeholder]] syntax insert value template. depending on "expose field" option choose, field can show in modal window available when clicking settings icon on field, or directl

python - Get column data based on foreign key and manytomanyfield in django admin -

i new in django. have following models. category id category_name 1 2 b module (category_id foreignkey) id module_name category_id 1 x 1 2 y 2 category_user (user_id manytomanyfield category_id) id category_id user_id 1 1 23 2 2 23 so want display data x & y module in admin category edit page if category id 1 & 2 assigned user 23 . admin.py class categoryadmin(admin.modeladmin): list_display = ('category_name','category_desc') filter_horizontal = ('user',) readonly_fields = ('allowed_module_names',) def allowed_module_names(self, instance): modules = [] module_names = instance.category.values_list("module_name") print(module_names) the query returns blank. any highly appreciated. in advance.

python - pip install package - failed with error code 1/2 -

i'm having issues installing pygrib using pip . tried installing pygrib using easy_install , , similar error. using pip error: command "c:\users\brandon\appdata\local\enthought\canopy\edm\envs\user\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\brandon\\appdata\\local\\temp\\pip-build-veulay9n\\pygrib\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record c:\users\brandon\appdata\local\temp\pip-ff_s5247-record\install-record.txt --single-version-externally-managed --compile" failed error code 1 in c:\users\brandon\appdata\local\temp\pip-build-veulay9n\pygrib\ using easy_install error: c:\users\brandon\appdata\local\enthought\canopy\edm\envs\user\lib\site-packages\numpy\core\include\numpy\npy_1_7_deprecated_api.h(12) : warning msg: using deprecated numpy api, disable #defining npy_no_depr

c# - Fix DataGridView scroll blitting / jerkyness -

Image
in windows forms, created custom row headers datagridview draws faces of game characters. however, noticed when scrolling datagridview , windows seems blit existing rows on not-yet-drawn ones, creating noticeable , annoying jerkiness. this how looks artificially slowed down when scrolling , down (it fast in reality, jerkiness still noticable - gif has been slowed down show mean blitting): this seems happen default datagridviewrowheadercell , other cells ( which didn't supply custom drawing code, notice numbers not updating aswell in gif above ), not noticable due them not having images / faces (quickly recognizable human) , alternating row colors. so looks datagridview has these problems in general, become perceivable images. there way prevent datagridview blitting contents or windows causing it, chances low prevent doing so? the drawing double buffered. tried wm_setredraw , didn't find fitting "prescroll" , "postscroll" events try use it.

language concepts - What's the point behind passing functions as arguments to other functions? -

it's rather general purpose question , not specific 1 language. don't quite understand point behind passing function argument function. understand if function, say, foo1() needs use result returned function foo2() , why can't values returned/updated foo2() passed foo1() is? or in scenario, why can't foo2() called within foo1() results being used therein? happens under hood when foo2() passed argument foo1() ? foo2() executed prior foo1() ? generally speaking, pass function foo2 function foo1 in cases multiple evaluations of foo2 necessary - , perhaps don't know in advance parameters used each call of foo2 , couldn't possibly perform calls in advance. i think sort() function/method on lists might best concrete example. consider list of people - might reasonably want sort them alphabetically name, or numerically age, or geographical distance given point, or many other possible orders. hardly practical include every such ordering built-

c# - Impersonating to X509Store.Add to StoreName.Root - The Request Is Not Supported -

i cannot find related error encountering. the problem encountering cryptographicexception on store.add below: "the request not supported." the msdn documentation not helpful, states that: the certificate not added store. i used following code guide, following change: they adding storename.my , i want add storename.root i want use idisposable class impersonate user. my proof of concept code (abridged/shoddy): public class userlogonimpersonator : idisposable { private windowsimpersonationcontext _impersonationcontext = null; private const int logon_interactive = 2; private const int provider_default = 0; [dllimport("advapi32.dll", setlasterror=true)] private static extern int logonuser( string lpszusername, string lpszdomain, string lpszpassword, int dwlogontype, int dwlogonprovider, ref intptr phtoken); public userlogonimpersonator() { _imperson

java - where to place suggested code -

i newbie spring. have spring project want run code after finishes startup. there sol'n offered here: suggested solution specifically, try: @eventlistener(applicationreadyevent.class) public void dosomethingafterstartup() { system.out.println("hello world, have started up"); } my question in project put code? (there bunch of code files in various directories)

mysql - Sending data taking too long but indexes aready create -

i having problems query taking 20 seconds return results :( in table cases , cases_cstm, have 960,000 rows this query: select cases.id ,cases_cstm.assunto_c, cases.name , cases.case_number , cases.priority , accounts.name account_name , accounts.assigned_user_id account_name_owner , 'accounts' account_name_mod, cases.account_id , ltrim(rtrim(concat(ifnull(jt1.first_name,''),' ',ifnull(jt1.last_name,'')))) assigned_user_name , jt1.created_by assigned_user_name_owner , 'users' assigned_user_name_mod, cases.status , cases.date_entered , cases.assigned_user_id cases left join cases_cstm on cases.id = cases_cstm.id_c left join accounts accounts on cases.account_id=accounts.id , accounts.deleted=0 , accounts.deleted=0 left join users jt1 on cases.assigned_user_id=jt1.id , jt1.deleted=0 , jt1.deleted=0 (((ltrim(rtrim(concat(ifn

ASP.NET Core RESTfull API hosting - 500 internal server error -

according topic i'm trying publish , host .net core application. getting 500 internal server error when try retrieve data using request api ( example.com/pets/users ). example.com/pets url api published. my webconfig looks this: <?xml version="1.0" encoding="utf-8"?> <configuration> <system.webserver> <handlers> <add name="aspnetcore" path="*" verb="*" modules="aspnetcoremodule" resourcetype="unspecified" /> </handlers> <aspnetcore processpath="dotnet" arguments=".\pets.api.dll" stdoutlogenabled="true" stdoutlogfile=".\logs\stdout" /> </system.webserver> </configuration> which believe pretty ok. stdout log says this: warn: microsoft.extensions.dependencyinjection.dataprotectionservices[59] neither user profile nor hklm registry available. using ephemeral key repository. pr

scope - Searching local javascript variables by name patterns -

in javascript, local variables not live on object i'm aware of. is, function foo() { const x = 2; self.x; // undefined this.x; // undefined window.x; // undefined x; // 2, eval('x'); // 2 } the last option eval('x') shows possible refer these variables name. i'm looking extend , access variable using name pattern : function foo() { // code not under direct control function foobar_abc() {} function other_functions() {} // code under control const matchingfunction = // find function name matching 'foobar_*' } if lived on object, use myobject[object.keys(myobject).find((key) => key.startswith('foobar_'))] . if in global scope, myobject window , works. the fact eval able access variable name implies value available somewhere. there way find variable? or must resort techniques re-write (potentially complex) code not under direct control? i'm targeting modern browsers, , in use ca

spring - can I pass Predicate from querydsl to server? -

i reading tutorial here spring , thought querydsl interesting if can passed client. way client has total control on how filter data , there 1 generic method(filter) needed same dataset. i see predicate 's parent extends expression extends serializable , seems can serialize predicate , got stackoverflow exception when trying jackson . found has stringvalue() method can't find way have predicate read it. is possible have client decide how construct predicate object?

javascript - How can I clear my MongoDB collection between Mocha tests? Collection.remove({}) isn't working. . . -

this question has answer here: async function in mocha before() alway finished before it() spec? 1 answer how can clear mongodb collection between mocha tests? collection.remove({}) isn't working. . . . does see doing wrong? i've tried user.remove({}) syntax, well, no avail. also, if have moment, seem reasonable way write test? i'm admittedly new testing. const user = require('../../../app/models/user'); const config = require('../../../config/config'); const mongoose = require('mongoose'); const chai = require('chai'); const chaiaspromise = require('chai-as-promised'); const sinon = require('sinon'); const expect = chai.expect; chai.use(chaiaspromise); mongoose.connect(config.database, { usemongoclient: true }); mongoose.promise = global.promise; describe('the user model', () => { des

ios - UILabel doesn't fulfill numberOfLines -

i have address label can 2 or 3 lines depending on user's address: 123 street apt 5b mycity, mystate 12345 or 123 street mycity, mystate 12345 i make simple uilabel: let label_addr = uilabel() label_addr.numberoflines = 3 i expect 3 lines tall, in second case. however, trims down 2 lines if don't use filler "\n". there way make respect numberoflines property?

c++ - Generate random numbers using C++11 random library -

as title suggests, trying figure out way of generating random numbers using new c++11 <random> library. have tried code: std::default_random_engine generator; std::uniform_real_distribution<double> uniform_distance(1, 10.001); the problem code have every time compile , run it, generates same numbers. question other functions in random library can accomplish while being random? for particular use case, trying range within [1, 10] stephan t. lavavej (stl) microsoft did talk @ going native how use new c++11 random functions , why not use rand() . in it, included slide solves question. i've copied code slide below. you can see full talk here: http://channel9.msdn.com/events/goingnative/2013/rand-considered-harmful #include <random> #include <iostream> int main() { std::random_device rd; std::mt19937 mt(rd()); std::uniform_real_distribution<double> dist(1.0, 10.0); (int i=0; i<16; ++i) std::cout <<

java - Why put the main thread to sleep before cancelling a timer task? -

in this example author puts main thread running timer task sleep before cancelling timer task this: system.out.println("timertask started"); //cancel after sometime try { thread.sleep(120000); } catch (interruptedexception e) { e.printstacktrace(); } timer.cancel(); system.out.println("timertask cancelled"); try { thread.sleep(30000); } catch (interruptedexception e) { e.printstacktrace(); } } after cancelling author puts sleep 30 seconds. curious why done? show timer still run though main thread sleeping , additional 30 seconds added allow timer chance cancel itself? there way tell timer cancel after 120 seconds without putting main thread sleep? follow up great answer - follow question make sure understand correctly- if thread non daemon , cancel first task after 2 minutes using timer schedule task showed, stop main thread (as tasks scheduled cancelled)? the code demon

subdirectory - Unix deleting subfolders with names in YYYYMMDD that are older than 30 days -

i'm looking simple line of code (if possible) delete subfolders names in yyyymmdd older 30 days. have searched related solutions online , came this. i'm sure there's i'm missing here because when submitted this, no subfolders older 30 days deleted , not getting errors either. find /my/directory -type d -name '[0-9]{8}' -mtime +30 -exec rm -rf {} \; use -regex flag in find. find /my/directory -type d -regex "[0-9]{8}" -mtime +30 -exec rm -rf {} \;

Display text content of an active element in jQuery slot machine -

i'm using jquery-slotmachine , randomizer. here html: <div id="machine1"> <span class="option"> <span>example a</span> <span>example b</span> </span> </div> <div id="machine2"> <span class="option"> <span>example c</span> <span>example d</span> </span> </div> <div id="results"> <span></span> </div> here js: var machine1 = $("#machine1").slotmachine({ active : 0, delay : 500 }); var machine2 = $("#machine2").slotmachine({ active : 1, delay : 500, direction: 'down' }); function oncomplete(active){ switch(this.element[0].id){ case 'machine1': $("#machine1result").text(this.active); break; case 'machine2': $("#machine

Autogenerating Angular 2 template (with angular directives) -

i want write component autogenerates it's own template. template not plain html has angular tags such ngif , etc. has buttons references (predefined) click handler methods. i can plain html template autogeneration work using @viewchild ngif getting ignored. (click) handler ref getting ignored. anyone know how working? thanks! import {component, viewchild, elementref, afterviewinit} '@angular/core'; @component({ selector: 'app-root', template: ` <div #formcontainer></div>`, styleurls: ['./app.component.css'] }) export class appcomponent implements afterviewinit { title = 'app'; shouldshowlastname : boolean = false; @viewchild('formcontainer') formcontainer: elementref; ngafterviewinit(): void { let formhtml = `<div id="anchor"> first name: <input type="text" name="firstname" value="mickey">

facebook java ads sdk how to retrieve "delivery, results,result_rate,cost_per_result", and breakdown by day -

i'm trying use facebook's java sdk generate ads report. followed sample code, using new adaccount(ad_account_id, context).getinsights() retrieve data. java sdk retrieve partially data. i'm not sure i'm using correct api. import com.facebook.ads.sdk.*; import java.util.arraylist; import java.util.list; import config.fbreporting.gettyimages.com.config; public class sample_code { public static void main(string args[]) throws apiexception { string access_token = config.access_token; string ad_account_id = config.ad_account_id; string app_secret = config.app_secret; apicontext context = new apicontext(access_token).enabledebug(true); list<adsinsights.enumbreakdowns> breakdowns = new arraylist<>(); list<adsinsights.enumsummary> summaries = new arraylist<>(); apinodelist<adsinsights> adsinsights = new adaccount(ad_account_id,

asp.net - IIS (There was an error while performing this operation) -

Image
i receive (there error while performing operation) error referring web.config. follow below configuration: os windows server 2012 r2 iis version 8.5. url rewrite 2.1 module installed on machine. iis_iusrs has full access directory. application initialization module installed .net clr version v4.0.30319 , managed pipeline mode integrated. iis configuration below: web config below: <?xml version="1.0" encoding="utf-8"?> <configuration> <system.webserver> <handlers> <add name="aspnetcore" path="*" verb="*" modules="aspnetcoremodule" resourcetype="unspecified" /> </handlers> <aspnetcore processpath="dotnet" arguments=".\mes.dll" stdoutlogenabled="false" stdoutlogfile=".\logs\stdout" /> </system.webserver> </configuration> &l

python - Convert Kinesis Base64 String to protobuf/JSON -

i pulling data off amazon kinesis stream using python, , data records come off base64 encoded strings. data being put on stream protobuf files, need convert these base64 strings text readable protobuf file or else usable json. when decode base64 string, 'bytes' object, throws error if try use .decode('utf-8') . how can convert bytes object usable? note if use protoc --decode_raw command line tool can original protobuf message, don't see way in python script

php - Hostbuddy SMTP mail test, having troubles, could not connect to SMTP host -

i new php , im trying set postmaster, using hostbuddy hosting site , downloaded smtp information server. i got these files them automatically uploaded server testing smtp: class.phpmailer.php class.smtp.php index.php web.config i think entering correct information test. keep getting callback says, "could not connect smtp server". here index.php guys can see going on. <center><h2>php test email script</h2></center> <?php // display form if user has not clicked submit if (!isset($_post["submit"])) { ?> <form method="post" action="<?php echo $_server["php_self"];?>" target="_blank"> <table align = center> <tr><td>from email: <td><input type="text" name="uname"> i.e yourname@yourdomain.com</tr> <tr><td>email password: <td><input type="password" name="pass"></tr>

How to add annyang in Angular 4 using webpack -

i have same problem described in this post . case bit different because i'm using webpack, instead of system.js. project angular 4 , created lastest version of angular cli. how can map resource webpack?

php - Symfony validation -

i'm working in bundle user creates "comision" using form, , i'm trying check user still have "credit". created custom validator thas queries past comisions ant throw error if credit not enough my problem if user submits date wrong format in "date" field (i.e. 32-13-20122 24:05) symfony still tries run custom validation , sort of errors (because $comision->getdate() null , not valid datetime object) i'm getting error: clone method called on non-object i can check if value of $comision->getdate() valid datetime in custom validator, seems me should not necessary since added rules in date property. this entity (simplified) /** * @myvalidation\totalhours() */ class comision { /** * @orm\column(type="datetime") * @assert\datetime() * @assert\notnull() */ protected $date; /** * @orm\column(type="decimal", nullable=false, scale=1) * @assert\notblank() */ protected $hours; ... my form class ... cl

python - Data is saved including blank -

Image
i wanna parse excel , put model(city&prefecture&area&user) . wrote fourrows_transpose=list(map(list, zip(*fourrows))) val3 = sheet3.cell_value(rowx=0, colx=9) user3 = companyransaction.objects.filter(corporation_id=val3).first() if user3: area = area.objects.filter(name="america").first() pref = prefecture.objects.create(name="prefecture", area=area) city = city.objects.create(name="city", prefecture=pref) price= price.objects.create(city=city) pref.name = fourrows_transpose[0][0] pref.save() transpose in fourrows_transpose[2:]: if len(transpose) == 5: if "×" in transpose or "○" in transpose: city.name = transpose[1] city.save() price.upper1000 = transpose[2] price.from500to1000 = transpose[3] price.under500 = transpose[4]

javascript - simple form validation not working -

trying loop through fields, , have errors written above form, autofocus, , background color changed red ... form doesn't work. why? bonus points: appreciate if explain how name fields individually in errormessages ... code: <html> <head> <meta charset="utf-8" /> <title></title> <script> function validateme(){ document.getelementbyid("button1").addeventlistener("click",validateform); function validateform(){ //alert("wheeeeee!"); var formy = document.getelementbyid("testy"); (var = 0; < formy.length; i++) { if (formy[i].value == "") { document.getelementbyid("errormessages").innerhtml = "please don't leave blank" document.form[&quo

ios - How NEHotspotHelper choose the helper? -

in apple's document hotspot, means system choose 1 app hotspot helper. ( https://developer.apple.com/library/content/documentation/networkinginternet/conceptual/hotspot_network_subsystem_guide/contents/introduction.html#//apple_ref/doc/uid/tp40016639 ) are there rule whitch app choosen ? there 2 apps named qqdoctor , myapp in device. 1 wifi ap, many times qqdoctor choosen, not myapp. has high possibility qqdoctor choosen. qqdoctor(15 times choosen), myapp(5 times choosen). (in concept,it may has same possibility whitch app choosen, not!) this code: -(void)registerhotspot{ nsinteger s_count = 0; if ([[[uidevice currentdevice] systemversion] floatvalue] >= 9.0f) { nsdictionary * option = nil; if ([sgvconfig shareinstance].hotspotdisplayname) { option = @{knehotspothelperoptiondisplayname: [sgvconfig shareinstance].hotspotdisplayname}; } // dispatch_queue_t queue = dispatch_get_global_queue(dispatch_queue_priority_high, 0); di

c# - get the id of selected item from html5 input list -

how can id of selected item input list. can fetch item can not fetch id of selected item. <div class="form-row"> <label> <span>&nbsp;selected items</span> <input list="username" runat="server" id="usernameinput" class="form-control input_list" placeholder="faculty" required="required" /> <datalist id="username" runat="server"></datalist> </label> </div> <div class="form-row"> <label> <span>&nbsp;&nbsp;selected html5 input</span> <input type="text" id="input_selected" runat="server" /> </label> </div> <div class="form-row"> <asp:button id="btnsubmit" runat="server" text="submit" onclick="btnsubmit_click" /> </div>

node.js - How to call node module in express rendered view? -

i'm having difficult time trying understand how pass called data view. i'm requiring mozscape node module in little application i'm trying develop don't quite understand how i'm pass information view. imagine need create object in router , call function in view. mozscapes returns object pass view , use handlebars iterate through data? here's code router below //pull in express const express = require('express'); //declare router variable index view const index = express.router(); //mozscape seo data var mozscape = require('mozscape').mozscape; //mozscape expects accessid , secretid //only allows 1 call per 10 seconds free plan //need add env file later var moz = new mozscape('mozscape-6d6ab44235', '846aca62a6db69661c81b784115e8a9'); //dummy data var business = { name: 'party corner', address: '123 main street, red bank, nj', hours: 'monday through friday

rest - JSONpath to access a JSON array element by values in multiple sibling array elements -

i have service returns json 2 dimensional list. need find value in second dimension based of values of 2 of elements siblings. a sublisting of json response looks this: { "rows" : [ ["15053518617", "myitemname", "callactivityactivated", "4", "354687456539856756757577547674562234", "callactivity", "2010913-e8345ac7-6c54-4835-933b-3f7ddd2dd777", "b0012345-2017-01-13", "activated", "", "\"null\"" ], ...more rows... ] } i need access element 7 in array element. but, don't know order in these rows returned. need jsonpath syntax can use in soapui property transfer identify row combination of 2 other elements in row. i can access row hard-coded values in particular response with: $.rows.[0].[7] this returns: b0012345-2017-01-13 because can't depend on rows being in same order (unlike first dimens

python - Pandas dataframe replace with regex doesn't work -

i have dataframe many rows. want use pd.replace replace values in entire columns. import pandas pd import re list = ['md 15241', 'md', 'td', 'td 15487'] = pd.dataframe(list) b = a.copy() b.replace(r'[a-z]{2}', 'usa', inplace = true) b output 0 0 md 15241 1 md 2 td 3 td 15487 i tried r'md' or r'td' , works. you need regex=true in replace method: b.replace(r'[a-z]{2}', 'usa', inplace=true, regex=true) b #0 #0 usa 15241 #1 usa #2 usa #3 usa 15487

ocaml - requiring "core" in utop gives error: Unix.Unix_error (Unix.ENOENT, "sysconf", "") -

when try call #require "core" in utop , error: utop # #require "core";; exception: unix.unix_error (unix.enoent, "sysconf", ""). raised primitive operation @ unknown location called file "toplevel/topdirs.ml", line 144, characters 10-51 i have .ocamlinit file looks in current directory: (* added opam. *) let () = try topdirs.dir_directory (sys.getenv "ocaml_toplevel_path") not_found -> () ;; #use "topfind";; #thread;; #camlp4o;; what causing error happen? appears error findlib? i tried wiping away ~/.opam directory, rerunning opam init , opam switch set 4.05.0 , , reinstalling core , utop , error persists. possible need reinstall opam itself? using binary version of opam-1.2.2. i'm running arch linux, , believe error started occuring after updating packages on system, not sure. i still able use jbuilder build executables, when running executables, fail similar error: $ _build/

How to get docker applications to send logs to openshift's built in log aggregator? -

i setting openshift cluster , trying aggregate logs using built in efk stack openshift builds when start cluster with: oc cluster --logging=true however, add other projects , docker images nodes, not quite sure how funnel application logs created logging project. how logs report created efk cluster?

Download and execute executable app automatically using flask/python framework -

i working on task of application runs web can automatically download executable application , place on external media specified volume label. how should start regarding using flask/python framework. web browsers not let choose executable gets downloaded. create security problems. unless, mobile progressive webapp, in case there might possibility can ask permissions download app in specific location, otherwise, not allowed. what can do. you can perform normal download, , user move executable external media. can done inserting following javascript: let = document.createelement("a"); a.href = exe_data; a.download = 'some_name.exe' document.body.appendchild(a) a.click(); window.url.revokeobjecturl(a.href); a.remove()

javascript - es6 implement polymorphism with extend -

look code below. a extend b , let b call sub-class's function implement polymorphism. if want add parameter b ,since super() must call before use this.param = param ,so can not via way pass parame b 's polymorphism() . how make b 's polymorphism() use custom param pass via b 's constructor? there way make b 's constructor can add parameter use custom business? class a{ constructor() { this.polymorphism(); } polymorphism(){ console.log("a") } } class b extends a{ constructor(param) { super(); } polymorphism() { console.log("b") /**use param * business code**/ } } new b()

objective c - Button Action addTarget call another class method with singleton shareInstance, and send with dynamic parameter -

i want design user story when user click uibutton "choose fruit" on class call choosefruit method on class b different parameter, such banana, apple, orange. requirement, search internet found out use shareinstance (singleton pattern) can achieve call class method. people shareinstance not recommend send parameter. ( https://stackoverflow.com/a/28652715/8305553 ) but every time button clicked, must send different fruit method. here code, believe way not best practice. can provide better way to approach user story? choosefruitviewcontroller.m: @implementation choosefruitviewcontroller { nsstring *fruit; } uibutton *choosefruit = [[uibutton alloc] initwithframe:cgrectmake(20, 200, 150, 40)]; [choosefruit settitle:@"choose fruit" forstate: uicontrolstatenormal]; [choosefruit setbackgroundcolor: [uicolor bluecolor]]; choosefruitclass *choosefruitclasstest = [choosefruitclass sharedinstance]; fruit = @"banana"; [choosefruitclasstest setfruit:frui