Posts

Showing posts from July, 2015

python - How to use abbreviated timezone name(PST, IST) in Pytz -

i need know way of using abbreviated timezone name pst, ist etc on pytz. now can able convert between timezone using timezone name "america/los_angeles". instead need find way of using timezone name pst, ist etc., sample code have used conversion. def local2utc(self, dt): from_zone = tz.gettz('america/los_angeles') to_zone = tz.gettz('utc') local = dt.replace(tzinfo=from_zone) print("converted time") print(local.astimezone(to_zone).replace(tzinfo = none)) return local.astimezone(to_zone).replace(tzinfo = none) someone let me know way of achieving same. this nature impossible, because abbreviations can mean multiple (different) time zones: http://www.timeanddate.com/time/zones/ if want work timezones, make dictionary mapping abbreviation long name.

Integrate Mpesa API with google forms -

i want integrate mpesa api google form. users using form pay, let registration fee i think possible using apps script create google form. forms service this service allows scripts create, access, , modify google forms. here sample code creating google form using apps scripts. // create new form, add checkbox question, multiple choice question, // page break, date question , grid of questions. var form = formapp.create('new form'); var item = form.addcheckboxitem(); item.settitle('what condiments on hot dog?'); item.setchoices([ item.createchoice('ketchup'), item.createchoice('mustard'), item.createchoice('relish') ]); form.addmultiplechoiceitem() .settitle('do prefer cats or dogs?') .setchoicevalues(['cats','dogs']) .showotheroption(true); form.addpagebreakitem() .settitle('getting know you'); form.adddateitem() .settitle('when born?...

PHP Filter Array for double Elements -

i've got question. got array filled external links like: www.google.de www.google.com/test and on. no array filltered. if there links in array this: www.google.de www.google.de/test www.google.de/fuuuu i want www.google.de link , filter rest out of it. startet use array_diff_key not working should. here snippet. $d_array = array_diff_key($externalarray, array_unique($externalarray)); thanks help. greats, traxstar finally, did : $arr = [ 'www.google.de', 'http://www.google.de/test', 'www.google.de/fufufufu', 'www.google.com/cctvvmb', 'https://www.google.com/', 'google.co.uk/hello', ]; // based on http://stackoverflow.com/questions/1201194/php-getting-domain-name-from-subdomain function get_domain($url) { if(preg_match('/(?p<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', $url, $regs)) { return $regs['domain']; } return false; } ...

php - Profile Query Submit -

i have following code: <?php $id=$_get['id'];$id=str_replace('_',' ',$id); global $wpdb; $res = $wpdb->get_results("select * `agents` `name`='".$id."'"); foreach ($res $row) { $name = $row->name; echo $name; } ?> when hit submit profiles display following url: http://www.website.com/profile/?id=first_last is there way display url this: http://www.website.com/profile/first-last/ thank you, john you can use htaccess rewriting # begin wordpress <ifmodule mod_rewrite.c> rewriteengine on rewritebase / rewriterule ^profile/(.*) /profile/?id=$1 [l] rewriterule ^index\.php$ - [l] rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule . /index.php [l] </ifmodule> # end wordpress or wordpress page_rewrite_rules: you can add block of code theme’s functions.php file. add_filter( 'page_rewrite_rules', 'my_page_rewrite_rules' ); function my...

ios - How to check if a specific application is installed or not? -

i have 2 applications abc , xyz. need show download prompt xyz app in abc application. condition is, if xyz pre-installed prompt should not shown. the twist here not have code access of xyz application (since developed other team of same client) cannot use uri schemes here. i have tried this approach of no use. any appreciated. :) if owner of both applications can use url-schema technique. if not, know url-schema of xyz app, can check canopenurl: method wheter xyz istalled or not

Node.js on nginx with different port -

i have seen few examples in internet tried none of them working, can tell whats wrong doing. have laravel app on nginx server , want run node.js app on different port on server. have been trying on different ways , getting " 502 bad gateway " another note, have https port allowed port 3000. here's server config codes- server{ listen 443 ssl; # listen [::]:80 ipv6only=on; server_name node.example.com; root /home/tapos/node_modules; index index.html index.htm index.js; location / { try_files $uri $uri/ =404; # proxy_pass https://node.example.com; proxy_pass https://localhost:3000; proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for; proxy_set_header host $http_host; proxy_set_header x-forwarded-proto $scheme; proxy_buffering off; } } you need add server block redirecting traffic nodejs app or update existing server block redirect traffic between nodejs application based on u...

javascript - Expand and collapse child row on click of a link in the parent row of a table -

Image
guys i'm newbie jquery. i've make child rows in table hide , show on click of link in parent row. i've tried use jquery toggle, dont know how make work when there multiple rows. here's table - <table class="table table-striped reporttable"> <thead> <tr> <th>product type</th> <th>product name</th> <th>face value</th> <th>my stock</th> <th>ordered stock</th> <th>sub account stock</th> </tr> </thead> <tbody> <tr> <td><a class="showhr" href="#">sim</a></td> <td></td> <td></td> <td>574,888</td> <td>0</td> <td>0</td> ...

javascript - Error: Failed to execute 'appendChild' on 'Node': The new child element contains the parent -

below code throws error when script running. code adding more menu. when run script throws error failed execute 'appendchild' on 'node': new child element contains parent. $(document).ready(function() { ulnodes = document.getelementbyid("sub"); linodes = []; (var = 0; < ulnodes.childnodes.length; i++) { if (ulnodes.childnodes[i].nodename == "li") { mpdata = ulnodes.childnodes[i].getattribute('class'); ulnodes.childnodes[i].setattribute('class', 'n-menu' + " " + mpdata); linodes.push(ulnodes.childnodes[i]); } } var inp = document.getelementbyid("sub"); tot_li = inp.getelementsbyclassname("n-menu").length; var n; wwidth = window.innerwidth; if ((wwidth > 767) && (wwidth < 800)) { n = 4; } if ((wwidth > 800) && (wwidth < 1024)) { n = 5; } if (wwidth > 1025) { n = 7; } if (tot_li > n)...

Google maps for iOS [map balloons] -

Image
how make map balloons when marker being touched or tapped in ios? put want application's map feature able popup map balloon display information on location marker located. i'm using google maps since i've heard more accurate mapkit in ios. the image below objective in question: if want custom map balloons markers, while using google maps sdk ios, can use function - (uiview *) mapview: (gmsmapview *) mapview markerinfowindow: (gmsmarker *) marker this allows display custom info window marker instead of default infowindow. need design view shown in picture , assign required values , return view in function. please check earlier post see example of making custom infowindow . can adjust how infowindow located respect marker, setting value property marker.infowindowanchor

partitioning - how to manage (insert ,update and select operation ) large table in postgresql-9.4 -

i have country table having countries in world ,states table having states of countries , city table having cities record (may include city,town , village) in country in world. problem how manage such large table record of city table in postgresql version-9.4 , there more 10000 concurrent users accessing it.

combine multiple match() results in mongodb aggregation framework -

i got following query: db.getcollection('messages').aggregate( { $match : { "header.messagetype" : { $in: ["04"] }, } }, { $project: { _id: '$_id', header: '$header', content: '$content', q0: { $arrayelemat: [ "$content.changes", 0 ] }, q1: { $arrayelemat: [ "$content.changes", 1 ] }, q2: { $arrayelemat: [ "$content.changes", 2 ] }, q3: { $arrayelemat: [ "$content.changes", 3 ] }, q4: { $arrayelemat: [ "$content.changes", 4 ] }, q5: { $arrayelemat: [ "$content.changes", 5 ] }, } }, { $match : { "q0":"1" } }, { $sort : { "sequenceid" : -1, } }, { $limit : 1 } ); whic...

exchangewebservices - How could I fetch multiple o365 mail details for mail ids using EWS managed API in c# -

i need fetch multiple o365 mail details different mail ids using ews managed api in c#. suppose have o365 mail ids 1,2,3... when pass these mail ids , call ews managed api details mail ids should populated. have done details population single email id using code below: exchangeservice service = new exchangeservice(exchangeversion.exchange2013_sp1); service.credentials = new webcredentials("username", "password"); service.autodiscoverurl(ownerusername, redirectionurlvalidationcallback); emailmessage mail = emailmessage.bind(service, mailid, propertyset.firstclassproperties); if has suggestion please share. try this: exchangeservice service = new exchangeservice(exchangeversion.exchange2013_sp1); service.credentials = new webcredentials("username", "password"); service.autodiscoverurl(ownerusername, redirectionurlvalidationcallback); //make sure include properties looking in emailmessagesch...

How to tune the spark executor number? -

i submit spark stream calculation task stand alone spark cluster. submit command below: ./bin/spark-submit \ --master spark://es01:7077 \ --executor-memory 4g --num-executors 1\ /opt/flowspark/sparkstream/latest5min.py 1>a.log 2>b.log note use num-executors 1. because want 1 executor. then ps comand can find below output. [root@es01 ~]# ps -ef | grep java | grep -v grep | grep spark root 11659 1 0 apr19 ? 00:48:25 java -cp /opt/spark-1.6.0-bin-hadoop2.6/conf/:/opt/spark-1.6.0-bin-hadoop2.6/lib/spark-assembly-1.6.0-hadoop2.6.0.jar:/opt/spark-1.6.0-bin-hadoop2.6/lib/datanucleus-api-jdo-3.2.6.jar:/opt/spark-1.6.0-bin-hadoop2.6/lib/datanucleus-rdbms-3.2.9.jar:/opt/spark-1.6.0-bin-hadoop2.6/lib/datanucleus-core-3.2.10.jar:/opt/hadoop-2.6.2/etc/hadoop/ -xms4g -xmx4g -xx:maxpermsize=256m org.apache.spark.deploy.master.master --ip es01 --port 7077 --webui-port 8080 root 11759 1 0 apr19 ? 00:42:59 java -cp /opt/spark-1.6.0-bin-hadoop2.6/c...

.htaccess - Mod-rewrite 301 link wont redirect -

can 1 tell me 301 rewrite rule link please, need remove toolrepairshop , %2520 toolrepairshop-blog?mywebsite_blog_tag=tool%2520repair%2520shop to blog?mywebsite_blog_tag=tool-repair-shop sorry needed redirected blog?mywebsite_blog_tag=tool%20repair%20shop am sure blog module automatically adding %20 you can use followin redirect in htaccess : rewriteengine on rewritecond %{the_request} /toolrepairshop-blog\?mywebsite_blog_tag=tool%2520repair%2520shop [nc] rewriterule ^ /blog?mywebsite_blog_tag=tool-repair-shop [nc,l,r=301,ne]

c - Flash programming causes unexpectedly reset -

Image
i'm working mcf51em256 freescale microcontroller , i've problems flash programming. in order make software persistant i'm trying store variables in secondary flash memory recover unexpected shutdowns. sometimes, when test work shutting down mcu, reset. i have store struct: // kwh or kvarh energy accumulator type typedef struct { uint32 ea_ps; // energy must stored in kwh or kvarh uint32 ea_ng; // fields must contain positive values! uint32 er_q1; uint32 er_q2; uint32 er_q3; uint32 er_q4; }kwh_energyacc32; and these functions: // function stores in flash given kwh_energyacc64 structure. void save_flash_kwhenergyacc(long addr, kwh_energyacc32* acc) { // kwhenergyacc struct needs 32 bytes in flash flash_burst(addr, 1, &(acc->ea_ps)); flash_burst(addr + 4, 1, &(acc->ea_ng)); flash_burst(addr + 8, 1, &(acc->er_q1)); flash_burst(addr + 12, 1, &(acc->er_q2)); flash_burst(addr + 1...

java - CheckBox in GridView still clickable while clickable=false -

i have made gridview (in fragment) adapter , layout items. layout exists of imageview display picture, checkbox , imageview display indicator indicates if picture picture or if thumbnail video. here layout: <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content"> <imageview android:id="@+id/ivgridmedia" android:layout_width="match_parent" android:layout_height="match_parent" android:adjustviewbounds="true" android:contentdescription="@string/imgobjectmediadesc"/> <checkbox android:id="@+id/checkbox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignright="@+id/ivgridmedia...

c# - select all rows that count of quantity fields least equal- Entity framework -

Image
i have table productinventory , in have product quantity . i want select rows least of field equals input(number) . i try : list<product> products = new list<product> { new product{id=1,name="a",quantity=1}, new product{id=1,name="a",quantity=2}, new product{id=1,name="a",quantity=3}, new product{id=1,name="b",quantity=4}, new product{id=1,name="b",quantity=7} }; var result = products .asenumerable() .groupby(r => r.name) .where(g => (int)g.sum(r =>r.quantity)<= 4) .tolist(); but causes return zero. example: i don't know possible in linq or not. can try this. var result = products.asenumerable().where(g => g.name == "a").tolist(); int userinput =4; var total = 0; var selectlist = new list<product>(); (int = 0; < result.count; i++) { (int j = i; j < result.count; j++) { if (total + result[j].quantity <= u...

model view controller - Demandware MVC concept -

i new guy demandware , switching magento demandware. demandware not opensource not getting proper tutorials, stuff understand concepts of it. i magento know magento mvc structure. in demandware have different concepts pipelines, pipelets, isml scripts, ecma script, dw scripts etc. i want know mvc pattern of demandware. how works , basic concept need concentrate? i suggest request demandware xchange account possible you, access demandware community portal , api documentation. in short: models demandware forms , demandware api objects controllers demandware pipelines (there javascript controllers released, may find these easier understand if have node.js experience). these can call dw scripts (demandwarescript based on ecmascript standard 5.0 javascript extensions e4x , optional types) views isml templates. should avoid including lot of logic in them, either isml tags isif, isloop, etc. or isscript. any further questions - let me know. hope helps, zlatin ...

c# - Getting file size in KB -

i storing file in database in kb. try convert file length return file info kb follow. fileinfo filevol = new fileinfo(downloadpath); int sizeinkb = (int)(filevol).length / 1024 ; if file size return db , value in size in kb equal code allow install software downloadpath. getting value in size in kb less of value return db (always 1 kb). wrong me. please resolve. fileinfo filevol = new fileinfo(downloadpath); string filelength = filevol.length.tostring(); string length = string.empty; if (filevol.length >= (1 << 10)) length= string.format("{0}kb", filevol.length >> 10); length=> result kb of file.

sql - Modify and Implement Query -

Image
we trying analysis of how long our staff have been working on hourly basis trending , forecasting purposes. we have both clock in (shifta_start) , clock out (shifta_end) of employees. below current code using , have included output shown in sql after execution. however when employee working overnight eg: shiftastart != shiftaend, fields cannot populated. current sql works when employee start , end shift on same day. does know how modify query when employee works overnight, can populate in sql columns? select --b.*, b.employeename, b.department, convert(datetime, left(b.shifta_start,17),103) shifta_start, convert(datetime, left(b.shifta_end,17),103) shifta_end, b.starttime_hour, b.starttime_min, b.endtime_hour, b.endtime_min, case when b.[0h_start] < b.[0h_end] b.[0h_start] else b.[0h_end] end [0], case when b.[1h_start] < b.[1h_end] b.[1h_start] else b.[1h_end] end [1], case when b.[2h_start] < b.[2h_end] b.[2h_start] else b.[2h_end] end [2], case wh...

mysql - Something wrong with mysqli_fetch_array in php? -

i trying create booking system in php , mysql datepicker. when user selects date table available period times should displayed. if time frame available, user should use radio input , book period of time. if i'm using "order start asc limit 1" . gives me 8:22 exists , , it's correct, not gives me second statement, 8:30 exists . instead, 8.30 creates available time frame 8:30-8:38 . if i'm using "order start asc" . multiplies information based on how many records have in database. can't see wrong ! bellow code mysql table: create table if not exists `bookings` ( `id` int(100) not null auto_increment, `date` date not null, `start` enum('8:22-8:30','8:30-8:38','8:38-8:46','8:46-8:54','8:54-9:02','9:02-9:10','9:18-9:26','9:26-9:34','9:34-9:42','9:42-9:50','9:50-10:58','10:58-11:06','11:06-11:14','11:14-11:22','11:22-...

Using Flyway and TOAD to compile the same Oracle code -

as company looking use flyway manage our oracle database migrations, , tool looks it'll excellent our needs. i've looked further how it'll fit our development processes , have run problem have not been able resolve. we'll setting additional database instance we'll using continuous integration, , automated testing. we'll use flyway release our db application instance. allow multiple versions of database application we'd ability release our db code different schemas. so, if had schema called scott, may want release code scott_rm, scott_ci, scott_v5, etc. we can manage in flyway using placeholders mimic syntax required variable substitution in oracle, i.e. flyway.placeholderprefix=&& flyway.placeholdersuffix=. this works when running through flyway, or sql*plus. our package declaration this: create or replace package &&schema_scott..pa_package however, problem lies when developer working within toad , want compile code directly o...

Change maximum allowed configuration file size [IIS Express 10/Windows 10] -

Image
after adding multiple entries redirect map in linked config file, following error on iis express 10 on windows 10 (64 bit, iis express running 32-bit): " can not read configuration file because exceed maximum file size " i've tried adding configuration key registry, setting maxwebconfigfilesizeinkb value of 512 under hklm/software/microsoft/iisexpress/10.0/mimic/configuration : any idea on how enable configuration files larger 250 kb iis express on windows 10? cheers! finally, saved me: https://blogs.msdn.microsoft.com/amb/2013/01/07/iis-express-8-and-large-web-config-files-cannot-read-configuration-file-because-it-exceeds-the-maximum-file-size-error-message/ basically, had add the maxwebconfigfilesizeinkb value under: hklm/hkey_local_machine\software\wow6432node\microsoft\iisexpress\10.0\mimic\configuration

jquery - How to add additional fields to form before submit? -

is there way use javascript , jquery add additional fields sent http form using post? i mean: <form action="somewhere" method="post" id="form"> <input type="submit" name="submit" value="send" /> </form> <script type="text/javascript"> $("#form").submit( function(eventobj) { // want add field "field" value "value" here // post data return true; } </script> yes.you can try hidden params. $("#form").submit( function(eventobj) { $('<input />').attr('type', 'hidden') .attr('name', "something") .attr('value', "something") .appendto('#form'); return true; });

Saving dates in a matrix ("origin must be supplied") with r -

i writing bachelor thesis , have not experience r far. problem dates made commands : t<-strptime(x, "%d.%m.%y %h.%m") don't work anymore when save them in matrix other information on specific dates. i bit confused because works fine when don't put them in matrix t[1:10] but happens try save them in matrix matrix1<-matrix(c(t,v2,v3,v4),nrow=length(v2)) fehler in as.posixct.numeric(x[[i]], ...) : 'origin' muss angegeben werden it's german means origin must supplied. any ideas have fix it? bit frustrated :) roland right. can't have posixlt objects in matrix. can save dates numeric timestamps in matrix , convert them dates while accessing converting numeric timestamp: >date<- as.numeric(as.posixct("2014-02-16 2:13:46 utc",origin="01-01-1970")) >date [1] 1392545626 then save timestamps in matrix , convert date, use above command again without converting numeric.

android - Navigation drawer + Action bar tabs design -

in opinion, "best" design choice implement viewpager 2 fragments use swipe action when using new navigation drawer pattern ? tried tabs navigation drawer doesn't overlap action bar tabs... in opinion, tabs sub level navigation. so, move navigations sub level in listview of navigation drawer

jquery - Get and save all id start with using javascript -

i have structure this <div id-"form-input"> <div id="form1"></div> <div id="form2"></div> <div id="form3"></div> <div id="form4"></div> </div> i want number of form 1 , 2 , ... n . try using code id . var num = new array(); var elems = $('div[id^=form]'); (var i=0; i<elems.length; i++) { alert(elems[i]); num.push(elems[i]); } alert(num); but returns [object htmldivelement] . wrong? how can number? use map() method following. var num = $('div[id^=form]').map(function() { var id = this.id.split('form')[1]; if(!isnan(id)) return +id; // + convert string num }).get(); alert(num); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id-"form-input"> <div id="form1"></div> ...

performance - How to measure resource usage on partitionlevel in Service Fabric? -

with service fabric tools create custom metrics , capacities. way can make our own resource models resource balancer uses execute on runtime. monitor , use physical resources such as: memory, cpu , disk usage. works fine long keep using default load. but load not static service/actor, use built-in dynamic load reporting. run problem, reportload works on level of partitions. partitions within same process on node. methods monitoring physical resources found using process smallest unit of measurement, such performancecounter. if value used there hunderds of partitions reporting same load , load not representative of partition. so question is: how can resource usage measured on partition level? not service instances , replicas hosted in same process, share thread pool default in .net! every time create new service instance, platform creates instance of service class (the 1 derives statefulservice or statelessservice) inside host process. great because it's fast, cheap...

javascript - Canvas component constructor with the built-in image object doesn't show's the image -

i'm working canvas , try create constructor function 'component' create various elements. idea has have ability fill created element not color, background image. works fine filling element color, can't load image. no errors in console. it's nothing on screen. need help, please. whole code this: var myrect; function startgame (){ workingarea.create(); myrect = new component(30, 30, "grass.jpg", 10, 120, 'image'); } var workingarea = { canvas: document.createelement('canvas'), create: function (){ this.canvas.width = 480; this.canvas.height = 270; this.context = this.canvas.getcontext('2d'); document.body.insertbefore(this.canvas, document.body.childnodes[0]); } }; function component(width, height, color, x, y, type){ this.width = width; this.height = height; this.x = x; this.y = y; this.type = type; if (this.type === 'image'){ this....

css - Background-Color of BODY tag applied to the whole HTML -

this question has answer here: applying background <html> and/or <body> 1 answer i confused size of body tag in html. i have tough code follows: <body> </body> body{ padding: 0px; height: 100px; background-color: #e5e5e5; } why background cover of page?, thought should cover 100px, please explain me, thank help! this indeed confusing, specified in css 2.1 specification, clause 14.2 background : if computed value of background-color transparent , computed value of background-image none html element (as things default), browsers must instead use computed value of background properties body element , must not render background body (i.e. make transparent). is, body background magically turns html background if html lacks background of own – , affects background properties, not true heig...