Posts

Showing posts from January, 2013

python - Creating a heatmap by sampling and bucketing from a 3D array -

i have experimental data exists so: x = array([1, 1.12, 1.109, 2.1, 3, 4.104, 3.1, ...]) y = array([-9, -0.1, -9.2, -8.7, -5, -4, -8.75, ...]) z = array([10, 4, 1, 4, 5, 0, 1, ...]) if it's convenient, can assume data exists 3d array or pandas dataframe : df = pd.dataframe({'x': x, 'y': y, 'z': z}) the interpretation being, every position x[i], y[i] , value of variable z[i] . these not evenly sampled , there parts "densely sampled" (e.g. between 1 , 1.2 in x ) , others sparse (e.g. between 2 , 3 in x ). because of this, can't chuck these pcolormesh or contourf . what instead resample x , y evenly @ fixed interval , aggregate values of z . needs, z can summed or averaged meaningful values, not problem. naïve attempt this: x = np.arange(min(x), max(x), 0.1) y = np.arange(min(y), max(y), 0.1) x_g, y_g = np.meshgrid(x, y) nx, ny = x_g.shape z_g = np.full(x_g.shape, np.nan) ix in range(nx - 1): jx in range(ny - 1): ...

javascript - laravel - How to list all Event of an calendar if I have permission -

i have web application use google calendar api. when access web app, give me permissions access calendar. example: mr b access web app can access calendar. how can access b's calendar if give me permissions access calendar ? edit: if i'm mr , access web app, can google calendar create event, invite atendees, ... . public function __construct(request $request) { $client = new google_client(); $client->setauthconfig('client_secret.json'); $client->addscope(google_service_calendar::calendar); $client->setaccesstype("offline"); $guzzleclient = new \guzzlehttp\client(array('curl' => array(curlopt_ssl_verifypeer => false))); $client->sethttpclient($guzzleclient); $this->client = $client; } public function oauth() { session_start(); $rurl = action('eventcontroller@oauth'); $this->client->setredirecturi($rurl); if (!isset($_get['code'])) { $auth_url...

C++ ipch visual studio tracked in git.Cannot push due to large size -

Image
i using visual studio c++ , have forked repo , during building,git tracked huge file of 101mb resides in src/.vs/v15/ipch now problem cannot push of changes origin github's size limit 100mb. i committed 4-5 changes after , cannot push single of them origin. following error in bash: remote: error :gh001: i tried doing : git --rm cached <file> this deleted files index still have push changes. how can deal issue? is there way go make n commits , undo tracking of .vs code when changed it? you can try bfg repo-cleaner in order clean local repo of big file, applies on bare repo. for current local (non-bare) repo, can follow " removing sensitive data repository " , remove 1 specific file past commits. git filter-branch --force --index-filter \ 'git rm --cached --ignore-unmatch path-to-your-file-with-sensitive-data' \ --prune-empty --tag-name-filter cat -- --all but actually, should remove .vs folder itself: see "...

Angular - Subscribe to route.queryParams -

i've got in ngoninit ngoninit(): void { this.sub = this.route.queryparams.subscribe((params: any) => { this.data = {...params}; this.stationsservice.getstations(this.data).subscribe((res: any) => { this.stations = res.data.stations }) }); } and have delete function deletemass() { let array: = manipulateselections(this.selected, this.stations); this.stationsservice.deletestations(array).subscribe((res: any) => { this.data.random = math.random(); this.router.navigate([], {queryparams: this.data }); }) } what i'm doing. every time delete stations create random number change me route make first observable runs again. can suggest better way. seems bad practice.

entity framework - List Data from DB using POST method in C# Web API EF -

i working on project , 1 of requirements able list value stories without using method. i have controller code here: // post api/valuestories [responsetype(typeof(valuestory))] public async task<valuestory> postvaluestory([frombody] string value) { valuestory valuestory = await db.valuestories.findasync(); var valuestoryname = (from vs in db.valuestories vs.id == valuestory.id select vs).tolist(); list<valuestory> vs1 = new list<valuestory>(); foreach (var v in valuestoryname) { vs1.add(new valuestory() { id = v.id, valuestoryname = v.valuestoryname, organization = v.organization, industry = v.industry, location = v.location, annualrevenue = v.annualrevenue, createddate = v.createddate, modifieddate = v.modifieddate, mutualactionplan = v.mutualactionplan, ...

linux - Debian Stretch apt autoclean => E: Unable to stat initrd.img. - stat (2: No such file or directory) -

i have installed debian stretch, amd64 architecture. i installed on luks-encrypted lvm volume using debootstrap, unencrypted usb pendrive mounted /boot. it's procedure know well, have been using many years, jessie, wheezy, , (maybe, i'm not sure) before, , have never faced problems of kind. this time installation process seemed have finished successfully, can boot , login system, install packages, etc, when try clean obsolete packages /var/cache/apt/archives using aptitude autoclean or apt autoclean . i error message: e: unable stat initrd.img. - stat (2: no such file or directory) i looked in / directory, , symlinks (initrd.img included) seem created correctly (well, expected, otherwise not bootstrap system), pointing (relative path) /boot directory. i tried remove links, regenerate them manually, uninstalling , reinstalling kernel, no result... i tried update-initramfs -u -k all but strange message i: initramfs attempt resume /dev/dm-2 i:...

Ruby on rails - Showing featured posts? -

i creating blog application ruby on rails , show 30 'featured' articles on home page. i have considered using boolean attribute 'featured' on articles table, have issues this; if have 4000 articles, have search through of them find 30 featured. 3970 articles have empty column. i'm wondering if there better way - such creating db table stores id's of featured articles? thanks in advance. i think in case best decision use model scope featured articles. class article < applicationrecord scope :featured, -> { where(featured: true) } end and use scope rails view <% @articles.featured.each |article| %> <p><%= link_to article.subject, article_path(article) %></p> <% end> link scopes ruby on rails guide

How to change amount of scroll through Scroll Viewer in UWP XAML/C#? -

i using listview display items, let of height 100. in case of many items, vertical scroll bar displayed scrollviewer properties. however, when user scrolls through list, getting scrolled half of screen @ time 1 scrolls covers entire list view. i want have code set amount of scroll, 100 height @ time. tried searching through doc didn't find any. data comes binding , number of items varies, fine have fixed height each item. sample code: <listview name="lvsummarylist" scrollviewer.verticalscrollmode="enabled" scrollviewer.isverticalrailenabled="true" verticalalignment="bottom" selectionmode="none" scrollviewer.verticalscrollbarvisibility="auto" scrollviewer.horizontalscrollmode="disa...

ios - Slow Write performance in Glusterfs -

i newbie glusterfs. have setup glusterfs in 2 servers following options: performance.cache-size 2gb performance.io-thread-count 16 performance.client-io-threads on performance.io-cache on performance.readdir-ahead on when run binary in following manner: ./binary > shared_location/log it takes 1.5 mins log size 100m whereas running in manner: ./binary > local_location/log takes 10 secs. huge difference in time. no of cores in glusterfs server: 2, current machine: 2 is there way can reduce time? also, there standard configuration start off with, can avoid basic issues above?

java - I am building a simple remote control gui but I don't know how to display the number into the textfield -

i building simple remote control gui don't know how display number textfield. knows how? import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.border.border; import java.util.arraylist; import java.util.list; import javax.swing.jbutton; import javax.swing.jframe; import javax.swing.jpanel; import javax.swing.swingutilities; public class remote3 extends jframe { private jlabel remotel, channell, volumel, e1, e2, e3, e4; private jtextfield channeltf, volumetf; private jbutton volumeup, volumedown; private volupbuttonhandler voluphandler; private voldownbuttonhandler voldhandler; public remote3() { e1 = new jlabel(""); e2 = new jlabel(""); e3 = new jlabel(""); e4 = new jlabel(""); remotel = new jlabel("sony",swingconstants.center); channell = new jla...

node.js - Express adding URL to filePath after form submit -

app.js .... app.get('/index', function(req,res) { res.render('index', {}); }); app.get('/indexs', function(req,res) { res.render('index', {}); }); app.get('/indexs/:sistr', function(req,res) { res.render('index', {}); }); jade (pug): form(role="form",id="form1",action="",target="tarframe") ... iframe#tarframe(style="display: none") script(type="text/javascript"). $('#form1').on('submit') function(e) { .... window.location.href = '/indexs/'+str; }); the application works fine until /indexs/'some string' called form submit. when page gets rendered scripts/css/etc loaded have url first part of filepath. when /index rendered on initial application load, scripts example: get /vendor/select2/select2.min.js (rc=200) when /indexs/'some string' called form submit (which renders index), scripts as: get...

jquery - Overflow property in CSS -

.course_strip{ background-color: rgba(0,0,0,0.65); height: 44px; color:#f1f1f1; line-height: 44px; vertical-align: middle; text-transform: uppercase; font-size: 18px; letter-spacing: 1px; font-family: 'segoe ui'; } .course_strip p{ padding: 0 10px; } .course_strip p:hover{ background-color: #000; } .course_strip p:active{ background-color: #4caf50; } .course_strip .glyphicon{ line-height: 44px; top: 0px; } .course_strip_left p{ float: left; } .course_strip_right p{ float: right; } .left_container{ width: 20%; height: 100%; background-color: #f1f1f1; padding-top: 20px; padding-left: 16px; font-family: 'segoe ui', tahoma, verdana, sans-serif; font-size: 15px; } .left_container h2{ margin-top: -4px; font-size: 21px; font-weight: 500; } .left_container p{ margin-top: 40px; padding-left: 1px; font-weight:...

c# - How to enable subdomain multisite feature for an dotnet web application? -

i wonder how enable subdomain multisite feature microsoft dotnet web application wordpress php application. example, microsoft dotnet application has domain name: example.com. when user1 register application, provides user1 domain name user1.example.com. when user2 register may application, provides user2 url user2.example.com... question is: microsoft dotnet support technique? if yes, please tell me how do. thanks.

javascript - toISOString() changes datetime value -

i have array of objects.each object in array has date property.i try biggest(the last) date array. here array: var sensorsdata = [{ id: 1, measuredate: "2017-08-20t09:52:32" }, { id: 2, measuredate: "2017-08-20t09:54:35" }, { id: 3, measuredate: "2017-08-20t09:56:13" }]; and here function fetch biggest date array above: function updatelatestdate(sensorsdata) { return new date(math.max.apply(null, sensorsdata.map(function(e) { return new date(e.measuredate); }))).toisostring(); } the result updatelatestdate function is: 2017-08-20t06:56:13.000z but strange because, can see no 1 of properties in sensorsdata objects doesn't have date returned updatelatestdate function. here fiddler . any idea why updatelatestdate function returns wrong result? when create date new date(str) creates date object time zone. toisostring() makes 0 utc offset, denoted suffix "z". here workaround: var date = n...

c# - Connection String null reference exception in other systems -

i need set .dbml connection string because it's change after deploying. test many posts in google no 1 works me. here links test in app. 1. setting connection string in dbml files using linq sql in visual studio 2008 2. point connectionstring in dbml app.config in app code, connection string <add name="purewater.properties.settings.purewaterconnections" connectionstring="data source=.;initial catalog=purewater;integrated security=true" providername="system.data.sqlclient" /> according 1 , 2 abbove, set .dbml connection none , left empty. modify .dbml designer code. after that, call data context (dbml) other windows forms this: purewatercxtdatacontext cxt = new purewatercxtdatacontext(configurationmanager.connectionstrings["purewater.properties.settings.purewaterconnections"].connectionstring); everything ok , don't have error on own system error on other systems on configurationmanager.connectionstr...

php - htaccess redirect TLD preserve subdomains -

i want redirect tlds specific tld, , want preserve subdomains. the followings redirect examples need: sub1.domain.net -> sub1.domain.com sub2.domain.net -> sub2.domain.com sub3.domain.net -> sub3.domain.com sub1.domain.org -> sub1.domain.com sub2.domain.org -> sub2.domain.com sub3.domain.org -> sub3.domain.com i have tried code in .htacess file: rewritecond %{http_host} !^([a-za-z_\-\.(0-9)]*)domain\.com rewriterule ^ http://$1domain.com%{request_uri} [l,r=301] but $1 not recognized variable. $1 undefined in example not capturing uri. use captured part of hostaname ,you need %n variable. : rewritecond %{http_host} !example\.com$ rewritecond %{http_host} ^((?!www\.).+)\..+$ rewriterule ^ http://%1.example.com%{request_uri} [ne,l,r]

How to make pivot table in SQL Server in my case? -

i wants display record same column. don't know how describe question also. i have table called soldqtytable itemno weeks years qtysold asofweekonhand ---------------------------------------------------- 1 1 2017 5 3 2 1 2017 2 5 3 1 2017 66 70 1 2 2017 4 33 i wants display below itemno years [1qtysold] [1_onhand] [2qtysold] [2_onhand] ----------------------------------------------------------------------- 1 2017 5 3 4 33 2 2017 2 5 3 2017 66 70 i tried in way. doesn't work select pvt1.itemid, pvt1.storeid, pvt1.years, isnull([1],0) [1qtysold], isnull([2],0) [2qtysold], isnull([1_onhand],0) [1_onhand], isnull([2_onhand],0) [2_onhand] ( select itemid, storeid, years...

php - Transfer IP accounting to single row table -

regarding other question: ip accounting sql database i need other script writing. have script fetch info except packets in table , put table single rows of information, script must check every single source, destination , bytes table (i not worried packets) , store other table adds total bandwidth upload , download per ip address. so must store table 1 column named ipaddress, called downloadtransfer, called uploadtransfer, called totaltransfer (which adds both upload , download , last timestamp. how can that? have tried info 2 tables not sure on how , have check each other nor select each column , add store new table. <?php include 'config.php'; $conn = mysqli_connect($sqlserver, $sqlusername, $sqlpassword, $sqldatabase); $query = "select * users" , "select * datapackages"; $result = mysqli_query($conn,$query); echo "<table>"; echo "<tr><th>username</th><th>datapackageid</th><th>dat...

Perform "outer product" of 2-D matrix and return a 3-D array in MATLAB -

i operation on 2-d matrix somehow looks outer product of vector. have written codes task, pretty slow, know if there can accelerate it. i show code wrote first, followed example illustrate task wanted do. my code, version row-by-row function b = outer2d(a) b = zeros(size(a,1),size(a,2),size(a,2)); %pre-allocate output array j = 1 : size(a,1) b(j,:,:) = transpose(a(j,:))*a(j,:); %perform outer product on each row of , assign j-th layer of b end end using matrix = randn(30000,20) input testing, spends 0.317 sec. my code, version page-by-page function b = outer2d(a) b = zeros(size(a,1),size(a,2),size(a,2)); %pre-allocate output array j = 1 : size(a,2) b(:,:,j) = repmat(a(:,j),1,size(a,2)).*a; %evaluate b page-by-page end end using matrix = randn(30000,20) input testing, spends 0.146 sec. example 1 a = [3 0; 1 1; 1 0; -1 1; 0 -2]; %a input matrix. b = outer2d(a); disp(b) then expect (:,:,1) = 9 0 1 1...

javascript - Angular 4.2 DSL animation -

i`m try use angular 4.2 new animation api , create simple example when try make fadein / fadeout effects. seems transition fadeout => fadein not called. why? trigger('divanimation', [ state('fadein', style({opacity: 1})), state('fadeout', style({opacity: 0})), transition('* => fadein', [ query('span, p', style({transform: 'translatex(-50px'})), query('span, p', [ animate(500, style({opacity: 1, transform: 'translatex(0)'})), ]) ]), transition('* => fadeout', [ query('span, p', [ animate(500, style({opacity: 0})) ]) ]) ]) https://plnkr.co/edit/0c5esoszz7zkcrdevvos?p=preview try this: animations: [ trigger('divanimation', [ state('fadein', style({opacity: 0})), state('fadeout', style({opacity: 1})), transition('fadein <=> fadeout', animate(500)) ]) ],

c++ - I want to draw a rectangle on an image at given pixel location using wxWidgets -

i want add rectangle on image. rectangle starts position , size based on pixels of image . suppose have image of resolution 100x100 , want draw rectangle 25x25 50x50 (i.e 25th pixel in both horizontal , vertical 50th pixel). , when resize image new pixels info should updated , rectangle should across same image previously. consider group photo having x ,y,z in them , know pixel info of x in picture @ full resolution should draw rectangle on x , when user resizes image rectangle should still focus on x irrespective of pixel info. int neww, newh; dc.getsize(&neww, &newh); if (neww != w || newh != h) { resized = wxbitmap(image.scale(neww, newh , wximage_quality_high)); w = neww; h = newh; dc.drawbitmap(resized, 0, 0, false); dc.setpen(wxpen(*wxlight_grey, 2)); dc.setbrush(*wxtransparent_brush); dc.drawrectangle(wxpoint(352,78), wxsize(50, 50)); }

docker - CasperJS doesn't load content injected by Angular router -

i'm preparing example project on github accompany course i'm working on how write functional tests dockerized applications. application has part angular2 single-page app, i'm trying test app casperjs (i've tried behat same problem explained below). when running tests in casperjs it's if routing in angular doesn't load tests, mean can assert things in index template exist (like page title example) things inside <app-root></app-root> tags don't load tests. the code here index template: <!doctype html> <html lang="en"> <head <meta charset="utf-8"> <title>testproject</title> <base href="/"> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <app-root></app-root> </body> </html> the test is: casper.test.begin('tests homepage structure', function suite(tes...

sql server - SQL Query check result with other rows in same table -

i want build sql query select row based on date range , want additional columns following sample table +----+--------------+--------------+--------------+--------------+ | id | customerid | accountid | datefrom | dateto | +----+--------------+--------------+--------------+--------------+ | 1 | c0001 | a0001 | 21/01/2016 | 28/01/2016 | | 2 | c0001 | a0001 | 01/02/2016 | 08/02/2016 | | 3 | c0002 | a0002 | 09/02/2016 | 16/02/2016 | | 4 | c0002 | a0002 | 14/01/2016 | 21/01/2016 | | 5 | c0003 | a0003 | 07/01/2016 | 14/01/2016 | | 6 | c0003 | a0003 | 09/02/2016 | 16/02/2016 | | 7 | c0004 | a0004 | 01/01/2016 | 07/01/2016 | | 8 | c0004 | a0004 | 09/03/2016 | 16/03/2016 | +----+--------------+--------------+--------------+--------------+ if if pass date range 01/02/2016 28/02/2016 need result follows +----+-----------...

Python Check how many times item appears in a row in list -

if have list, say lst = [1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0] i'm trying find way show amount of times in row each item appears, return list afterwards lstnew = [(1, 4), (0, 2), (1, 1), (0, 4), (1, 3), (0, 2)] thanks in advance. (the outputed data format not matter much, if it's easier return dict go ahead) you can use groupby from itertools import groupby [(a, len(list(b))) a, b in groupby(lst)] result: [(1, 4), (0, 2), (1, 1), (0, 4), (1, 3), (0, 2)] group group consecutive elements of same value , len(list(...)) can take length of group. 1 advantage of method, it'll run in linear time.

Call a generated .dll file from codegen matlab in c program -

i using codegen in matlab r2016b generate .dll file follows: codegen -config:dll ex_fun.m -args {0,0,0,0,0,0} i have tried include dll file reference using visual studio 2015 nothing works fine , couldn't use .lib file linker eitherll. the strange thing use gcc on linux compiling .c script calls c function along output .so file (which equivalent .dll in windows) follows: gcc main.c ex_fun.so -wl,-rpath=$(pwd) however, couldn't find direct method in windows. how can use , call .dll file output matlab in c main script program? it should noted .def file generated don't how use along output dll file. in visual studio ide: switch platform "x64" in project properties: c++>general>additional include directories = ^add compilation folder. linker>general>additional libraries directories = ^add compilation folder. linker>input>additional dependencies = "ex_fun.lib" in code: add #include "ex_fun.h...

sql - Exception "Data source name not found" while connecting to an existing DSN -

i have created odbc connections (both 32/64 bit) configuration given below: microsoft sql server odbc driver version 10.00.14393 data source name: odbcmssql data source description: server: .\sqlexpress database: medicalmarketting language: (default) translate character data: yes log long running queries: no log driver statistics: no use regional settings: no prepared statements option: drop temporary procedures on disconnect use failover server: no use ansi quoted identifiers: yes use ansi null, paddings , warnings: yes data encryption: no i want connect local mssql server given in below code snippet: string connectionstring = "data source=odbcmssql;initial catalog=medicalmarketting;integrated security=true"; con = new odbcconnection(connectionstring); cmd = new odbccommand(); cmd.connection = con; cmd.commandtype = commandtype.text; try { this.con.open(); this.tr = con.begintransacti...

javascript - Does require('./bar') try to load a file named 'bar' first or 'bar.js' first? -

quoting article @ https://medium.freecodecamp.org/requiring-modules-in-node-js-everything-you-need-to-know-e7fbd119be8 below: we can natively require json files , c++ addon files require function. don’t need specify file extension so. if file extension not specified, first thing node try resolve .js file. if can’t find .js file, try .json file , parse .json file if found json text file. after that, try find binary .node file. however, remove ambiguity, should specify file extension when requiring other .js files. here little experiment seems contradict written above. $ cat foo.js console.log('i foo.js!') require('./bar') $ cat bar.js console.log('i bar.js!') $ cat bar console.log('i bar!') $ node foo.js foo.js! bar! $ node bar bar! the experiment shows if not specify .js extension name, i.e. import bar or try run bar , first thing node tries find file named bar . therefore, contradicts following statement quoted article. ...

javascript - using jquery click eveny from within an object -

i want add click event <span> in dom click event sits in object i have html <html> <body> <span id="metolog">hello-world </span> </body> <script> function makeobj(){ this.logme= $("#metolog").click(function(){ console.log("shoot") }) } const obj = new makeobj() obj.logme // want listen click event </script> </html> as mentioned in comment problem you're storing in constructor's property logme . click() method returns jquery object, span in case, click handler never attached it. http://api.jquery.com/click/ what have right in constructor this: function makeobj(){ this.logme= $("#metolog").click(function(){ console.log("shoot") }) } const myobj = new makeobj(); // test logme console.log(myobj.logme); // returns jquery object [span#metolog] one solution transform logme property method in order attach cl...

ios - How to set contraints for self sizing UITableViewCell using Auto Layout in Interface Builder -

Image
i have self-sizing tableviewcell presents comments. if current user commented present edit , delete buttons. contraints work in case. of constraints set in interface builder. the challenge when comment doesn't belong user set .ishidden = true both edit , delete buttons. how can adjust constraints new scenario? edit: issue when set .ishidden true on buttons, want cell height shrink button space empty. another approach: toggle .isactive state of constraint bottom of buttons bottom of cell, along .ishidden state. to so, add vertical space constraint bottom of date label bottom of cell, set >= 4 (or "padding" want when buttons not there). add @iboutlet spacing constraint bottom of edit button bottom of cell. in image, shows bottom = edit button.bottom + 2 . when ctrl+drag constraint ib source file generate iboutlet line this: @iboutlet weak var editbuttonbottomconstraint: nslayoutconstraint! you need edit line, though... constraints de...

ios - Can I union multiple transparent SCNShape objects? -

Image
i'm adding multiple transparent scnshape objects arscnsceneview scene. these shapes based on user input , should overlap. they flat shapes made uibezierpath on same plane shapes has transparent, user can see camera input behind the problem overlapping shapes visible, , i'd show single shape - union of shapes. failed approaches: putting under same node , use parent opacity. merging uibezier paths. blend modes transparency modes drawing using primitive triangles instead of uibezierpath you have @ vectorboolean swift library deal boolean operations union looking for. haven't tried myself have heard things it.

c# - Create Restful Service Using Repository -

i have mvc application. using repository pattern , dependecy injection patterns. here simple interface : [servicecontract] public interface icategoryservice { [operationcontract] list<category> getall(); category add(category category); } and concrete class implements interface: public class categorymanager : icategoryservice { private readonly icategorydal _categorydal; public categorymanager(icategorydal categorydal) { _categorydal = categorydal; } public list<category> getall() { return _categorydal.getwithsp(); } public list<category> getall(int a) { return _categorydal.getlist(); } public category add(category category) { return _categorydal.add(category); } } i inject concrete class interface in global.asax. need create web service expose methods in interface (this interface example. not one). how can few effort? because of me...

React native: How to use js library from cdn stripe.js -

i want use stripe.js library react native available cdn. is possible use js library cdn react native? if goal integrate external javascript file in project, best way might download file cdn manually, or part of build process , require / import local file in app. however, using stripe in app, i'd recommend looking mobile-specific solution such stripe-expo , or react-native-payments react-native-payments-addon-stripe . stripe.js library intended browser use, , while may work, mobile-specific sdks work better in react native. googling "react native stripe" turns out few other third-party libraries well. haven't used of them, may worth evaluating.

javascript - Different stylesheet for different device -

i have question: how automatically change website based on device type? know there like @media screen , (max-width:720px){/*code mobile here*/} @media screen , (min-width:1280px) {/*code pc here*/} but think can cause problems on big resolution mobile devices , low resolution desktop monitors. wonder there way of changing css file/selecting exact part of css code based on device type, smartphone, tablet or pc? anything works help. if not clear, try explain better. if i'm wrong, correct me. you can use these: // large devices (desktops, less 1200px) @media (max-width: 1199px) { ... } // medium devices (tablets, less 992px) @media (max-width: 991px) { ... } // small devices (landscape phones, less 768px) @media (max-width: 767px) { ... } // small devices (portrait phones, less 576px) @media (max-width: 575px) { ... }

github - How to add the commit's description to the discord webhook bot messages? -

i followed tutorial create webhook between github , discord. https://support.discordapp.com/hc/en-us/articles/228383668 everything worked expected , bot updating chat fine. despite searching in docs ( https://discordapp.com/developers/docs/resources/webhook ), not find how configure bot displays commit's description. i don't know if possible, can point me how handle this? the discord github webhook display first line of commit git typically treats summary. the github push webhook publishes json document containing fields such head , refs , , commits array fields such message , author . however, default discord webhook expects simpler json document content field message body. webhook reject github push document. however discord provides special github webhook understands payload of github push webhook . you've set noted displays first line of commit. there doesn't seem way customize it. if want display full commit message, you'l...

swift - check URL text as a string in Xcode -

this question has answer here: how check string starts (prefix) or ends (suffix) in swift 2 answers i have text field user can use enter linkedin url. however, don't want user able enter url want how can check string entered starts with https://www.linkedin.com/in/... you can use string's hasprefix function: if textfield.text.hasprefix("https://www.linkedin.com/in") { print("string starts https://www.linkedin.com/in") } else { print("string not start https://www.linkedin.com/in") }

python - Merge colormaps in matplotlib -

Image
i want merge 2 colormaps imshow plot. want use 'rdbu' range -0.4 0.4, 0.4 maximum value (say 1.5) want use gradient same blue color (say green example). how can that? this how far got far: import numpy np import matplotlib.pyplot plt import matplotlib.colors colors matplotlib.mlab import bivariate_normal n = 100 ''' custom norm: example customized normalization. 1 uses example above, , normalizes negative data differently positive. ''' x, y = np.mgrid[-3:3:complex(0, n), -2:2:complex(0, n)] z1 = (bivariate_normal(x, y, 1., 1., 1.0, 1.0))**2 \ - 0.4 * (bivariate_normal(x, y, 1.0, 1.0, -1.0, 0.0))**2 z1 = z1/0.03 # example of making own norm. see matplotlib.colors. # joe kington: 1 gives 2 different linear ramps: class midpointnormalize(colors.normalize): def __init__(self, vmin=none, vmax=none, midpoint=none, clip=false): self.midpoint = midpoint colors.normalize.__init__(self, vmin, vmax, clip) def __call__(se...

php - Submit button value vs. hidden input value -

could please tell me difference between submitting submit button value , submitting hidden input value ? i ask question in regard of browser compatibility (ie 9+). so, problem following: know posted hidden input value correctly read server. i'm not sure if case too, if value (which want post) part of "value" attribute of <button> tag. thank time! p.s: prepared example clarity. contains form each option in question. when 1 of forms submitted, corresponding values read in php. relevant user id value. <?php if (isset($_post['submituserid']) && !empty($_post['submituserid'])) { // submitted values. $userid = $_post['submituserid']; $username = $_post['username']; echo 'posted user id: ' . $userid; echo '<br/>'; echo 'posted user name: ' . $username; // save new values in db... } else { // initial values fetched db. $userid = 123; $username = 'v...

scala - strange behavior while pattern matching -

object state { def unapply(s: string): option[int] = if (s.trim.isempty) none else some(s.trim.length) } and output... scala> " hello" match { case state(l) => l } res25: int = 5 and things went south ... scala> " " match { case state(l) => l } scala.matcherror: (of class java.lang.string) @ .<init>(<console>:9) @ .<clinit>(<console>) @ .<init>(<console>:7) what bugging me, why did throw matcherror? clear explanation helpful. the none result means extractor input value unsuccessful, other extractors can considered, if no other specified, should throw matcherror . documentation : this equivalent val name = customerid.unapply(customer2id).get . if there no match, scala.matcherror thrown: val customerid(name2) = "--asdfasdfasdf"

Python What is difference between file iterator and list iterator? -

this question has answer here: confused python lists: or not iterators? 4 answers if have file iterator with open('test1.txt','r') f1: print(f1.__next__()) but if same thing list, doesn't work. a1 = [1,2,3,4,5] a1.__next__() so, difference between file iterator , list iterator? file , list (or tuple, dictionary, etc.) iterators behave differently? there no such file iterator , list iterator.iterator works on iter objects. list iterable , not iter object, can make them iterable. a =[1,2,3,4,5] a= iter(a) a.next() all python data types except number can made iterable. confused python lists: or not iterators?

graphviz directed graph with parents at top -

Image
this directed graph digraph g { semigroup monoid -> semigroup band -> semigroup } renders dot as but want semigroup @ top. have bigger example this, hacks using rank aren't going work. general theme want arrows point upwards instead of downwards. i tried using -y parameter, makes no difference. if use <- in file getting top/down order correct, i'd need way reverse drawing of arrow. you add graph rankdir = bt;

A simple JavaScript / jQuery way of swapping the positioning of two image links on click? -

i have set client-side translation of web page using translate.js . if user clicks on say, french, move position of english , english move position of french. tried following: $('.img-btn').click(function(){ var clickedid = $(this).attr('src'); alert('you clicked on button #' + clickedid); $('.img-btn.active').attr('src', clickedid); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script> <div id="language-select"> <a class="lang_selector trn" href="#" role="button" data-value="fr"><img id="french" class="img-fluid rounded-circle img-btn" src="img/flags/fr.jpg" alt="french"></a> <a class="lang_selector trn" href="#" role="button" data-value="it"><img id="italian" class=...

java - How to Remove label on pie chart -

Image
i have created pie chart using philjay mpandroidchart not want text , figure written on pie chart should beside of pie chart color description figure. display @ downside without figure. to remove x-values use piechart.setdrawslicetext(false) . to remove y-values use piechart.getdata().setdrawvalues(false) .

java - show only 2 panels in JColorChooser -

i want display "swartches" , "rgb" panel. import java.awt.color; import java.awt.dimension; import java.awt.flowlayout; import java.awt.event.actionevent; import java.awt.event.actionlistener; import javax.swing.jbutton; import javax.swing.jcolorchooser; import javax.swing.jframe; import javax.swing.joptionpane; import javax.swing.colorchooser.abstractcolorchooserpanel; public class colorpickersample { private static final long serialversionuid = 1l; private static string hex = "#ff0033"; private static void createandshowgui() { // create , set window. final jframe frame = new jframe("centered"); // display window. frame.setsize(50, 100); frame.setvisible(true); frame.setdefaultcloseoperation(jframe.exit_on_close); // set flow layout frame frame.getcontentpane().setlayout(new flowlayout()); jbutton button = new jbutton(""); system.o...

get token from more 1 type by javascript -

i have 4 type of url , need token. type1 http://gettoken/index.php?action=test&token=aaaaa type2 http://gettoken/index.php?action=test&token=aaaaa&login=admin type3 http://gettoken/index.phpaction=test&login=admin&token=aaaaa&expires=3600 type4 http://gettoken/index.php?action=test&login=admin&expires=3600&token=aaaaa and token length 5 character. here function return parameter value url function getparameterbyname(name, url) { if (!url) url = window.location.href; name = name.replace(/[\[\]]/g, "\\$&"); var regex = new regexp("[?&]" + name + "(=([^&#]*)|&|#|$)"), results = regex.exec(url); if (!results) return null; if (!results[2]) return ''; return decodeuricomponent(results[2].replace(/\+/g, " ")); } use bellow var url ="http://gettoken/index.php?action=test&login=admin&token=aaaaa&expires=3600"; var action = getparameterbyname(...

wp_query filter for users in wordpress by button click event -

hey want let visitors in website filter between 3 different kinds of users. have 3 buttons in top of page. query $args = array( 'offset' => $paged ? ($paged - 1) * $number : 0, 'number' => $number, ); it shows 12 users per page , gives pagination in bottom. how can change query through buttons? tried transfer data url , $_get function ruins pagination...please help! by way know how filter user_meta_data . want know how there through button click event.

jquery - onMouseMove function instead of onMouseDown -

i have three.js script stops scene rotation onmousedown want stop rotation on mouse hover instead of onmousedown. $(function(){ var camera, renderer; var ismousedown = true; var mpi=math.pi /180; var circleradius = 1400; var startangle = 0; var centerx = 0; var centerz = 0; var startradians = startangle + mpi; var totalspheres = 4; var incrementangle = 360/totalspheres; var incrementradians = incrementangle * mpi; var element = function ( id, dat, position, rotation ) { var html = [ '<div class="wrapper" >', '<ul class="stage clearfix">', '<li class="scene" >', '<div class="movie i1" id="' + id + '" >', '</div>', '</li>', '</ul>', '</div>' ].join('\n'); var div = document.createelement('div');...