Posts

Showing posts from March, 2010

python - Best way to join two large datasets in Pandas -

i'm downloading 2 datasets 2 different databases need joined. each of them separately around 500mb when store them csv. separately fit memory when load both memory error. trouble when try merge them pandas. what best way outer join on them don't memory error? don't have database servers @ hand can install kind of open source software on computer if helps. ideally still solve in pandas not sure if possible @ all. to clarify: merging mean outer join. each table has 2 row: product , version. want check products , versions in left table only, right table , both tables. pd.merge(df1,df2,left_on=['product','version'],right_on=['product','version'], how='outer') this seems task dask designed for. essentially, dask can pandas operations out-of-core, can work datasets don't fit memory. dask.dataframe api subset of pandas api, there shouldn't of learning curve. see dask dataframe overview page additional data

bluetooth lowenergy - Can all BLE slaves receive a "trigger" message at the same time? -

we have 10 sensors (with analog digital converter) ble slaves, , slaves triggered master sensors can start sampling @ same time. possible ble? if not, smallest latency (or time skew) between 2 slaves getting triggered? the best way first connect 10 devices short connection interval (like 10 ms or whatever). once done, send write commands 10 of them @ same time. long bluetooth controller can fit 10 enqueued packets, of them sent in next connection event each ble slave. time skew within connection interval.

r - long to wide with out timevar -

this question has answer here: transpose / reshape dataframe without “timevar” long wide format 6 answers i move data.frame long wide. whenever have duplicate id, want copy results in particular var new col. in end want id unique id. have looked @ using reshape function - can't seem how handle not having "timevar" - in particular case, don't have grouping var want reshape based on. there ton on stack overflow reshaping data can't seem find issue. i have: a<- data.frame( id = c( 11,12,13,14,15,15,16,17,17,18,19,10) , pi = c( 21:32 ) ) i want b<- data.frame( id = c( 11,12,13,14,15,16,17,18,19,10) , pi = c( 21:25,27:28,30:32 ), pi2 = c( na,na,na,na,26,na,29,na,na,na) ) you can in few steps: bb <- aggregate(pi~id, data=a, fun=c) cols <- max(sapply(bb$pi, len

sql - parent-child data alignment -

Image
i have stored procedure presents inventory data , standard format , not consider parent-child relationship. current view of data along many other columns: i'm trying bring parent/child relationship in report. i've modified queries bring in parent/child data in. data needs presented in specific way. pic below: basically, need list each parent first followed child records. find these records child display on parent row. the min of child "1st receipt date", max of child "last receipt date", sum of child "on hand" sum of child "sales unit" mths supply calculated total on hand , sales units i have no clue how arrange data in manner. appreciate direction. thanks in advance. -- section stage sample data -------------------------------------------------------------------------------------------------------- declare @inv table (sku int,firstreceiptdate date,lastreceiptdate date,onhand int,salesunits int) insert @inv (s

hadoop - importing compressed (gzip) data from s3 to hive -

i have bunch of .gzip files in s3://mybucket/file/*.gzip. i loading table using: set hive.exec.dynamic.partition=true; set hive.exec.dynamic.partition.mode=nonstrict; set hive.exec.max.dynamic.partitions.pernode=1000; set hive.enforce.bucketing = true; set hive.exec.compress.output=true; set io.seqfile.compression.type=block; set mapred.output.compression.codec=org.apache.hadoop.io.compress.gzipcodec; create external table db.tablename(col1 dataype,col1 dataype,col1 dataype,col1 dataype) partitioned (col datatype) clustered (col2) sorted (col1,col2) 200 buckets row format delimited fields terminated '\t' lines terminated '\n' location 's3://mybucket/file'; it creates table doesn't load data s3 hive/hdfs. any appreciated? thanks sanjeev i think files present in s3://mybucket/file/ not organized in correct directory structure hive partitions. suggest create external table without partitions , buckets on s3://mybucket/file/ , write h

bootstrap modal as the login page for spring security -

in web app, have login/registration part bootstrap modals appears when login icon in header clicked. i'm trying configure in spring security, see have return page in config method: @override protected void configure(httpsecurity http) throws exception { http .formlogin().loginpage("/login") .and() ... } my question how implement modal login page instead of full html page. i'm using spring mvc 4 spring security 4 , thymeleaf edit: in header in html pages: <div class="col-xs-7 col-sm-4"> <div class="top-social-last top-dark pull-right" data-toggle="tooltip" data-placement="bottom" title="login/register"> <a class="top-icon-circle" href="#login-modal" data-toggle="modal"> <i class="fa fa-lock"></i>

facebook api explorer do not retrive email address -

i'm trying implement signin/-up via facebook, not receive email address on request. sure, i've grabbed email permission before, no success. tried fb graph api explorer , again private account. yes, access token email permission, no email delivered, instead "field empty or disallowed access token". access token? created, email permission. empty? how be, when required on signup? using different account of friend, worked charm. depend on account settings? even if permissions given, user can turn platform off in apps settings. check settings , permissions app showing, here: https://www.facebook.com/settings?tab=applications&section=opt_out&view if alright, can follow discussion: register facebook doesn't provide email

c++ - Template Method 'For Loop' to Reverse Vector -

i have method reverses objects of vector. want able use method regardless of data type, i'm using template. ex : " 1 2 3 4 " becomes " 4 3 2 1" & "how brown cow" becomes "cow brown how" this current template method.(full code added copy , paste purposes) #include "stdafx.h" #include <iostream> using namespace std; template <class t> void fillvector(vector<t>& vect, const t array[], int size) { (int index = 0; index < size; ++index) vect.push_back(array[index]); } template<class t> void reverse(vector<t>& vect) { if (vect.empty()) { throw emptyvectorexception(); } else { int endval = vect.size(); (int x = 0, y = endval-1; x < (endval / 2); x++, y--) { t temp = vect[x]; vect[x] = vect[y]; vect[y] = temp; } } } template<class t> void output(const vector<t>

javascript - Post data to current php page with ajax -

i want post data current page ajax.but couldnt that. i have doctor panel , wanna patient's data 'hastalar' table in db using patient's national id:'tc'.session using doctor guess cant use $_session patient @ same time.and wanna use 1 php page.so cant see patient's datas in current page.pls me guys. dokyon.php textbox <a href="#" id="ara" class="ara" ><br/>search patient</a> <input type ="text" id="tc" name="tc" /> jquery <script type="text/javascript" > $(function() { $(".ara").click(function(){ var tc = $('#tc').val(); $.ajax({ url:'dokyon.php'//current page type: 'post', data:{tc:tc}, success: function(){ alert(data); } }); }); }); </script> php codes <?php

Multiple transpose in R -

i have data.frame this: country country b country c country d 123 567 789 101 asd dfa dgf fgh i want convert this: country 123 asd country b 567 dfa country c 789 dgf country d 101 fgh data.frame contains lot of row, can't subset according rownames. t function convert this: country countryb countryc countryd 123 567 789 101 asd dfa gf fgh so, t not useful want. one way of splitting data frame using matrix. i'll assume know final number of columns (ncols). # data frame example df = data.frame(x = c("country a","country b","country c","country d", "123","567","789","101","asd","dfa","dgf","fgh"),stringsasfactors = f) # ncols: known number of columns ncols = 3 df = data.frame(matrix(df$x, dim(df)[1]/ncols, ncols), stringsasfactors = f) result: > df x

android - Can layout_gravity override parent gravity? -

does gravity setting set parent override layout_gravity settings set children? seems when try it. there way bypass behaviour? use linearlayout global gravity, want 1 element aligned bottom always. i don't want relativelayout. <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:gravity="center_horizontal"> <textview android:id="@+id/textview_error_message" android:layout_width="match_parent" android:layout_height="wrap_content"/> <button android:id="@+id/button_next" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" android:text="@string/button_next" /> </linearlayout>

javascript - Replace Text in a Div with text in another Div -

<div id="replaceme">i'm girl</div> <div id="iamreplacement" style="display:none">no boy girl</div> the text in replaceme should replaced text in iamreplacement i think can done in java script or jquery.. can 1 me on this.. tried (not working) <script> jquery('#replaceme').replacewith(jquery('#iamreplacement')); </script> try jquery: $("#replaceme").html($("#iamreplacement").html()); or pure javascript: document.getelementbyid("replaceme").innerhtml = document.getelementbyid("iamreplacement").innerhtml;

r - How to add axis to map in cylindrical equal area projection? Why are the polygon lines at the border stretched out? -

Image
goal add axis labels coordinates @ 30deg latitude, 60deg longitude. fix polygon lines, around ~west asia, eastern europe. question 1 i not know scale of axis when specify cylindrical equal area projection. (-180 180 ~ -3.1 3.1 , -90 90 ~ 1 1?) question 2 how can fix world map polygon distorted around west asia or eastern europe? wrap = true fixed of polygon issues 1 remains. sample library(mapproj) library(maps) # world map, cylindrical equal area projection map(database= 'world', xlim=c(-180,180), ylim=c(-90,90), projection='cylequalarea', parameters = 0, fill=t, col="#f2f2f2", bg="white", lty=1, lwd=1, orientation=c(90,0,225), resolution=0, wrap=t, ) # default axis map.axes() # desired axis axis(1, at=c(-120,-60,0,60,120), labels = c('-120','-60','0','60','-120'), pos=-90) map here works me: cyleqareamap <- function(){ library(mapproj) library(maps) # world

ios - Notify UITableViewController when cell is programmatically selected -

Image
my table view allows multiple cell selection, each cell sets selected when button inside cell has been clicked (similar gmail app does, see picture below). looking way let uitableviewcontroller know cells have been selected or deselected, in order manually change uinavigationitem . hoping there way using delegate methods, cannot seem find one. didselectrowatindexpath handling clicks on cell itself, , should not affect cell's selected state. the straight forward way create our own delegate protocol cell, uitableviewcontroller adopt. when dequeue cell, set delegate property on cell uitableviewcontroller instance. cell can invoke methods in protocol inform uitableviewcontroller of actions occurring , can update other state necessary. here's example code give idea (note did not run compiler, there may typos): protocol articlecelldelegate { func articlecelldidbecomeselected(articlecell: articlecell) func articlecelldidbecomeunselected(articlecell:

How do you get a file from a windows host to linux docker container? -

i've been trying things like docker run -t -i -v c/my-project:/usr/share/my-project mp /bin/bash (mp name of container) and docker run -t -i -v c/my-project:/usr/share/my-project:z mp /bin/bash, but while directory my-project created in docker image, empty despite fact directory not empty in windows. i've resorted adding files in dockerfile build run mkdir , add c/my-project sub-optimal. you cannot host linux docker containers directly on windows. there linux vm host 'docker machine'/boot2docker created you. have transfer files vm. i don't recommend using docker machine due frustrations ip , filesystem mapping. explicitly create own linux vm , manage docker way.

jquery - my express page only loads once and fails the second time -

i have express page updates doc in mongoose database when receives post request jquery post request, , does, once , when enter doc fails. mongoose collection has 2 docs in collection location vancouver. jquery page $("#sendover").click(function(){ var settings = json.stringify({ type : $("#type option:selected").text(), productname : $("#name").val(), collectionname : $("#groupings option:selected").text(), segment : $("#segment option:selected").text(), levels : $("#levels option:selected").text() }); console.log(settings); $.ajax('/logic', { type: 'post', contenttype: 'application/json', datatype: 'json', data: settings }).done(function () { console.log('message saved successfully'); }).fail(function (err) { console.log('failed save mess

javascript - Can an HTML5 notification fire from an inactive tab and play an audio alert? -

say, want play beep.mp3 on hour wrote javascript code this, not hard. when user switches tab, , page becomes living in inactive tab, won't hear audio alerts more. is there remedy this? if include audio in html can play using javascript, if browser tab inactive. <body> <audio id="beep" src="audio source file" preload="auto" ></audio> <script> function playbeep() { document.getelementbyid("beep").play(); } playbeep(); </script> </body>

javascript - 2 Versions of JQuery on 2 different places conflicting? -

so got website it's not working since have 2 different jquery's loaded , when remove 1 line function not work anymore. <link href="social-traffic-pop.css" rel="stylesheet" type="text/css" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script> <script src="http://connect.facebook.net/en_us/all.js#xfbml=1"></script> <script src="http://platform.twitter.com/widgets.js" type="text/javascript"></script> <script src="jquery.stp.js" type="text/javascript"></script> and other one: <!-- javascript --> <script type="text/javascript" async="" src="ga.js"></script><script src="jquery.min.js"></script> <script src=&q

Qt C++ Modulo Operator Failing -

this question has answer here: how code modulo (%) operator in c/c++/obj-c handles negative numbers 15 answers this simple issue overlooking. writing in c++ on qt , working on ciphers. have use %26 in order them working. tested this: qdebug() << (6-18)%26; , according internet , math, should produce me number 14, right? no. -12 6-18 is, don't know if modulo isn't being applied of what. appreciated. you right on this: 6-18 = -12 when divide: -12/26 = 0.46 with modulus = 4 i hope you.

avfoundation - Sound board Swift 2 -

Image
i trying make sound board app in swift , 3 out of 4 buttons crash app , other 1 nothing. doing wrong? new programming , trying follow tutorial doesn't work. import avfoundation import uikit class firstviewcontroller: uiviewcontroller { let soundfilesname = ["tacos", "what's supposed mean", "cube fist man", "giraffe"] var audioplayers = [avaudioplayer]() override func viewdidload() { super.viewdidload() //set audio player sound in soundfilesname { do{ //try , somthing let url = nsurl(fileurlwithpath: nsbundle.mainbundle().pathforresource(sound, oftype: "mp3")!) let audioplayer = try avaudioplayer(contentsofurl: url) audioplayers.append(audioplayer) } catch{ //catch error thrown audioplayers.append(avaudioplayer()) } } } @

c++ - Can't understand wrong answer in graphing program -

there problem in have points on graph (~100 of them) , rotate amount, except 1 of them. tackle problem taking distances center of first set of points, , distances center of second set, then, after comparing them, 1 set not have matching distance--which wrong point. #include <iostream> #include <cmath> #include <math.h> using namespace std; int main() { int star1, star2; cin>>star1; int x1[star1], y1[star1]; (int i=0; i<star1; i++) {cin>>x1[i]>>y1[i];} cin>>star2; int x2[star2], y2[star2]; (int i=0; i<star2; i++) {cin>>x2[i]>>y2[i];} int d1[star1], d2[star2]; (int i=0; i<star1; i++) {d1[i]=sqrt(x1[i]*x1[i]+y1[i]*y1[i]); d2[i]=sqrt(x2[i]*x2[i]+y2[i]*y2[i]); } int dis=0; //the ones furthest center gone if (star1>star2) {for (int i=0; i<(star1-star2); i++) {if (d1[i]<d1[i+1]) {dis=i+1;} } (int = dis; < star1; i++) {d1[dis] = d1[dis+1]; d1[star1-1] = 0;} } else if (star2>star1) {for (int i=0;

Swift Extensions from Objective-C Protocol -

so using objective-c library makes use of mkmapview . there class: @interface bsweathermapview : mkmapview /** receiver’s delegate. */ @property (nonatomic, weak) id<bsweathermapviewdelegate> delegate; its protocol defined method: @protocol bsweathermapviewdelegate<mkmapviewdelegate> @optional - (mkannotationview *)mapview:(bsweathermapview *)mapview viewforannotation:(id<mkannotation >)annotation; my swift class has extension doing following: extension viewcontroller : bsweathermapviewdelegate { func mapview(mapview: bsweathermapview!, viewforannotation annotation: anyobject) -> mkannotationview! {} } when following error: objective-c method mapview:viewforannotation: provided method mapview(_:viewforannotation:) conflicts optional requirement method mapview(_:viewforannotation:) in protocol mkmapviewdelegate i have no clue how past this... anyone? thanks, the problem objective-c declaration illegal: @protoc

jquery - Bootstrap 3.3.x, how to get correct order of menu items for navbar when collapsed? -

bootstrap newbie using 3.3.6, , having trouble creating simple navbar based on example twitter provides in documentation. code show below sets navbar has 2 menu items on top right corner. large screens, looks like: brand menu 1 menu 2 but when collapse navbar smallest screen, shows: brand menu 2 menu 1 how collapsed order be: brand menu 1 menu 2 ? <nav class="navbar navbar-default navbar-static-top navbar-default-siteheader navbar-inner-siteheader"> <div class="container-fluid"> <!-- brand , toggle grouped better mobile display --> <div class="navbar-header" > <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"> <span class="sr-only">toggle navigation</span> <span

Select all fields with group by clause in Ms. Access -

i have table contain checktime, userid, , checktype. checktime type datetime. want these data without duplicate checktime date. example data this: userid | checktime | checktype 1 | 2016-05-01 06:58:00 | 1 | 2016-05-01 06:59:00 | 1 | 2016-05-02 06:58:00 | 1 | 2016-05-02 06:58:10 | 1 | 2016-05-02 06:59:00 | does know how remove duplicate date? so, above data, can result this: userid | checktime | checktype 1 | 2016-05-01 06:58:00 | 1 | 2016-05-02 06:58:00 | i tried use distinct, doesn't works, because have different time each checktime. , use group clause, can give me result 1 field. my query right this: select userid, checktype, checktime, day(checktime) checkinout userid = 259 , month(checktime)='5' , year(checktime)='2016' , checktype = 'i' group day(checktime) order day(checktime) asc and cames error aggregate function. do need time? select distinct userid, format([che

javascript - Phaser sprite map positioning -

i have map laid out fills entire screen. understand how add sprite on map , give coordinates, var thumb = game.add.sprite( 100, 100 , "levelthumb"); but wanted know if following possible. can add lets 15 of same sprite on map giving each 1 specific coordinates. i know can done loop , passing in random x , y exmaples http://phaser.io/examples/v2/groups/add-a-sprite-to-group want give them specific coordinates each one. for wonder how solved helped me it. function create() { lumpofsprites = game.add.group(); lumpofenemies = game.add.group(); function spritepositioning(x, y){ //pass in x&y coordinates when calling this lumpofenemies.create(x, y, 'imagenamehere'); //enter image name here or set parameter } spritepositioning(100,400); spritepositioning(0,400); spritepositioning(500,100); spritepositioning(424,432); spritepositioning(216,200); spritepositioning(500,578); var theplayer = game.add.sprite(300, 240, 'imgnamehere'

winforms - Updating a datagridview from a button in other form C# -

i have forms, form1 , form2. in form1 have datagridview loads data database, 2 buttons, 1 filter , add row datagridview. in form2 have comboboxes, textboxes, radiobuttons, , 4 buttons, 1 adds data, 1 remove selected row(when double clic row in datagridview form2 loaded info row), 1 cancel(close form), , last 1 update selected row modified info. but problem i'm stucked there, don't know how update same row. i'm able add new 1 or erase one. i'm working on c# entity framework. may me on how update selected row form? i tried modifying code use when double clic datagridview load data in form2: inspeccion inspeccio = new inspeccion(); inspeccio.id =int32.parse(txtnumtransaccion.text); inspeccio.vehiculo = int32.parse(cbxidvehiculo.text); inspeccio.cliente= int32.parse(cbxidcliente.text); inspeccio.ralladuras = ralladuras().tostring(); inspeccio.cantidad_combustible = cbxcombustible.text.tostring(); inspeccio.repuesta = repuesta().tostring(); inspeccio.gato = g

signal processing - Unexpected fundamental hum in audio demonstration -

i trying create spectral audio demonstration using web audio api's periodicwave generator. can seen here: http://orazdow.github.io/bars/ whenever have fair amount of partials turned on sound dominated loud buzzy hum @ fundamental. i wasn't expecting , understand cause. hoping generate similar pure data's fourier resynthesis example, can seen here @ section 3.8.2, pure tones rather filtered noise. writing values real part array. the dominating tone not expected or wanted, hoping understand causing it. i think oscillators doing what's intended. if have flat spectrum (which have in demo default except it's band-limited), signal should approximately pulse train (periodic signal of impulses). i think if create such periodic sequence of impulses , listen, sound oscillators.

c++ - Template functions in namespace cause errors -

assume following code: #include <iostream> template<typename t> struct link { link(t&& val) : val(std::forward<t>(val)) {} t val; }; template<typename t> std::ostream& operator<<(std::ostream& out, const link<t>& link) { out << "link(" << link.val << ")"; return out; } template<typename t> auto makelink(t&& val) -> link<t> { return {std::forward<t>(val)}; } namespace utils { template<typename any> constexpr auto removelinks(const any& any) -> const any& { return any; } template<typename t> constexpr auto removelinks(const link<t>& link) -> decltype(removelinks(link.val)) { return removelinks(link.val); } } /* utils */ int main() { int k = 10; auto link = makelink(makelink(k)); std::cout << link << std::endl; std::cout << utils::removelinks(link) <<

java - How to convert JsonNode to Map -

using play framework java on server i'm using graphiql make requests, when final jsonnode variables = request().body().asjson().get("variables") , jsonnode value "{\"id\":\"bar\"}" , want convert jsonnode map, tried json.mapper().convertvalue(variables, new typereference<hashmap<string, object>>() { }); but keep getting exception caused by: com.fasterxml.jackson.databind.jsonmappingexception: can not instantiate value of type [map type; class java.util.hashmap, [simple type, class java.lang.string] -> [simple type, class java.lang.object]] string value ('{"id":"bar"}'); no single-string constructor/factory method @ [source: n/a; line: -1, column: -1] what doing wrongly? how convert jsonnode map? change type reference use map interface instead of hashmap class. new typereference<map<string, object>> . update: also, said json node has value "{\"

c# - How do I keep my async method from blocking the UI? -

so i'm writing method supposed process large amount of strings , update ui every string processed. i'm using async-await pattern using progress reporter reports string main thread supposed updated. problem is: doesn't work. ui gets blocked if method running synchronously, though used await keyword. here's code looks like: private async task processfile(string filepath, iprogress<string> progress) { string[] linestoprocess = file.readalllines(filepath); int linecount = buffer.count(); await task.factory.startnew(() => { (int = 0; < buffer.count(); i++) { //do actual processing here progress.report(string.format("lines processed: {0} / {1}", i, linecount)); } }); } and here's method calling processfile task private async task runtask() { string filepath = //get filepath somehow await processfile(filepath, n

javascript - Radio Button Change not detected in JQuery -

can please me out, why change not being detected here radio button form - <form style = "padding:10px; margin:5px;" id="askmethod"> select option: <input type="radio" name="method" value ="textmethod" checked = "checked">type text <input type="radio" name="method" value ="imagemethod">upload image </form> here jquery routine - $(document).ready(function() { $('input [type=radio][name=method]').on('change', function() { switch ($(this).val()) { case 'textmethod': alert("text"); break; case 'imagemethod': alert("image"); break; } }); }); please use change bellow $('form#askmethod [type=radio][name=method]').change(function() { switch($(this).val()) { case 'text

Where are the Android icon drawables within the SDK? -

in design of ui of android applications, need drawables icons. where existing drawables located within android sdk? in android.r.drawable , read more here : http://docs.since2006.com/android/2.1-drawables.php simple resource usage : android:icon="@android:drawable/ic_menu_save" simple java usage : mymenuitem.seticon(android.r.drawable.ic_menu_save);

Add 1000 Constraints in linear programing using R lpSolve -

i'm trying implement big linear model, i'm having problem add more variables/constraints. example, want add constraints without adding others zeros (0) in matrix (f.con) in example: library(linprog) f.obj <- c(3,24,79,140,230,306,338, 26,78,145,226,309,336,354, 146,250,312,364,417,496,508, 314,382,424,472,503,525,548) f.con <- matrix (c(1,1,1,1,1,1,1, 0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 1,1,1,1,1,1,1, 0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 1,1,1,1,1,1,1, 0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,0,0,0,0,0,0, 1,1,1,1,1,1,1) ,nrow=4, byrow=true) f.rhs <- c(10,22,8,30) f.dir <- c("<=", "<=","<=","<=") lp ("max", f.obj, f.con, f.dir, f.rhs) n<-lp ("max", f.obj, f.con, f.dir, f.rhs)$solution n thank you! i pres

c - Weird result from a macro while using pre-increment and post-increment operators -

this question has answer here: why these constructs (using ++) undefined behavior? 13 answers i 12 , 49 code #include <stdio.h> #define product(a) a*a int main() { int = 3, j, k; j = product(i++); k = product(++i); printf("%d %d\n", j, k); return 0; } if instead of using macro use function 9 , 25, expect... can explain why happen? if expand macro, line j = product(i++); becomes j = i++*i++; and line k = product(++i); becomes k = ++i*++i; both these lines subject undefined behavior. can try make sense of 1 run of program results not guaranteed same different compiler or same compiler different compiler flags. when use function call instead of macro, behavior of code more straight forward. line j = product(i++); is equivalent to: int temp = i; j = product(temp); i++; the line k = product

etw - Not able to find the custom event -

Image
i following sample provided here use custom event source. however, after run sample, there no event message found in event viewer figure below: did have idea? you need capture events tool: with xperf : "c:\program files (x86)\windows kits\10\windows performance toolkit\xperf.exe" -start userlogger -on guid -f user.etl && timeout -1 && "c:\program files (x86)\windows kits\8.1\windows performance toolkit\xperf.exe" -stop userlogger change guid own with perfview : perfview /onlyproviders=*mycompanyeventsource collect create own wprp profile , add entry log mycompanyeventsource events , run wrp -start myprofile.wprp && timeout -1 && wpr -stop result.etl use eventlistener class listen events in own code use traceevent , start realtime session , subscribe dynamicall event , parse here mycompanyeventsource data. what want write eventlog , have set event channel attribute

google maps - How to get photo location by latitude and longitude in android? -

how photo location latitude , longitude in android? lat , lon, want fetch photo location lat , lon before. the places api supports return of 1 place photo if available place search request , ten place photos place details request. if photos array returned request, can pass photo_reference contained photo object place photo request maxheight and/or maxwidth, sensor , key parameters: here great tutorial: showing nearby places photos @ location in google maps android api v2

javascript - Data not appending to element in Handlebars.js -

<!doctype html> <html> <head> <meta charset=utf-8 /> <title>js bin</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript" charset="utf-8"></script> <script src="http://cloud.github.com/downloads/wycats/handlebars.js/handlebars-1.0.0.beta.6.js" type="text/javascript" charset="utf-8"></script> <script src="app.js" type="text/javascript" charset="utf-8"></script> </head> <body> <ul> <script id ="ajaxtemplate" type="text/x-handlebars-template"> {{#each}} <li> <span class="meta">{{name}} on {{date}}</span> <p>{{comment}}</p> </li> {{/each}} </script> </ul> <script> $(document).ready(function(){ //document.write("

delphi - Why is an interface in the sub class not released -

i'm facing following situation , i'm wondering code leaking memory. let have following interfaces , implementations: type itools = interface function helloworld : string; end; idatabase = interface function query(aquery : string) : string; end; imanager = interface procedure execute; end; tdatabase = class(tinterfacedobject, idatabase) strict private ftools : itools; public constructor create; destructor destroy; override; function query(aquery : string) : string; end; ttools = class(tinterfacedobject, itools) strict private fdatabase : idatabase; public constructor create(adatabase : idatabase); destructor destroy; override; function helloworld : string; end; tmanager = class(tinterfacedobject, imanager) strict private fdatabase : idatabase; public constructor create; procedure execute; end; now, if create example this: procedure example; var lexample : imanager; begin lexample := tmanager.creat

javascript - Facebook Custom Button Implementation Issue -

connect.js connect.php i trying create facebook login custom button using facebook sdk. have created , able login via clicking on "continue facebook" button . problem whenever redirects memberpage after clicking on continue facebook button , tries click on "logout" button on memberpage kill session created custom button . redirects me sigin page. within seconds again redirect me memberpage. issue here : redirecting memberpage again , again , not able logout.however, if try login without facebook using provided username , password . able login , logout without issue. above have given links code. connect.js(contains facebook login , authentication code.) function getuserdetails() { fb.api('/me?fields=id,name,email,birthday,gender,first_name,last_name,verified,hometown', function(response) { var data = { access_token: fb.getaccesstoken(), fb_id: response.id, email

c++ - Windows malloc issue? -

in windows (visual studio c++ 2010) i'm trying simple string copy. here's code: char * filename; (...) filename = (char *) malloc(wcslen(argv[(i + 1)]) + 1); wcscpy((wchar_t *)filename, argv[i + 1]); wprintf(l"filename is: %s", filename); and program crashes if argv[i + 1] if bigger 14. if 14 or less runs fine. see bellow. c:\visual studio 2010\projects\test\release>test.exe -f 12345678901234 aa asas asas first argument argv[1] -f argc = 6 filename is: 12345678901234 what's gotcha here? missing? thanks. realise wcslen() returns number of wide characters in string, not number of bytes occupies. , malloc() requires number of bytes... so need multiply number of wide characters size of wide character before passing malloc() : filename = (char *) malloc( (wcslen(argv[(i + 1)]) + 1) * sizeof(wchar_t)); but then, you're typecasting (char *) . if argv declared char *argv[] or char **argv , wcslen() wrong function use anyway: nee

php - Unable to write file with 0775 -

when want upload image on server, script doesn't have rights write file. however, script execute localy , rights of folder 0775. ...# chmod -r 0775 img drwxrwxr-x 2 root root 4096 jun 11 10:56 img but, when put rights in 0777, it's work. there has solution not allowing write directory ? thanks ! the upload directory needs owned user write file (in case user web server process running under) or upload directory needs have group ownership group of web server process user member. so example if webserver user apache , web server user member of group apache, solve by chown apache /path/to/upload/directory or chgrp apache /path/to/upload/directory any script running on webserver have write access upload directory.

html - How to increase the size of carousel in materialize.css? -

i trying increase size of carousel in materialize.css couldn't it. have tried setting height didn't work. googled couldn't find solutions. me this? .carousel .carousel-item { width:300px !important;} this might help, place code in css , change width acording need.

javascript - (Why) does setting `array[NaN]` do nothing? -

i reading an article javascript prngs , , came across surprised me: var = new array(); var b; a[b++] = 1; a [] , no exception thrown — the write array vanishes. try out in browser console if don’t believe me. i didn't believe him, tried out in browser console (firefox 47): » var = new array(); » var b; » a[b++] = 1 » ← array [ ] » b ← nan there several curious things going on here, in particular, i'm trying understand why statement a[b++] = 1 doesn't [appear to] anything. taking top: var = new array(); // 'a' empty array, plain ol' boring empty array, have been // written = []; var b; // 'b' have no value , 'undefined'. 'console.log(b); // undefined' a[b++] = 1; // lets break above statement down pieces: b++ // increment b one, undefined + 1 === nan a[ ] // use nan property our array 'a' = 1; // assign 1 property // ok? happened why 'a' still empty? console.log(a);

installation - Visual C++ 14 redist package prerequisite - configure from visual studio setup proj -

Image
i have visual studio setup project installs x64 program needs vc++ 14 redist package. i selected options per image , created folder structure inside: c:\program files (x86)\microsoft visual studio 14.0\sdk\bootstrapper\packages i have created vcredist_x64 folder contains: vcredist_x64.exe product.xml en folder inside en folder have: package.xml contents of product.xml: <?xml version="1.0" encoding="utf-8" ?> <product xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper" productcode="microsoft.visual.c++.11.0.x64" > <!-- defines list of files copied on build --> <packagefiles> <packagefile name="vcredist_x64.exe" homesite="vcredistexe"/> </packagefiles> <installchecks> <msiproductcheck property="vcredistinstalled" product="{e46eca4f-393b-40df-9f49-076faf788d83}"/> </installchecks> <

linq - c# FsCheck cannot convert lambda expression -

i'm trying c# fscheck generator generate series of commands initialized random strings. came following solution: public gen<command<a,b>> next(b value) { var gen1 = arb.default.string().generator; var gen2 = gen.two(gen1); var gen3 = gen2.select((command<a,b>)(s => new derivedcommand(s.item1,s.item2))) //derivedcommand extends command<a,b> return gen.oneof(gen3); } however, vs cannot build code: cannot convert lambda expression type command<a,b> because not delegate type i have searched solutions error message, nothing found helped. using system.linq , system.data.entity . suggestions resolving issue appreciated. you're trying cast (s => new derivedcommand(s.item1,s.item2)) , lambda expression, (command<a,b>) , (i assume) class. you need like: var gen3 = gen2.select(s => (command<a,b>)(new derivedcommand(s.item1,s.item2)));