Posts

Showing posts from April, 2013

powershell outlook showing content from other e-mail -

i have powershell script prints senderemailaddress, , subject. problem when asking content get-content $txtcontent | select -index 23 content e-mail. maybe there method clear cache or because content previous e-mail , don't know how fix this. $txtcontent= "c:\test.txt"; $matchstring= "info@blabla.com"; $olfolderinbox = 6 $outlook = new-object -com outlook.application; $mapi = $outlook.getnamespace("mapi"); $inbox = $mapi.getdefaultfolder($olfolderinbox) $inbox.items | select -last 1 senderemailaddress,to,subject $inbox.items | { $_.senderemailaddress -match $matchstring } | out-file $txtcontent get-content $txtcontent | select -index 23 when using get-content $txtcontent content of e-mail need. when need line 23 content another, previous e-mail

java - Android ViewPager doesn't show Fragment -

i'm trying let viewpager show fragments, however, doesn't seem work. not showing anything, not height. can tell me step missing? thanks main_activity.xml: <android.support.design.widget.coordinatorlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/colorbackground"> <android.support.v4.view.viewpager android:id="@+id/viewpager" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_above="@+id/bottomnavigation" /> <com.aurelhubert.ahbottomnavigation.ahbottomnavigation android:id="@+id/bottomnavigation" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom"...

sql - Transposing and then exporting a table to a CSV file -

Image
i have sql table 3 columns such: i write script in amazon redshift (uses postgresql 8.0.2 believe) exports above table csv file transposed. transposed mean create new column each cobrand (there 4 distinct values in cobrand_id column) in csv file. illustrate want, included image (the values illustrative!): when try: copy temp_08.jwn_calc 'p:/sql_new/products_199.csv' delimiter ',' csv header; i error: [42601] error: syntax error @ or near "header" position: 74 when remove "csv header", error: [0a000] error: copy file xen-tables not supported help appreciated! transposing to transpose data, you'll have write query names each column, such as: select qqyy "quarter", sum(case when cobrand_id = 10001372 sum end) "10001372", sum(case when cobrand_id = 10005244 sum end) "10005244", sum(case when cobrand_id = 10005640 sum end) "10005640", sum(case when cobrand_id = 10006...

memory - java.lang.OutOfMemoryError: Java heap space creating a long list of Myclass -

i'm parsing data internet create arraylist every politician class has field hashmap. every hashmap contains 132*150 entry. after 164th map filled got exception: java.lang.outofmemoryerror: java heap space. wanted store big list using serialization use in future. how should proceed? should serialize politician instances , not whole list? there other optimal way store data? (if needed) i'm writing data files. thinked store data "as object" improve ease of use. code: private static void setvotiparlamentari(parseropenparlamento parser, arraylist<politician> politicianlist){ for(politician p : politicianlist){ string filepath = system.getproperty("user.dir") + file.separator + "io_files" + file.separator + "info_parlamentari2"; string filename = file.separator + p.getname() + ".txt"; iterator<string> votesiterator = parser.parsepoliticianvotes(p).iterator(); filewriter w = null; try { w =...

clear terminal (and history!) in Python -

this almost duplicate of clear terminal in python , not quite. that question reads: standard "comes batteries" method exist clear terminal screen python script, or have go curses (the libraries, not words) ? all of responses there result in happens when enter clear on terminal - on screen disappears except empty command line @ top. but, if you'd like, can scroll see doing earlier. i'm looking way this, not allow user scroll up. it's equivalent of command+k on macos. the application multiplayer card game, , don't want player able scroll see player's hand. you use subprocess.call() standard library subprocess module send reset command terminal reinitialize terminal , in effect similar clear clear scrollback history. import subprocess subprocess.call('reset') alternatively, have learned this answer , can use command tput reset instead, clear terminal instantly, whereas reset alone experience slight delay. can called s...

c# - Unity physics - how to make objects bob down then up as if in space with gravity? -

alright, getting physics here in unity , ive been through unity's forums well, cant figure out how create specific gravity related effect - i have these rigid bodies of mass 100 able push off platform (my game bunch of platforms set in space) open space. because checked affected gravity, fall. what need objects slide off platform, fall little bit bob , stay there floating. if pushed off in space, cant keep going. bob down, up, stay , float. this seems lot more complicated thought, ive played gravity , high values fall straight down (not out, obviously) , low values float above when pushed off. there doesn't seem sweet spot neither go down or up, bob. how can achieve this? masses 100. my suggestion implement force function tries resemble arkimedes' principle. key potential dependant on how far down object is: further down water object is, more lift force. such, key function here (and tricky one) volumebeneathsurface . double liftforce(object) { con...

xcode8 - LLVM Kaleidoscope examples in Xcode -

i'm working llvm kaleidoscope ch. 7 example, , use xcode 8 work on project further. currently, have used cmake build xcode project have functionality looking for. (see http://llvm.org/docs/cmake.html ) the problem is, builds entire llvm source folder inside 1 giant xcode project (think 134 dependencies, takes 800 seconds compile, etc...). want 1 target , 1 source file huge xcode project, not else. the problem, though, don't know how link appropriate headers , llvm source when create own xcode project. option use make -g xcode ... path_to_llvm_root so, guess what's left figure out way isolate 1 target/settings out of dozens , copy on new project. does have experience llvm kaleidoscope examples within project?

Using Google Places Web Service in an Android app -

Image
all of android apis google place searches return predictions, , these not accurate or complete place search web service. though predictions deliver desired place, i've bumped scenarios don't. want use android api primary search tool, offer user search button delivers more complete results (like returned web service). i've validated have working web api-key url: https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=47.725977,-122.047113&keyword=home%20depot&rankby=distance&key=my-key in test app, called exact url using httpurlconnection, , use app-specific api key validate can use googleapiclient to location information (lattitude , longitude). here's screen shot of result: i've been unable call google place web service app, regardless of keys provide (including unrestricted key). google doesn't seem want use web services app, though there couple of stackoverflow questions imply it's possible. my questions (1) tec...

r - rvest scraping data from a button style tag? -

following more delving scraping data off sites. trying pull data off of site seatgeeks few columns. i'm having trouble accessing pricing , link data specifically. following code runs can't accurate data pricing , links. 65$ keeps repeating though numbers different per button. ideas? appreciate help! #ticket scruber library(rvest) tix_link = paste("https://seatgeek.com/new-york-knicks-tickets#events") tix_info = tix_link %>% read_html() %>% html_nodes(".event-listing-title span") link_date = read_html(tix_link) link_date = html_nodes(link_date, ".event-listing-date") link_time = read_html(tix_link) link_time = html_nodes(link_time, ".event-listing-time") link_price = read_html(tix_link) link_price = html_node(link_price, ".event-listing-button") link_info = read_html(tix_link) link_info = html_node(link_info, "span") #convert data frame ticket_deals = data.frame(deals = html_text(tix_info), ...

string - Python: os.join.path() -

this question has answer here: why backslashes appear twice? 1 answer i used os.join.path() load image in folder. found function cannot give accurate path when used in defining function in cases. example: def myfuncion(something) desiredpath = os.path.join('mypath','apple.jpeg') #desiredpath = os.path.normpath(os.path.join('mypath','apple.jpeg')) print desiredpath return when implement function, printed result of path is: mypath\apple.jpeg it illegal image loading. os.path.join() works in pythonconsole. how make path generated in such function definition have double backslashes? also, noted os.path.normpath cannot work sometimes. example: os.path.normpath('mypath\apple') it should give result: mypath\\apple but instead, results in: 'mypath\x07pple' how come?? \a eq...

python gflags module help flag doesn't work -

i have problem use python gflags module in selenium web test suite. follow way how example in gflags github repo. new flags defined via define_string working. default 1 --help doesn't work. here code: #!/usr/bin/env python import datetime import gflags import sys import time import os import glob import unittest selenium import webdriver pageobject.contact_us_page import contactuspage pageobject.utility import sendemailnotification selenium.webdriver.support.ui import webdriverwait selenium.webdriver.support import expected_conditions ec selenium.webdriver.common.by import flags = gflags.flags gflags.define_string('sender_addr', '', 'the sender of email notification') gflags.define_list('receivers_addr', '', 'the list of receivers') gflags.define_string('sender_password', '', 'the password of sender email box') class testcontactuspage(unittest.testcase): @classmethod def setupclass(cls): ...

python - how can i show igraph outputs? -

Image
this simple question. i'm new python appreciate help! in codes put below, how can show output instead of memory object? graph.clusters(g) out[106]: <igraph.clustering.vertexclustering @ 0x1187659d0> graph.community_edge_betweenness(g, clusters=none, directed=true, weights=none) out[107]: <igraph.clustering.vertexdendrogram @ 0x118765d90> it depends want show? let's take example: import igraph g = igraph.graph.barabasi(n = 20, m = 3) c = g.clusters() print() in python calls __str__() method of object, converts human readable, in case of vertexclustering , each row represents cluster (cluster id in square brackets), , vertex ids belonging cluster listed. first line gives simple description: >>> print(c) clustering 20 elements , 1 clusters [0] 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 then, can access members of each cluster list of vertex ids this: >>> c[0] [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1...

flask - Google Oauth redirect_uri not working with domain aliases -

i have 2 domains pointing same public ip. domain1 : sub.domain1.com domain2 : sub.domain2.com domain2 has alias domain1 i have registered both below api's redirected apis google dashboard follows api1 : sub.domain1.com/authorized api2 : sub.domain2.com/authorized i have integrated google oauth service flask web application , working expected when access application using domain name "sub.domain1.com". i login/logout , works perfect but,when access flask application using domain sub.domain2.com and tried login got error saying invalid response google redirecting sub.domain1.com/authorized?code=4/7jglt8defsb4gubhglr9xegypsovgcity7xrrtpgwu8# i not understand if access application using " sub.domain2.com " redirecting " sub.domain1.com/authorizedauthorized?code=47jglt8defsb4gubhglr9xegypsovgcity7xrrtpgwu8# " giving error invalid response google please can me ?

asp.net - how can i show correctly datetime in C# -

i have time stamp in persian date format , want convert full persian date, code work correctly in localhost when upload remote server output changed gregorian date string dt = ""; persiancalendar pc = new persiancalendar(); int year = convert.toint32(ts.substring(0, 4)); int month = convert.toint32(ts.substring(4, 2)); int day = convert.toint32(ts.substring(6, 2)); int hour = convert.toint32(ts.substring(8, 2)); int minute = convert.toint32(ts.substring(10, 2)); int second = convert.toint32(ts.substring(12, 2)); dt = new datetime(year, month, day, hour, minute, second, 0, pc).tostring("dddd dd mmmm yyyy hh:mm:ss", cultureinfo.createspecificculture("fa-ir")); output code expect (in localhost): شنبه 22 آبان 1395 13:43:10 and output in remote server شنبه 12 نوامبر 2016 13:43:10 what should work correctly? the calendar parameter in datetime constructor used interpret integer values not dictate result of calendar. code have w...

How to handle authentication callback in an API backend? Rails API + React Fronetend + Facebook -

i have rails 5 api backend. have 2 routes such: # facebook link url # /accounts/facebook_url def facebook_url @oauth = koala::facebook::oauth.new( env['facebook_app_id'], env['facebook_secret'], facebook_callback_accounts_url ) # @oauth.url_for_oauth_code # create oauth url url = @oauth.url_for_oauth_code render json: url # hanlde using serializer? end # facebook post url code # /accounts/facebook_callback?code=fadsdfaadsf def facebook_callback @oauth = koala::facebook::oauth.new( env['facebook_app_id'], env['facebook_secret'], facebook_callback_accounts_url ) token = @oauth.get_access_token(params[:code]) end in react app, url authentication facebook_url route , redirect user route. facebook send me token. able point. problem how frontend know token received or not? if rails application, use different redirects based on status. seems more architecture based ...

c - How access Drivers folder in minifilter driver -

my minifilter driver start type on boot, wont access c:\windows\system32\drivers folder in instancesetup callback, tried \systemroot\system32\drivers , got status_object_path_not_found , when tried \device\harddiskvolume2\windows\system32\drivers worked. my question can sure harddiskvolume2 path have drive current operating system installed? maybe should use harddiskvolume3 or harddiskvolume4 , how can know it?

angularjs - jQuery datepicker doens't change ng-empty if I select a date -

i have view in have input field jquery ui date picker. want disable button if field empty. html(cshtml-asp.net): @html.textboxfor(model => model.from, new { ng_model = "from", id = "dfrom", @class = "form-control datepick", placeholder = "select date", tabindex = "2" }) <input ng-disabled="!from" type="button" value="add" class="btn btn-success" /> js: $(document).ready(function () { $(function () { $('.datepick').each(function () { $(this).datepicker({ dateformat: 'd mm, y', maxdate: new date() }); }); }); }) but if select date, field doesn't change (like: ng-empty ng-not empty) , button still disabled. how can solve issue? the ng-disabled makes angular add html disabled='disabled' whenever type selected field (any character other space). works jquery datepicker field....

Memory Leak in C free() -

i'm running valgrind , it's telling me need free , i'm not sure that. points line "toinsert->value = linkedlist->copy(element); where run free , on data? " void linkedlist_append(linkedlist *linkedlist, void *element) { listnode *toinsert = (listnode*)malloc(sizeof(listnode)); toinsert->value = linkedlist->copy(element); toinsert->next = null; listnode *last = linkedlist->head; if (last==null) linkedlist->head = toinsert; else{ while(last-> next !=null){ last = last->next; } last->next = toinsert; } linkedlist->size++; } output valgrind: > ^c==30515== ==30515== heap summary: ==30515== in use @ exit: 287 bytes in 47 blocks ==30515== total heap usage: 95 allocs, 1,038 frees, 2,159 bytes allocated ==30515== ==30515== 247 bytes in 46 blocks lost in loss record 2 of 2 ==30515== @ 0x4c28c20: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==30515== 0x4011ac: st...

enable remote access for mongoDB server -

i have linux servers running on same local network. 1 of them running mongodb server. trying connect first server mongodb second server. have added port 27017 first server firewall rules. have modified /etc/mongo.conf file follows: bind_ip=127.0.0.1,10.0.0.202 that did not work. have tried next version: bind_ip=[127.0.0.1,10.0.0.202] that did not work well. after modifying file trying restart mongod service service won't restart. original line: bind_ip=127.0.0.1 . here error once restart service , check status: mongod.service - sysv: mongo scalable, document-oriented database. loaded: loaded (/etc/rc.d/init.d/mongod) active: failed (result: exit-code) since sun 2016-11-13 11:32:15 ist; 4min 58s ago docs: man:systemd-sysv-generator(8) process: 37572 execstop=/etc/rc.d/init.d/mongod stop (code=exited, status=0/success) process: 37546 execstart=/etc/rc.d/init.d/mongod start (code=exited, status=0/success) main pid: 37559 (code=exited, status=48) nov ...

c# - How to prevent Xamarin.Forms.Entry Keyboard to be Unfocused when Pressing a Button -

Image
i making chat functionality, , how xaml snippet looks like: <stacklayout grid.row="1" orientation="horizontal" heightrequest="50"> <entry x:name="chatfield" text="{binding currentmessagetext}" placeholder="{binding messagetextplaceholder}" horizontaloptions="fillandexpand"/> <button text="send" backgroundcolor="transparent" command="{binding sendmessagecommand}"/> </stacklayout> i have entry control , button control binded command sends text in chatfield. and want mimic chat apps standard wherein pressing send button not unfocus or hides keyboard. unfortunately, right when press send button - automatically unfocus keyboard entry cell. initial steps made prevent this, on viewmodel sendmessagecommand have: var chatentry = currentpage.findbyname<entry>("chatfield"); chatentry.focus(); but makes weird behaviour of pushing li...

asp.net - WebSocket server c# receiving & identifying multiple messages -

i have created asp.net c# project, consists of web form , websocket handler. send data in json format web form websocket handler. the web form have code snippet: ws.send(json.stringify(amt)); ws.send(json.stringify(name)); under websocket handler's onmessage(string message) method, convert data sent web form in json format c# format. but, how onmessage method in websocket handler knows data "amt" , data "name"?

android - list view click gets the wrong item -

i have list view inflated adapter. when click on 1 of buttons wrong item. used work o.k until added whatsapp button. this adapter: public class shawarmaddapter extends arrayadapter<shawarma> { string nname; double lat,lon; public shawarmaddapter(context context, list<shawarma> resource) { super(context,0, resource); } @override public view getview(int position, view convertview, viewgroup parent) { .... if (convertview==null) { convertview= layoutinflater.from(getcontext()).inflate(r.layout.shawarmaddapter,parent,false); } .... waze= (imagebutton)convertview.findviewbyid(r.id.adapterwazebtn); whats = (imagebutton)convertview.findviewbyid(r.id.whats); locname=name.gettext().tostring(); .... nname = sh1.getname(); name.settext(sh1.getname()); .... if (sh1.getparking()==1) park.setchecked(true); else park.setchecked(false); rate.setrating((float) sh1.getrank()); rate.setisindicat...

Rails link_to how to show blank when null -

i have in view: <td><%= link_to product_sale.product.consignor.try(:name), { controller: :consignors, action: :edit, id: product_sale.product.consignor.try(:id) }, :target => "_blank" %></td> which in product_sale view links edit consignors products listed. some product doesn't have consignor. when happens, shows /consignors/edit how can show blank instead? when show blank instead mean not show link? if so, can't conditionally call link_to helper: <td><%= product_sale.product.consignor ? (link_to edit_consignor_path(product_sale.product.consignor) ) : '' %></td> as long routes set correctly shouldn't need specifying controller , action , id either. if want display more meaningful end user instead of default link add parameter before edit path: <td><%= product_sale.product.consignor ? (link_to product_sale.product.consignor.name, edit_consignor_path(product_sale.product.consigno...

plot - In Matlab: When plotting in 3d, using colormap(..), how to specify 'transparent' (white?) color for the value 'zero'? -

in matlab: when plotting in 3d following: xxxxx=normrnd(1,1,[1,10000]); yyyyy=normrnd(1,1,[1,10000]); minx=min(xxxxx); maxx=max(xxxxx); miny=min(yyyyy); maxy=max(yyyyy); x = minx:(maxx-minx)/10:maxx; y = miny:(maxy-miny)/10:maxy; [x,y] = meshgrid(x,y); hist3 = hist3([xxxxx' ,yyyyy'],{x y}); figure(); surf(x,y,hist3); colormap(jet); shading interp; is possible specify 'transparent' (white?) color surface @ 'zero' (instead of dark blue, seen if plot code above)? thanks on advance! instead of use "jet" built-in colormap, can define custom colormap first value white (1.0 1.0 1.0 in rgb think) in matlab page . example wrote is map = [0.2, 0.1, 0.5 % fisrt color 0.1, 0.5, 0.8 0.2, 0.7, 0.6 0.8, 0.7, 0.3 0.9, 1, 0]; % last color in each line rgb color. every value 0.0 , 1.0 , not 0 255.

verilog multiplication results is zero? -

i'm trying multiply 2 32 bit signed fractional number (1 sign bit, 8 integer bit, 23 fraction bit) the first 1 is 32'b0_00000001_00000000000000000000000 // 1.00 the 2nd 1 is 32'b0_00000100_00000000000000000000000 // 4.00 when example output signed[31:0] a; assign = 32'b0_00000001_00000000000000000000000 * 32'b0_00000100_00000000000000000000000; the results zero? why isn't 4? kindly please me in part mistaken , should do. thank much regards isaac because trying assign 64 bit value 32 bit wire, , verilog truncate value, keeping lower 32 bits of result, zero. to have proper result, can this: module mult; reg [31:0] = 32'b0_00000001_00000000000000000000000; // 1.0 reg [31:0] b = 32'b0_00000100_00000000000000000000000; // 4.0 reg [63:0] t; reg [31:0] c; initial begin t = * b; c = t[54:23]; $display ("%b",c); $finish; end endmodule

Reversing part of a string in Python -

let's have string stored in variable: a = 'python' now, a[2:4] returns th . how reverse part of string ht returned instead? this tried: print a[2:4:-1] but returned empty string. know can store result of a[2:4] in new variable , reverse new variable. there way reverse part of string without creating new variable? >>> = 'python' >>> a[2:4] 'th' reverse substring using [::-1] >>> a[2:4][::-1] 'ht' or adjust indexes: >>> a[3:1:-1] 'ht'

web services - Courier api connect with vanila php -

i have created website in vanila php maintaining record of courier portals information shipment status ,it used monitor shipment status question how going connect courier company api vanila php live status of parcel because have no idea brief steps helpful

linux - adb from Android Studio and terminal are not usable simultanously -

i'm using linux mint , have annoying problem adb: i can use adb either android studio (android monitor) or in terminal, not both @ same time. android studio terminal found no devices if android monitor in android studio running. the workaround exit android studio , type 'adb kill-server' in terminal. after can use adb in terminal, , when i'm ready custom commands have restart android studio. i have activated tools -> android -> enable adb integration. any ideas use adb through terminal when android studio running? make sure using single instance of adb . you are, probably, using 2 instances of adb . single instance of adb , can use external terminal, android studio terminal, , build/run projects android studio simultaneously without restarting anything. to verify if using single instance of adb run $ adb or $ type adb from external terminal , 1 android studio, , make sure both pointing same adb . hope helps.

javascript - How to execute function on page? -

in following use page testing http://nitroflare.com/view/a71f0994e20f2e0/security-privacy.jpg the below script clicks on slow download , removes popup ad shows after click. instead of clicking on free download, first popup window, want call second click function is function () { $(this).hide(); $("#countdowntimercontainer").show(); startfreedownload(); } my script executes $("#countdowntimercontainer").show() doesn't execute startfreedownload() reason. question how can call startfreedownload() on page? // ==userscript== // @name nitroflare // @namespace https://nitroflare.com/ // @description https://nitroflare.com/ // @include https://nitroflare.com/* // @version 1 // @grant none // @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js // @require https://greasyfork.org/scripts/5392-waitforkeyelements/code/waitforkeyelements.js?version=115012 // ==/userscript== function skipid(objid){ ...

python - How to pull a variable from one function to another -

def letterchoice(): playerletter = input('please choose x or o.').upper() if playerletter in ['x','o']: print('the game begin.') while playerletter not in ['x','o']: playerletter = input('choose x or o.').upper() if playerletter == 'x': computerletter = 'o' else: computerletter = 'x' turnchooser() def turnchooser(): choice = input("would go first, second or decide coin toss?(enter 1, 2 or c) ") while choice not in ["1","2","c"]: choice = input("please enter 1, 2 or c. ") if choice == 1: print("g") cur_turn = letterchoice.playerletter() elif choice == 2: print("h") else: print("p") movetaker() i can't figure out how i'm suppo...

javascript - Using RxJs to handle namespaced events -

i have question best practice implements namespacing behavior in rx. in current implementation, i'm using event namespacing , propagation in tree. namespace n1:n2:n3 . n1 root namespace, n2 first child , n3 first child of n2 . tree following one. # tree result n1 └─ n2 └─ n3 events sent n1:n2 triggered on n2 on n1 (if n2 doesn't stop propagation). in same way, if event sent n1:n2:n3 triggered on n3 on n2 on n1 (we don't take care stopping propagation here). i'm looking best practice use rxjs implement behavior (i'm working on back-end side). tried do: const eventemitter = require('events'); // node 6.9.1 const rx = require('rxjs'); // v4.0 class eventbus extends eventemitter { emit(event) { event = event.trim(); if(!this._isvalid(event)) { return; } let args = [].splice.call(arguments, 1); const parts = event.split(eventbus .glue); for(let = parts.length; > 0; i--) { ...

python - can't run a pull queue handler inside a custom vm -

i have deployed hello world example of app.yaml , worker.yaml and queue.yaml runtime: python27 since worker more complicated, need install third party pips , other specific dependencies opencv - need run handler within custom vm meaning dockerfile . i want start simple, running worked before , "hello world" in simple python container. i've modified worker.yaml service: worker api_version: 1 #runtime: vm # python27 runtime: custom vm: true # python27 instance_class: b1 threadsafe: yes manual_scaling: instances: 1 network: instance_tag: ssh name: olympus-dev env_variables: python_env: lab handlers: - url: /.* script: main.app #libraries: #- name: jinja2 # version: latest # and app.yaml runtime: custom vm: true # python27 api_version: 1 threadsafe: true network: instance_tag: ssh name: olympus-dev env_variables: python_env: lab handlers: - url: /.* script: main.app #libraries: #- name: jinja2 # version: latest # and dockerfile f...

python - How would you abstract this series of list continue conditions? -

i have source code has number of conditions lead skipping rest of current list iteration: for name, row in recent.iteritems(): if name in ignore: print name + "is on ignore list. skipping." continue if number_of_open_orders_in(name) == max_orders_per_market: print name + "has max number of open orders. skipping." continue if row[0].ask < 100e-8: print name + "is single or double satoshi coin. skipping." continue gain.append( ( name, percent_gain(row[0].ask, row[1].ask), row[1].ask, row[0].ask, 'https://bittrex.com/market/index?marketname={0}'.format(name), ) ) as can see, code regular. each reason skipping performs test function of row or name if test returns true , print message skip current loop iteration the following code redundancy removed: for name, row in recent.it...

String processing in Python(as a list) -

i need advice. need write program in python requests user string s consisting of left , right brackets, instance (()))(()( . after this, program needs count number of left , number of right brackets of input string. example, string (()))(() contains 4 right brackets , 4 left brackets. hint: introduce 2 counters initialized 0 in beginning. explore symbols of string in loop. current symbol increment left counter 1 f symbol ( , otherwise, increment 1 right counter. then, need test whether string math-like. let call string math-like if brackets occur in mathematical formula. instance, strings () , (())() , (()()) math-like, while strings ))(())(( , ())(() not. need write program prints "yes" if input string math-like , "no" otherwise. hint: in particular, each iteration of loop, need check values of left , right counters satisfy particular condition. i beginner, confusing me write implementation of task or @ least imagine how should look. i ap...

javascript - How to jQuery for Call div from other website -

i have questen how call div other website usng javascrpt i have page : https://yuyunxp.github.io/share/index.html then, wan call <div id="testa"> in other page otherpage.html jquery(function($){ $('#testa').load('https://yuyunxp.github.io/share/index.html'); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <html> <head> </head> <body> <div id="testa"></div> </body> </html> but got error page. hehe.. i dont know why page error.. please sir, can u me.. ? ps :) testa id, need use # selector: <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <html> <head> <script type="text/javascript"> jquery(function($){ $('#testa').load('https://yuyunxp.github.io/share/index.html...

javascript - Ajax issue with input, textarea blur -

have problem submiting information via ajax. have example 20 rows. click on row , opens information services. $('tr').click(function() { var servicesupdateid = $(this).attr('data'); $("#"+servicesupdateid).css({"display":"block", 'opacity':'0'}).animate({left: '0',opacity: '1',}); // save form class ajax submit localstorage.setitem("formid", servicesupdateid); }); here html: <tbody> <?php $allservices = services::where('user_id', $mainuser->id); foreach($allservices $oneservices) { ?> <tr class="services-table-hover" data="services_<?php echo $oneservices->id; ?>"> <td> <div class="services-color"></div> <img src="/assets/images/provider_img2.png" alt=""> </td> <td class="title-name"> <?php echo $one...

microservices - SNS + CloudFormation -

i'm using aws cloudformation build stack microservice. aws cloudformation template creates resources like: lambda function, sns topic , api gateway. this microservice work , publishes messages sns topic. other microservices subscribe topic. the problem i'm facing when upgrade microservice's cloudformation template (sometimes need redeploy it, , recreate resources), sns topic changes arn . hence, microservices use topic need change well. i think create separate cloudformation template sns topic (i have more 1 per microservice). will approach? if not, what's recommended way? as per aws cloudformation docs, there 3 properties available sns topic, , change third property (i.e. topicname ) lead replacement of sns resource (and leading generation of new arn). since you're nuking resources in cloudformation stack , re-creating them (you mentioned that's how serverless framework you're using works), can preserve sns topic arn specifying...

Filtering an array with condition in PHP -

i trying filter array output children on holidays within date range (i.e 14-11-2016 till 18-11-2016) in php. i following data in array , not have control on creation of data. [{"holiday":"15-11-2016","name":"josh stevens"},{"holiday":"17-11-2016","name":"josh stevens"},{"holiday":"22-11-2016","name":"josh stevens"},{"holiday":"14-11-2016","name":"naomi christ"},{"holiday":"15-11-2016","name":"naomi christ"},{"holiday":"16-11-2016","name":"naomi christ"},{"holiday":"17-11-2016","name":"naomi christ"},{"holiday":"14-11-2016","name":"jasmine auger"},{"holiday":"15-11-2016","name":"jasmine auger"},{"holiday":"16-...

express - How to get req.hostname when running node.js behind apache with mod_proxy -

my node.js application uses req.hostname in order redirect pages http https this: app.get('*', function(req, res){ res.redirect('https://' + req.hostname + req.url); }); this works when running application on localhost. when application runs on server behind mod_proxy req.hostname not contain domain name. instead contains localhost . how domain name? on apache settings have add this: proxypreservehost on this tell apache preserve hostname when doing proxy pass node application

android - EditText: sometimes all the Spans before the cursor are cleared -

Image
as question states, keyboard action (only backspace seems this) clears spans have set before cursor. here relevant bits of edittext: // called constructors. private void init() { setsingleline(false); setimeoptions(editorinfo.ime_flag_no_extract_ui | editorinfo.ime_flag_no_enter_action); setinputtype(inputtype.type_class_text | inputtype.type_text_flag_no_suggestions | inputtype.type_text_flag_multi_line); settextisselectable(false); setcustomselectionactionmodecallback(new actionmode.callback() { public boolean oncreateactionmode(actionmode mode, menu menu) { return false; } public boolean onprepareactionmode(actionmode mode, menu menu) { return false; } public boolean onactionitemclicked(actionmode mode, menuitem item) { return false; } public void ondestroyactionmode(actionmode mode) {} }); addtextchangedlistener(new hashtagwatcher()); } @override public boolean issuggestionsenabled() { return false; } publi...

android - I unable to pass the bundle from the MainActivity to the SignFragment. the fragment is in viewPager -

i unable pass bundle mainactivity signfragment . fragment in viewpager . i null reference. here pager using. how can send bundle activity holding viewpager fragment. , how access bundle in fragment. viewpager= (viewpager)findviewbyid(r.id.pager); final pageradapter adapter=new tabpageradapter(getsupportfragmentmanager(),tablayout.gettabcount()); viewpager.setadapter(adapter); viewpager.addonpagechangelistener(new tablayout.tablayoutonpagechangelistener(tablayout));

PHP Gearman too much mysql connections -

i'm using gearman in custom joomla application , using gearman ui track active workers , jobs number. i'm facing issue mysql load , number of connections, i'm unable track issue, i've few questions might me. 1- gearman workers launch new database connection each job or share same connection? 2- if gearman launches new connection everytime job runs how can change make jobs share same connection? 3- how can balance load between more 1 server? 4- there "pay-as-you-go" package mysql hosting? if yes, please mention them. thanks lot! this overlooked issue when using kind of job queue workers. 100 workers open separate database connection each (they separate php processes). if mysql configured allow 50 connections, workers start failing. answer questions: 1) each worker runs inside 1 php process each, , process open 1 database connection. workers not share database connections. 2) if 1 worker processing jobs, 1 database connection open...

Align tabs next to window buttons in firefox -

tabs appear below window buttons due of screen space remains unused. there way move these tabs next these window buttons ? thanks in advance. image : tabs below window buttons

amp html - Why have Amp-Sticky-Ad additional V1.0 JS Library? -

the curent version amp sticky ad is: https://cdn.ampproject.org/v0/amp-sticky-ad-1.0.js there additional version https://cdn.ampproject.org/v0/amp-sticky-ad-0.1.js all other component (that use) have version 0.1 different between 0.1 , 1.0 , why have sticky ad both? validator says both version valid. i found answer here . main changes ux issues.

c - fgets doesn't work after scanf -

#include <stdio.h> #include <string.h> #include <ctype.h> void delspace(char *str); int main() { int i, loops; char s1[101], s2[101]; scanf("%d", &loops); while (loops--) { fgets(s1, 101, stdin); fgets(s2, 101, stdin); s1[strlen(s1)] = '\0'; s2[strlen(s2)] = '\0'; if (s1[0] == '\n' && s2[0] == '\n') { printf("yes\n"); continue; } delspace(s1); delspace(s2); (i = 0; s1[i] != '\0'; i++) s1[i] = tolower(s1[i]); (i = 0; s2[i] != '\0'; i++) s2[i] = tolower(s2[i]); if (strcmp(s1, s2) == 0) { printf("yes\n"); } else { printf("no\n"); } } return 0; } void delspace(char* str) { int = 0; int j = 0; char stmp[strlen(str)]; while (str[i++] != ...

constructor - Javascript - List all properties/methods from an object -

i know object literal can have keys listed using object.keys() method. object created through constructor function? function foo () {} foo.prototype.bar = 'bar'; foo.prototype.baz = 'baz'; var foo = new foo(); console.log(object.keys(foo).join(', ')); // returns '' console.log(object.getownpropertynames(foo).join(', ')); // returns '' object.keys own enumerable properties, , getownpropertynames own properties (even if not enumerable). neither of them give names of properties inherited prototype (or prototype, or its , ...). if care enumerable properties, see trincot's answer . if want all of them,¹ if they're not enumerable, have loop through prototype chain: function getallpropertynames(obj) { var result = []; while (obj && obj !== object.prototype) { result.push.apply(result, object.getownpropertynames(obj)); obj = object.getprototypeof(obj); } return result; } ...