Posts

Showing posts from July, 2013

c++ - Strange behavior when static casting from a big double to an integer -

here 's simple code: int main() { double d1 = 10000000000.0; const double d2 = 10000000000.0; cout << static_cast<int>(d1) << endl; cout << static_cast<int>(d2) << endl; cout << static_cast<int>(10000000000.0) << endl; } the output is: -2147483648 2147483647 2147483647 this surprised me grealy. why positive double casted negative int? i'm using g++ : gcc version 4.4.3 (ubuntu 4.4.3-4ubuntu5). casting double int when int isn't big enough hold value yields undefined behaviour . [n3290: 4.9/1]: prvalue of floating point type can converted prvalue of integer type. conversion truncates; is, fractional part discarded. the behavior undefined if truncated value cannot represented in destination type. this behaviour derived c: [c99: 6.3.1.4/1]: when finite value of real floating type converted integer type other _bool , fractional part discarded (i.e., value truncated ...

jquery - How to click on a primary key and have that data sent to another page? -

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js" type="text/javascript"> </script> <script type="text/javascript"> $(document).ready(function(){ $("#stuff").on("click",function(){ //var thing=$(this).text("td:first"); var tag=$(this).find("td:first").html(); var thing=$("tag").text(); alert(thing); //var thing=$(this).parent().siblings(":first").text(); window.location.href='thing.jsp?thing=' + thing; }); }); </script> <form action="relay" method="get"> <table border="2" id="stuff"> <tr> <td>id</td> <td>lion</td> <td>tiger</td> <td>libra</td> <td>ox</td> ...

Why are some datetime values being deleted when I round the time in R? -

i importing series of csv files r. these contain date/time column, id, , 2 columns of temperature values. this give example of data looks like: id<-c(1,2,3,4) date.time<-as.character(c("12/03/17 00:21:28", "12/03/17 02:21:28", "12/03/17 04:21:28", "12/03/17 06:21:28")) temp1<-c(-3.568,-3.568,-3.598,-3.598) temp2<-c(-11.577,-11.577,-11.541,-11.433) df<-data.frame(id,date.time,temp1,temp2) because date/time not in format want, i've been using strptime , formatting them posixlt. like: df$date.time<-strptime(df$date.time, "%d/%m/%y %h:%m:%s") df$date.time<- as.posixlt(df$date.time, "%y/%m/%d %h:%m:%s", tz="gmt0") this works fine , gives data looks like: id date.time temp1 temp2 1 2017-03-12 0:21:28 -3.568 -11.577 2 2017-03-12 2:21:28 -3.568 -11.577 3 2017-03-12 4:21:28 -3.598 -11.541 4 2017-03-12 6:21:28 -3.598 -11.433 however, want round time par...

jquery - Place Sub-Div in New Parent for Mobile/Narrow Width, 3-Col Bootstrap Otherwise -

jsfiddle: https://jsfiddle.net/lukeu3f8/4/ i have 3-column boostrap layout. selecting in col 1 activates 2, 2 activates 3 (like step-by-step wizard). the issue when browser resized (and in mobile) columns 2 , 3 wrap around column 1 @ bottom . can see if resize jsfiddle window. initially when page opened, no big deal because no selection has been made. it's ok show 1,2,3 sequentially in single column. once col 1 menu selected, in mobile (or desktop if $(window).width() < 1000 in experience) col 2 , later col 3 must detached/prepended under menuitem li (in front) clicked. think have scroll active li, can come later. other scenarios ok, can keep 3-col layout is. i need function both on startup , resizing like function resizesec2and3() { var limit = 1000; // perform detachment if (1) window width < limit, (2) menu selection has been made if ($(window).width() < limit && currmenuitemindex != -1) { var col2element...

How to grab data from plain text response of API Calls in PHP? -

i'm getting api response in plain text. need grab data text response , need store them variables. api calling: $url="http://91.101.61.111:99/sendrequest/?mobile=9999999999&id=11011&reqref=501"; $request_timeout = 60; $ch = curl_init(); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_timeout, $request_timeout); curl_setopt($ch, curlopt_connecttimeout, $request_timeout); curl_setopt($ch, curlopt_returntransfer, 1); $output = curl_exec($ch); $curl_error = curl_errno($ch); curl_close($ch); api response in plain text: request accepted ref=501 system_reference=ba01562 i need grab data above plain text response variables, below: $status = "request accepted"; $myref = "501"; $sysref = "ba01562"; i have tried: $explode1 = explode(" ", $output); $explode2 = explode("=", $explode1[3]); $explode3 = explode("=", $explode1[4]); $status = $exp...

How to write SortedSet of cassandra data type as json in python? -

i trying dump cassandra data in csv format using python. far, developed following script: from cassandra.cluster import cluster cassandra.auth import plaintextauthprovider cassandra.query import tuple_factory cassandra.query import dict_factory import csv auth_provider = plaintextauthprovider(username='cassandra', password='std123') cluster = cluster(['127.0.0.1'],auth_provider=auth_provider) session = cluster.connect('killrvideo') session.row_factory = tuple_factory rows = session.execute("select * videos videoid = 873ff430-9c23-4e60-be5f-278ea2bb21bd") row = cursor.fetchall() open('data.csv', 'w') fp: = csv.writer(fp, delimiter=',') a.writerows(rows) cluster.shutdown() and giving me output like: 873ff430-9c23-4e60-be5f-278ea2bb21bd, 2013-05-16 23:50:00, second in 3 part series cassandra data modeling, http://www.youtube.com/watch?v=qphhxujn5es,1, "sortedset([video_metadata(height=480, widt...

html - width of the width and height not working -

hi trying change width , height of .content class. giving me 100px of width , 100% of height if don't mention. have tried removing float stil not working.what reason? <!doctype html> <html> <head> <style> body{margin:0} #navbar{ width:100%; background-color:black; height:50px; padding: 0 150px 0 150px; position:relitive; } #logo{height:60px; width:90px; } #container{ background-color:#e6e6e6; width:78%; margin: auto; height:1000px; text-align:center; } #navtable{ color:white; position:absolute; top:10px; left:300px; font-size:1.5em; } #navtable td{padding:0 10px 0 10px; border-right:1px solid wh...

excel - MDX return caption as value -

i got following mdx query: select non empty [measures].[closed events] on columns ,non empty filter ( { [date].[year].&[2017]* ([date].[week number].&[36] : [date].[week number].&[52])* [visited contact].[contact sf id].children* [assignee].[role name].&[pl - sales rep hcp] } , [measures].[closed events] > 0 ) on rows [visit analysis]; how influence set within filter have both year , week number represented numbers in excel (data table) , not strings? what measures? with member [measures].[year] cint([date].[year].currentmember.name) member [measures].[weak] cint([date].[week number].currentmember.name) select non empty {[measures].[closed events],[measure].[year],[measure].[weak]} on columns ,non empty filter ( { [date].[year].&[2017]* ([date].[week number].&[36] : [date].[week number].&[52])* [vi...

ReactJS app on SSL -

i'm new reactjs , trying test deploying web server. it's 1 component says hello, make sure working. it works fine on local host, when upload webserver, configured ssl, not work. works: http://careigniter.com/x/test/ does not work: https://careigniter.com/x/test/ is there special have if going serve entire app under ssl? thanks! the issue server has wordpress , caching, going on. should have started on fresh server begin with.

react native - Error screen with white background -

Image
when getting exception react native on ios, error screen white background. can see tapped cell has exception stack, white background. not sure why's happening, there way fix? on android screen has red background (hence working expected.) running react native 0.48.3.

python - Reuse %s placeholder without duplicating the variable? -

mysql ver 14.14 distrib 5.7.19, linux (x86_64) i'm running insert / on duplicate key update query this: query = ("insert table set col1 = %s, col2 = %s, col3 = %s on duplicate key update col2 = %s, col3 = %s") cursor.execute(insert_post, (var1, var2, var3, var2, var3,)) is there way without reusing each of variables in cursor.execute() function, or better off doing string formatting format() ? iiuc, use named formatters , pass dict second argument. query = ("""insert table set col1 = %(var1)s, col2 = %(var2)s, col3 = %(var3)s on duplicate key update col2 = %(var2)s, col3 = %(var3)s""") cursor.execute(insert_post, {'var1' : var1, 'var2' : var2, 'var3' : var3}) reference.

Unable to run Airflow Tasks due to execution date and start date -

whenever try run dag, in running state tasks not run. have set start date datetime.today() , schedule interval "* * * * *". manually triggering run start dag task not run due to: the execution date 2017-09-13t00:00:00 before task's start date 2017-09-13t16:20:30.363268. i have tried various combinations of schedule intervals (such specific time each day) waiting dag triggered , manual triggers. nothing seems work.

android - Failed to resolve: com.google.firebase:firebase-core:11.2.0 -

Image
i'm getting multiple "failed resolve" issues when syncing project. firebase , play-services related. made sure same (11.2.0). i've checked , latest version both 11.2.0. also, other answers similar questions involve updating google play services , repository in sdk manager mine date. any idea why can't sync project? edit - current working solution // top-level build file can add configuration options common sub-projects/modules. buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.3.3' classpath 'com.google.gms:google-services:3.0.0' classpath 'com.google.firebase:firebase-plugins:1.0.4' // note: not place application dependencies here; belong // in individual module build.gradle files } } allprojects { repositories { jcenter() maven { url "https://maven.google.com" } } } task cle...

c++ - Why am I seeing different behavior between arrays allocated on the heap and the stack? -

i inspecting behavior of 2 2d arrays in c++, 1 allocated stack, , 1 allocated heap. i create two, 2d arrays of same shape, , populate arrays data. attempt read arrays in 2 different methods, first being simple array index format "arr[row][column]". read arrays using pointer dereference, , 2 different results heap allocated array, identical results stack allocated array. trying understand why results differ. appreciate clarification can provide. in advance. the code running below: #include <iostream> using namespace std; int main(){ int rows = 6; int columns = 3; // allocate stack. double q[rows][columns]; // allocate heap. double ** a; = new double*[rows]; for(int = 0; < rows; ++i){ a[i] = new double[columns]; } // populate arrays. for(int = 0; < rows; ++i){ for(int j = 0; j < columns; ++j){ a[i][j] = columns*i+j; q[i][j] = columns*i+j; } } ...

windows 10 - OneNote Take Screen Clipping Shortcut -

i've searched quite lot , haven't found answer yet. i'm hoping here can help. an application installed kidnapped onenote shortcut key take screenshots ( windows + shift + s ). tried reinstalling onenote time use shortcut, else launched. is there way reset shortcut onenote? thanks!

c# - Use Parallel.ForEach or fill List<Task> by foreach -

i trying use multi-threading. want run list of task .there 2 choice me, write 2 code below: list<task> tasklist=new list<task>(); foreach (var item in itemlist) { tasklist.add(task.factory.startnew(()=> dotasks(item,new random().next(15,40)))); } task.waitall(tasklist.toarray()); console.writeline("all tasks done!"); and this: parallel.foreach(itemlist, item => dotasks(item, new random().next(15, 40))); console.writeline("all tasks done!"); my questions: better in performance? parallel.foreach have threadpool manage opened tasks? there way better? parallel.foreach better choice. reuse current thread execute dotasks, total number of threads less in first case. in addition, start execution while in case foreach there delay between moment when created tasks , moment when scheduler run first task.

react native - Timeout waiting for modules to be invalidated -

i've react-native application using v0.43, few days ago , i've decided upgrade v0.48, , faced lot of issues found solutions them, , application starts , loading screen give me error timeout waiting modules invalidated i've searched it, didn't found solution ? suggestions ? remove { display: 'none' } style

java - The system cannot find the file specified - WEB-INF config file running on Tomcat 6 -

i have web application deployed war in tomcat 6. trying read config file under web-inf/ java class packaged in jar under web-inf/lib. get: the system cannot find file specified code: properties props = new properties(); file propsfile = new file(".\config.properties"); inputstream stream = this.getclass().getclassloader().getresourceasstream(propertiesfilepath); if (stream != null){ props.load(stream); log.debug("stream not null"); } else props.load(new fileinputstream(propsfile)); it works fine in server in production in our test server doesn't. server config related? try this: url resource = new url(this.getclass().getresource("."), "config.properties"); inputstream stream = resource.openconnection().getinputstream();

virtual machine - How to open a browser on a Google Compute Engine VM -

how can open browser in vm instance? , how safe/unsafe can be? the instance ubuntu 16.04 the way know access vm via ssh button provided google on cloud console website. i want use regularly, pages visually displayed , mouse clicks. (treat me newbie, i'm totally new on linux , on vms. didn't know there way of controlling browser) context: i need download huge amount of data websites virtual machine on google compute engine. i know there solutions on web transfer files machine, internet sucks, it's not feasible. i know there commands wget using copied cookies download files. even though, feel i'll needing use browser, because want use regular google drive interface transfer files if need. knowing more helps, question "how open browser , navigate if regular newbie, pages displayed , mouse clicks". install desktop sudo apt-get install ubuntu-desktop install vnc server https://www.digitalocean.com/community/tutorials/how-to-...

ef code first - Why does EF drop and create the same index? -

i have existing index (ix_itemimportsummaryid) generated foreignkey on itemimportsummary because default index naming structure. if try explicitly create index same name on id field, drop index , create again in migration script. the funny thing is, if give non-default name instead, rename index rather drop create it. seems ef stupid in scenario , doesn't realize can not @ all. public class itemimportsummarydetail { public int id { get; set; } [foreignkey("itemimportsummaryid")] public virtual itemimportsummary itemimportsummary { get; set; } [index("ix_itemimportsummaryid", isunique = false)] [index("ix_mpbid", 2, isunique = true)] public int itemimportsummaryid { get; set; } [required] [stringlength(maximumlength:10)] [index("ix_mpbid", 1, isunique = true)] public string mpbid { get; set; } } this add-migration generates: dropindex("dbo.itemimportsummarydetails", new[] { ...

dictionary - jpa 2 criteria with map key and value -

in entity have field @elementcollection @collectiontable @mapkeycolumn(name = "server_id") @column(name = "is_sync") private map<string, boolean> serversyncs = new hashmap<>(); i'm trying entities of table not have entry key equals "serverid" (passed parameter in function) or have entry value false. this i've done now criteriabuilder builder = session.getcriteriabuilder(); criteriaquery<t> criteriaquery = builder.createquery(clazz); root<t> root = criteriaquery.from(clazz); mapjoin<t, string, boolean> maproot = root.joinmap("serversyncs"); list<t> result = session.createquery( criteriaquery.where( builder.or( maproot.isnull(), builder.not(maproot.key().in(serverid)), builder.and( maproot.key().in(serverid), maproot.value().in(false) ...

c++ - Including constants without importing header file -

i have piece of code set take constant integer parameter (dimension of problem), run many different dimensions. i don't want have change hard-coded dimension every time run, ideally define several dummy header functions just: #ifndef dim_define_h #define dim_define_h const int dimension = [dimension specific header file]; #endif then when compiling use whichever header file needed instance like: g++ dimension_6.h code.cpp is such thing possible? defining constant in header file , using in file doesn't explicitly import header file? edit: my next attempt take main function only, stick along dimension definition in different file, , make copies of that. compilation looks like: g++ dim_specific_main.cpp lots.cpp more.cpp helpers.cpp and think it's making through compilation of main now, depend on helper functions defined in helper files. unfortunately when tries compile helper functions needs constant that's defined in main.h , seems have fo...

python - Activity log into Pandas Series -

i have input csv (userid, datetime) in order analyze activity of users generate pandas series index being date, , columns being users (multiple series). values sum of activities of each user aggregated on date (for instance: day). thanks in advance. fake data n = 100 np.random.seed(1) userid = np.random.randint(0, 10, n) datetime = np.random.randint(0, 10, n) + pd.timestamp('2016-1-1', freq='d') activity = np.random.randint(0,1000, n) df = pd.dataframe({'userid':userid, 'datetime':datetime, 'activity':activity}) df.head(10) datetime userid activity 0 2016-01-10 5 788 1 2016-01-01 8 44 2 2016-01-03 9 271 3 2016-01-01 5 670 4 2016-01-08 0 475 5 2016-01-02 0 910 6 2016-01-08 1 499 7 2016-01-10 7 787 8 2016-01-09 6 251 9 2016-01-05 9 666 solution df.groupby(['datetime', 'userid'])['ac...

r - Using rnorm for a dataframe -

i wanted use rnorm function on dataframe having e.g nrow=11451 elements. don't know how write code apply rnorm each row leading sim-dataframe nsim columns , nrow rows. dfsim <- rnorm (n=nsim, mean=df[[?]], sd=df[[?]]) as example: > head(df) object of class "spatiallinesdataframe" slot "data": linearid fullname rttyp mtfcc m01 sd01 nsim 10969 1104486135650 hwy 90 alt u s1200 0.0009886878 0.0001253361 10 10970 1104486135651 hwy 90 alt u s1200 0.0009831224 0.0001442643 10 10416 1102965182224 southwest fwy e acc m s1640 0.0010000000 0.0000000000 10 10494 1103342335512 robin hood ct pvt m s1780 0.0010000000 0.0000000000 10 10493 1103342334514 little john way pvt m s1750 0.0010000000 0.0000000000 10 1847 1101842210421 arrowood cir n m s1400 0.0010000000 0.0000000000 10 my expected result have ten more columns each row including simulated values. i use...

How to enable Linux namespace in system based on kernel 2.6.38 and initd? -

i want run lxc 2.0 on linux kernel 2.6.38 , init.d, whether both kernel version , initd mandatory. i have recompiled kernel namespace support follow. # kernel parameters config_namespaces=y config_cgroup_ns=y config_uts_ns=y config_ipc_ns=y config_user_ns=y config_pid_ns=y config_net_ns=y [root@ts ~]# config=$(pwd)/.config lxc-checkconfig --- namespaces --- namespaces: enabled utsname namespace: enabled ipc namespace: enabled pid namespace: enabled user namespace: enabled newuidmap not installed newgidmap not installed network namespace: enabled multiple /dev/pts instances: enabled --- control groups --- cgroup: enabled cgroup clone_children flag: enabled cgroup device: missing cgroup sched: enabled cgroup cpu account: enabled cgroup memory controller: enabled cgroup cpuset: enabled everything runs successful until hit following issue on lxc-start -n ts1 --logfile=ts1.log . lxc_start - start.c:preserve_ns:138 - no such file or directory - kernel not support attaching nam...

Use of statsmodels.imputation.mice -

i exploring statsmodels.imputation.mice package use imputing missing values. haven't seen example of usage, though, outside of http://www.statsmodels.org . gather, 1 create instance of mice.micedata , use in conjunction mice.mice().fit(). example http://www.statsmodels.org/dev/generated/statsmodels.imputation.mice.mice.html >>> imp = mice.micedata(data) >>> fml = 'y ~ x1 + x2 + x3 + x4' >>> mice = mice.mice(fml, sm.ols, imp) >>> results = mice.fit(10, 10) >>> print(results.summary()) the imputed values in instance of micedata not fixed, though. mean if imp = mice.micedata(data) every call imp.update('x1') (assuming data has column 'x1') draws new sample missing values using “predictive mean matching”. that's if use miceddata mice.fit(). however, let's want use package impute value values once, , use predictor package, sklearn, fit data. wonder, reasonable approach. can run update severa...

python - discord.py logs_from not working -

i trying lot of messages server, making test scripts, , logs_from() not working how think should, dont know if im using wrong or what, using python 3.5, , recent version of discord.py on pypi @client.event @asyncio.coroutine def on_message(message): number = 200 x = client.logs_from(message.channel, limit = number) print(x[1]) and error typeerror: 'logsfromiterator' object not support indexing client.logs_from coroutine, meaning must first await it. returns iterator, not list, should iterate through it, instead of indexing it. python 3.5 example: async def get_logs_from(channel): async m in client.logs_from(channel): print(m.clean_content) python 3.4 example: @asyncio.coroutine def get_logs_from(channel): logs = yield client.logs_from(channel): m in logs: print(m.clean_content)

html - Boostrap Resize -

the mobile boostrap resize kinda weird check image https://i.imgur.com/csnc0yl.jpg what i'm missing sizes in small monitors ins't work too you can see live in http://177.155.178.195/ thanks.

Why does this JSON code not work in Swift 3.2 -

i on final leg of first part of app. have been following tutorial exactly, every single article find has achient code. anyway, am, , receiving 2 errors have never seen before. these erors: 1. use of unresolved identifer mutablecontainers 2. argument in call any appreciated. have changed url names privacy. // send user data server side let myurl = nsurl(string: "https://www.nyserver.com/userregister.php"); let request = nsmutableurlrequest(url:myurl! url); request.httpmethod = "post"; let poststring = "email=\(string(describing: useremail))&password=\(string(describing: userpassword))"; request.httpbody = poststring.data(using: string.encoding.utf8); let task = urlsession.shared.datatask(with: request urlrequest) { data, response, error in if error != nil { print("error=\(string(describing: error))") return } var err: nserror? var json...

dns - Azure with single web app, but point different domans to it (NOT subdomains) -

Image
is possible have multiple domains pointing single azure web app? if there reason not recommended (maybe seo)? thanks. voss. yes, can have multiple domains pointing single azure web app.

Kubernetes get nodes not returning master node -

i running kubernetes on aws using centos. have 1 master node , 10 worker nodes. when kubectl nodes, not give me master node. returns 10 worker nodes though. any idea mistake doing? ok. looks issue kubeconfig on master node. pointing wrong client certificate. worked once fixed it.

linux - Why does dereferencing pointer from mmap cause memory usage reported by top to increase? -

i calling mmap() map_shared , prot_read access file 25 gb in size. have noticed advancing returned pointer has no effect %mem in top application, once start dereferencing pointer @ different locations, memory wildly increases , caps @ 55%. value goes down 0.2% once munmap called. i don't know if should trust 55% value top reports. doesn't seem using 8 gb of available 16. should worried?

string - C++ Random number generator apparent malfunction: am I unlucky? -

i wanted try c++ random number generator couldn't seem obtain satisfying results. example here attempt among others create random string of characters. #include <iostream> #include <string> #include <random> std::string f(unsigned int n){ std::uniform_int_distribution<int> dis025(0, 25); std::mt19937 gen_mt(n); std::string str(5, '\0'); for(int = 0; i<5; i++) str[i] = (char)('a' + dis025(gen_mt)); return str; } int g(unsigned int n, int m){ std::uniform_int_distribution<int> dis(0, m); std::mt19937 gen_mt(n); return dis(gen_mt); } int main() { std::string s = f(g(106175305, 40000000)) + " " + f(g(53718209, 40000000)); std::cout << "random string: " << s << std::endl; } link coliru . (i had use f(g()) trick stops shouting insults.) quite annoying , doubt desired behavior. somehow helpless prevent it, keeps happening, again... #include ...

c# - How to distinguish between a query string variable and a URL segment variable with Web API 2.0 attribute routing? -

lets have following apicontroller , method: [routeprefix("configs")] public class fullconfigcontroller : apicontroller { [route("{id}")] [httpget] public string getconfig(guid id) { return "my config data"; } } it's simple method designed return basic configuration data based on configurations id represented guid. intention call end point such http://<url>/configs/70c55eda-9671-4d75-a715-0835db8ac2e3 however not route through engine. yet this http://<url>/configs?id=70c55eda-9671-4d75-a715-0835db8ac2e3 does. how specify not want query string parameter here url segment parameter instead? edit : request webapiconfig public class routetemplatevariables { public const string pluginroot = "pluginroot"; public const string corepluginroot = "corepluginroot"; public const string additionalsegments = "additionalsegments"; } public static class webapiconfig...

How would I call a wildcard variable in python POST method? -

i still fresh python , trying web app return wildcard variable (as catch-all). here current code, functions correctly defined dictionary paths empty form responses, cant function undefined entries: def post(self): form = web.input(action=none) if session.room: if form.action: session.room = session.room.go(form.action) if not form.action: web.seeother("/") return render.show_room(room=session.room) else: web.seeother("/") here dictionary reference i'm attempting ('*' wildcard catch-all): escape_pod.add_paths({ '2': the_end_winner, '*': the_end_loser }) the_bridge.add_paths({ 'throw bomb': bridge_death, 'slowly place bomb': escape_pod, '*': the_bridge }) laser_weapon_armory.add_paths({ '132': the_bridge, '*': laser_death }) central_corridor.add_paths({ 'shoot!': shoot_death, ...

In C++, why does <cctype> define both std::isspace and ::isspace? -

and why c++ compilers able deduce type of ::isspace , implicitly convert std::function , not able std::isspace ? please see the following not compile: #include <cctype> #include <functional> template <typename functish> bool bar1(functish f) { return f('a'); } inline bool bar2(std::function<bool(char)> f) { return f('a'); } #if 1 #define ff &std::isspace #else #define ff &::isspace #endif #if 0 bool foo() { return bar1(ff); } #else bool foo() { return bar2(ff); } #endif of compilers supported compiler explorer, ellcc seems 1 std::isspace has deducibility/convertibility expect. there multiple overloads of std::isspace , 1 ::isspace . the header <cctype> declares function int std::isspace(int) , , maybe declares same function in global namespace (it doesn't have though). the header <locale> defines function template template <class chart> bool std::isspace(chart, const std::locale...

command line - Bash pipeline not working with asterisks -

this question has answer here: finding executable files using ls , grep 5 answers linux: pass command output multiple argument command 4 answers i using following pipeline: ls -f | ls *"*" in attempt find executable files since ls -f adds asterisks executable files, reason not work, why this?

google api python client - GMail API - messages().list() only returns message IDs -

the list() method returns list of message ids without other message metadata. there posts from 2014 , 2016 , official documentation states response list of user.messages resource ... is documentation wrong or there other way this? understand bringing entire message in "list" call not efficient rest api call - maybe returning "some" metadata make sense (e.g. output of service.users().messages().get(..., format='metadata')) opposed making call list() , then, every message, make get(..., format='metadata') thanks! m

Printing data at the end of a nested while loop [BASH] -

i'm hoping stack can save me ... again ... here's code -- below explain how can save me! #!/bin/bash while ifs= read -r input <&3 if [[ "$input" =~ ^(\/path\/to\/my\/file\/)(foo[0-9]{2}\.bar\.[0-9]{14}\.baz)$ ]] file="${bash_rematch[2]}" else echo "unknown input!" exit 1 fi printf "\n\n%s" "reading input ($file) ... " while ifs= read -r line if [[ "$line" =~ ^(v22200)(.*)$ ]] #version 2.2 if [[ "$version" = "2.2" ]] && [[ "$column082" =~ ^(pp)([a-z0-9]{3})([0-9]{6})$ ]] if [[ "${bash_rematch[2]}" = "foo" ]] output_path="/path/to/my/file/${file}_${bash_rematch[2]}_${version}${ext}" ...

c++ - Qt SplashScreen w/ Fading Logo Not Running Animation -

i creating loading screen app , want implement 2 qlabels (background , overlay) in overlay glowing outline of background. want overlay fade in opacity (0.0 - 1.0) use qpropertyanimation windowopacity property label, nothing works this. here full source code. main.cpp: #include "mainwindow.h" #include "imagefade.h" #include <qapplication> #include <qsplashscreen> #include <qtimer> #include <qhboxlayout> #include <qlabel> int main(int argc, char *argv[]) { qapplication a(argc, argv); qsplashscreen *splashscreen = new qsplashscreen(); splashscreen->resize(500, 500); qpixmap bkgdimage(":/files/images/launch/launch.png"); qpixmap ovlyimage(":/files/images/launch/launch-glow.png"); imagefade *imagelabel= new imagefade(splashscreen); imagelabel->setbackgroundimage(bkgdimage); imagelabel->setoverlayimage(ovlyimage); imagelabel->startanimation(5000); splashscre...

jquery - How to tell which Tab is currently open? Wet-Boew plugin -

i using tabbed interface wet-boews toolkit ( http://wet-boew.github.io/v4.0-ci/docs/ref/tabs/tabs-en.htm l) after page has loaded, how can determine tab open. i have tried below strangely return true <div class="wb-tabs"> <div class="tabpanels"> <details id="details-panel-panel1"> <summary>example 1</summary> <p> ... </p> </details> <details id="details-panel-panel2"> <summary>example 2</summary> <p> ... </p> </details> </div> </div> var panel1 = ($("details-panel-panel1").attr("open")) ? true : false; var panel2 = ($("details-panel-panel2").attr("open")) ? true : false; two tips: to element id nee...

Group a list of Object arrays by timestamp in Java -

i have list < object[]> , 1 of columns in object[] localdatetime. other columns location (string) , item price (double). basically, list looks this: 2017-01-01 02:05:00 newyork 26.89 2017-01-01 02:10:00 newyork 72.00 2017-01-01 02:15:00 newyork 73.10 2017-01-01 02:20:00 newyork 70.11 2017-01-01 02:25:00 newyork 79.90 2017-01-01 02:30:00 newyork 72.33 2017-01-01 02:35:00 newyork 75.69 2017-01-01 02:40:00 newyork 72.12 2017-01-01 02:45:00 newyork 73.09 2017-01-01 02:50:00 newyork 72.67 2017-01-01 02:55:00 newyork 72.56 2017-01-01 03:00:00 newyork 72.76 2017-01-01 02:05:00 boston 26.89 2017-01-01 02:10:00 boston 42.00 2017-01-01 02:15:00 boston 23.10 2017-01-01 02:20:00 boston 77.11 2017-01-01 02:25:00 boston 49.92 2017-01-01 02:30:00 boston 72.63 2017-01-01 02:35:00 boston 73.19 2017-01-01 02:40:00 boston 76.18 2017-01-01 02:45:00 boston 83.59 2017-01-01 02:50:00 boston 76.67 ...

swift3 - Use of unresolved identifier 'emailTextField' in SignUpViewController.swift -

import uikit import firebaseauth import firebasedatabase class signupviewcontroller: uiviewcontroller { @iboutlet weak var usernametextfield: uitextfield! @iboutlet weak var emailtextfield: uitextfield! @iboutlet weak var passwordtextfield: uitextfield! @iboutlet weak var profileimage: uiimageview! var selectedimage: uiimage? @ibaction func dismiss_onclick(_ sender: any) { dismiss(animated: true, completion: nil) } override func viewdidload() { super.viewdidload() profileimage.layer.cornerradius = 60 profileimage.clipstobounds = true let tapgesture = uitapgesturerecognizer(target: self, action: #selector(signupviewcontroller.handleselectprofileimageview)) profileimage.addgesturerecognizer(tapgesture) } func handleselectprofileimageview() { print("tapped") } override func didreceivememorywarning() { super.didreceivememorywarning() // dispose ...

html - javascript not bringing user to redirected page -

hi im trying build user gets re directed new page here's code var blue = ["question1button1", "question1button2"]; var secondquestion = ["question2button1", "question2button2"]; var button1, button2, button3, button4 = false; function myfunction() { var favorite = blue[math.floor(math.random() * blue.length)]; var postmessage = favorite; document.getelementbyid("mybtn").value; document.getelementbyid("demo").innerhtml = postmessage; if (postmessage == "test"){ button1 = true; alert("test"); } if (postmessage == "test1"){ button2 = true; alert("test1"); } if (postmessage == "test2"){ button3 = true; alert("test2"); } if (postmessage == "test3"){ button4 = true; alert("test3"); } } function next(){ if(bu...

Nesting grids and frames in tkinter and python -

Image
i'm trying set grid inside of frame in larger grid structure. i've tried distill simplest version of problem. from tkinter import tk, frame, label, entry root = tk() root.geometry('800x800') frame1 = frame(root, width=400, height=400, background="blue") frame2 = frame(root, width=400, height=400, background="red") frame1.grid(row=0, column=0) frame2.grid(row=1, column=1) label1 = label(frame1,text='label1') label1.grid() instead of placing label inside of frame1, label replaces frame in overall grid: i've looked @ other examples, haven't been able identify why work , mine not. the width= , height= of frame apply when has no children. once child widgets added, resizes fit contents. frame1 still there, it's same size as, , entirely covered by, label. to turn off auto-resizing behavior, call .grid_propagate(0) on frame (or .pack_propagate(0) , depending on geometry manager being used frame's ch...

java - Issue in the TESTNG program when I use "Priority" tag -

code: program using @test method priority tags. package testng1; import static org.testng.assert.assertequals; import org.openqa.selenium.webdriver; import org.openqa.selenium.ie.internetexplorerdriver; import org.testng.assert; import org.testng.annotations.test; @test public class testng { public static webdriver driver; public void verifytitle() { system.setproperty("webdriver.ie.driver", "c:\\users\\rprem\\downloads\\iedriverserver_x64_3.4.0\\iedriverserver.exe"); webdriver driver = new internetexplorerdriver(); driver.navigate().to("https://google.com"); string title = driver.gettitle(); system.out.println(title); assert.assertequals(title, "google"); } @test (priority = 1) public void verifytitle2() { driver.get("https://gmail.com"); string titlee = driver.gettitle(); assert.assertequals(titlee, "gmail - free storage , email...

emu8086 - Why does the following 8086 assembly code can only display numbers upto 2559? -

what trying ? i want 16bit number user , print on console. what problem ? well code works fine til number entered less 2600 movement enter 2600 displays "40" , 2601 "41" , on. shouldn't display numbers upto 65535 ? because storing value in bx register 16bit , stores @ 65535. why 2559 ? my code: .model small .data msg db 10,13,'enter 16bit number: $' newline db 10,13,'$' .code main: mov ax, @data mov ds, ax mov cl, 10 mov bx, 0 mov ah, 09h lea dx, msg int 21h call get16bitnum mov ah, 09h lea dx, newline int 21h mov ax, '$' push ax mov ax, bx store: div cl cmp al, 0 mov bh, 0 mov bl, ah push bx je continue mov ah, 0 jmp store continue: pop ax cmp ax, '$' je ext mov bx, ax mov ah, 02h mov dx, bx add dx, 48 int 21h jmp continue ext: mov ah, 04ch int 21h proc get16bitnum aggregate: mov ah, 01h int 21h cmp al, 13 je return mov ah, 0 sub al, 48 mov d...

java - What is a NullPointerException, and how do I fix it? -

what null pointer exceptions ( java.lang.nullpointerexception ) , causes them? what methods/tools can used determine cause stop exception causing program terminate prematurely? when declare reference variable (i.e. object) creating pointer object. consider following code declare variable of primitive type int : int x; x = 10; in example variable x int , java initialize 0 you. when assign 10 in second line value 10 written memory location pointed x. but, when try declare reference type different happens. take following code: integer num; num = new integer(10); the first line declares variable named num , but, not contain primitive value. instead contains pointer (because type integer reference type). since did not yet point java sets null, meaning "i pointing @ nothing". in second line, new keyword used instantiate (or create) object of type integer , pointer variable num assigned object. can reference object using dereferencing operator . (a dot...

linux - Script to count files (Bash) -

i trying create script goes through archive location , counts how many files there are. this have far. #!/bin/bash archive_location="location/archive/" count=0 files in $archive_location/* $archive_location/.* count=$($count+1) done echo "file count: " $count when run file line 8: 0+1: command not found & line 8: +1: command not found please me. first time creating bash script. you run find through wc find /path/to/search -type f | wc -l edit: since need write loop need correct counter 1 of following: count=$((count+1)) or let count=$count+1 or performance declare count integer , can use += operator: declare -i count count+=1

ios - I want to set navigation color to different colors for each VC -

i have code change vc nav bar color of choice changes "home" nav bar color think need have if statements check ones should colored. how write "if view controller color. else blah blah blah?" one solution add code in each view controller's viewwillappear method updates nav bar appearance needed. way, each view controller appears, sets how things should look. override func viewwillappear(_ animated: bool) { super.viewwillappear(animated) // update colors needed view controller }

javascript - Switch between icons when using FontAwesome 5.0 SVG Framework -

i'm looking able switch between icons in javascript while using new fontawesome svg framework. previously in old webfont method, achieved toggling or changing class on tag, these rendered svg's in source code no longer works. is there way without needing render both svg icons in source code , using additional classes/css toggle display?

r - ggplot version of dotplot -

Image
curious how plot dotplot using ggplot or plotly library functions. label mpg values on individual dots. # dotplot: grouped sorted , colored # sort mpg, group , color cylinder x <- mtcars[order(mtcars$mpg),] # sort mpg x$cyl <- factor(x$cyl) # must factor x$color[x$cyl==4] <- "red" x$color[x$cyl==6] <- "blue" x$color[x$cyl==8] <- "darkgreen" dotchart(x$mpg,labels=row.names(x),cex=.7,groups= x$cyl, main="gas milage car models\ngrouped cylinder", xlab="miles per gallon", gcolor="black", color=x$color) with quick clean of rownames column can following. we used factor() aesthetics color becomes discrete/ when faceting acheive need specify "free_y" scale , space . base library(tidyverse) mtcars2 = rownames_to_column(mtcars, "car") ggplot(mtcars2, aes(x = mpg, y = factor(car), color = factor(cyl))) + geom_point(shape = 1) + facet_grid(cyl ~ ., s...

DHCP library in c/c++ -

i’m searching c/c++ library can parse dhcp packets received linux sockets create own dhcp packets. linux has library handling dhcp packets or there third party library that? i’ve found nothing on google, neither in stack overflow questions.