Posts

Showing posts from February, 2010

python - What do these mean in print? -

def greater_less_equal_5(answer): if answer > 5: return 1 elif answer < 5: return -1 else: return 0 print greater_less_equal_5(4) print greater_less_equal_5(5) print greater_less_equal_5(6) what these number: 4,5,6 mean , in ending of print? they arguments/parameters being passed function greater_less_equal_5 value of answer used inside body of function. example, greater_less_equal_5(4) runs code: if 4 > 5: return 1 elif 4 < 5: return -1 else: return 0 this has nothing print .

c# - Email sending from 1and1 SMTP server -

trying send email 1and1 smtp server in asp : mailmessage msg = new mailmessage(); msg.from = new mailaddress("admin@mywebsite.com"); msg.to.add("personalmail"); smtpclient smtp = new smtpclient("auth.smtp.1and1.fr",465); smtp.credentials = new networkcredential("admin@mywebsite.com", "mypassword"); smtp.enablessl = true; try { // smtp.send(msg); smtp.send(msg); return "ok"; } catch (exception e) { return e.tostring(); } the code goes in catch error called :"net_io_connectionclosed" know problem ? regards hyrozen, you have use port 587.

sql - Merge Insert Into TABLE with an PHP ARRAY and for loop -

i have php array, coming database. array want insert different db/table. 2 fields (webinv_id,hostname) unique. update these table daily per script. if entry exist, must skip insert , should use update. that's working well. if run in php loop, insert or update first entry of array new table use merge table ... for that. input array: [0] => array ( [ci_id] => 39778 [nodealias] => rt-2 [node] => 10.1.2.3 [serialnumber] => 8374378584 [vendorname] => cisco [status] => active ) [1] => array ( [ci_id] => 72909 [nodealias] => rt-1 [node] => 10.1.1.3 [serialnumber] => 1276731237 [vendorname] => cisco [status] => active )... here loop try insert or update of devices. for ($i = 0; $i < count($router); $i++) { $sql = "merge devices using ( select " . "'" . $router[$i]['ci_id']...

asp.net mvc - Action method not getting called when I refresh page (MVC/Javascript) -

i have pop window uses following code call action method when checkbox checked: window.location.href('@url.action("process", "wip")'); this works fine, need window refresh when checkbox checked. added following under previous line: window.location.reload(true); but somehow causes first line not call action method @ all. 2 "window.location" lines tripping on each other or something?

Search & Compare Multiple MySQL Tables -

i'm trying use php search ips , ad networks in mysql database. rotate visitors between various ad networks prevent same visitor being sent same network within 24 hour period. ip_addresses table id, address, network_id 1, 120.110.140.223, 1 2, 120.110.140.223, 3 3, 115.157.247.46, 1 networks table id, name, clicks, status, order 1, random name, 200, active, 1 2, example name, 500, inactive, 3 3, other name, 100, active, 2 basically when visitor hits our php page, need able echo specific id networks table. should the id of first network isn't listed in ip_addresses table visitor's ip address. networks should ordered order column , should have status = active . i thought using php list of id 's of networks status set active , correctly ordered this: select id networks status = 'active' order id asc and loop through until reach first id isn't in ip_addresses table ip. however, wasn't sure how loop or how make stop once first n...

python - How to get sender info from request object -

with 3 <a> calling same function: <a id="1" href="call" 1 </a> <a id="2" href="call" 2 </a> <a id="3" href="call" 3 </a> on back-end in python using flask looks this: @app.route("/call") def call(): print request now inside of python call() function request object. can use request idea of 3 <a> clicked call function? you can't information cliked link request. have add unique argument every link ie. href="call?number=1" or href="call/1" , can number in flask. href="call?number=1" needs @app.route("/call") def call(): print request.args.get('number', 'no number!') see: http://flask.pocoo.org/docs/0.11/quickstart/#the-request-object href="call/1" needs @app.route("/call/<int:val>") def call(val): print val see: http://flask.pocoo.org/docs/0.11...

Is it possible to mix multiple audio files on top of each other preferably with javascript -

i want combine audio clips, layered on top of each other play synchronously , saved in new audio file. appreciated. i've done digging online, couldn't find definitive answer whether or not many of tools available far javascript audio editing librarys go (mix.js example) capable. yes, possible using offlineaudiocontext() or audiocontext.createchannelmerger() , creating mediastream . see phonegap mixing audio files , web audio api . you can use fetch() or xmlhttprequest() retrieve audio resource arraybuffer , audiocontext.decodeaudiodata() create audiobuffersourcenode response; offlineaudiocontext() render merged audio, audiocontext , audiocontext.createbuffersource() , audiocontext.createmediastreamdestination() , mediarecorder() record stream; promise.all() , promise() constructor, .then() process asynchronous requests fetch() , audiocontext.decodeaudiodata() , pass resulting mixed audio blob @ stop event of mediarecorder . connect each audiocon...

html - How to move each box to the right, or to each first box does not move, but it remains the same -

how move each box right, or each first box not move, remains same. red marked boxes move right 5 pixels, , each blue remain in same place. wish each box in first row remains in place, without having move right https://s11.postimg.org/lyh9uaxwj/dsada.png #istaknuti_proizvodi_box_prikaza { width:100%; height:auto; position: relative; background: #ccc; top:75.1px; } #istaknuti_proizvodi_prikaz { width:236px; height:250px; border:1px solid #000; position: relative; box-sizing: border-box; -webkit-box-sizing:border-box; -moz-box-sizing:border-box; float:left; margin-top:2px; } #istaknuti_proizvodi_prikaz:nth-child(n+2){ margin-left:5px; } <div id="istaknuti_proizvodi_box_prikaza"> <div id="istaknuti_proizvodi_prikaz"></div> <div id="istaknuti_proizvodi_prikaz"></div> <div id="istaknuti_proizvodi_prikaz"></div> <div id="istaknuti_proizvodi_prikaz...

python - How can you add movement to shapes in pygame? -

i using python 2.7 tried make simple game using pygame module. in program makes rectangle, , having trouble doing getting move upon keys being pressed. believe problem 'player.move' part in code, documentation poor on pygames website. appreciated. import pygame import random import time pygame.init() white = (255,255,255) black = (0,0,0) displaywidth = 800 displayheight = 800 fps = 30 clock = pygame.time.clock() blockwidth = 50 blockheight = 50 pygame.display.set_caption('test game') screen = pygame.display.set_mode([displaywidth, displayheight]) background = pygame.surface(screen.get_size()) background.fill((white)) background = background.convert() screen.blit(background, (0,0)) global xstart, ystart xstart = 400 ystart = 400 global player player = pygame.draw.rect(screen, black, ([xstart,ystart,blockwidth,blockheight])) pygame.display.update() def mainloop(): global x, y x = xstart y = ystart mainloop = true pygame.display.update() ...

tableview - Table View: right to left swipe to delete does not show up - swift 3 -

i've built simple todolist app swift 3. want able delete items tableview swiping right left. code i've found. nothing happens when swipe left. code: func tableview(_ tableview: uitableview, numberofrowsinsection section: int) -> int{ return todolist.count } func tableview(_ tableview: uitableview, caneditrowat indexpath: indexpath) -> bool { return true } func tableview(_ tableview: uitableview, cellforrowatindexpath indexpath: indexpath) -> uitableviewcell { let cell = uitableviewcell(style: uitableviewcellstyle.default, reuseidentifier: "cell") cell.textlabel?.text = todolist[indexpath.row] return cell } // func tableview(_ tableview: uitableview, commit editingstyle: uitableviewcelleditingstyle, forrowat indexpath: indexpath) { if (editingstyle == .delete) { todolist.remove(at: indexpath.row) userdefaults.standard.set(todolist, forkey: "todolist") tableview.reloaddata() } }...

firebase - Lose password after sign in using Google provider -

i have android app use firebase authentication using email , password. added google provider users can sign in wih google account, problem following there's existing user example@gmail.com registered on app, later user sign in google account firebase automatically change provider of account email google, problem user sign out , try login email/password , got message the password invalid or user not have password i understand why happens, users (you know users) frustrated because can't login email/password there's way tell firebase keep user password or when user login google , convertion happens in order notify user note app allow 1 account per email i found there's method fetchprovidersforemail asume can build flow on method check provider have user , allow user chose if want keep if old password asking , linking account or continue

html - Zoom in/out doesn't work on my mobile phone (Blogger) -

i try add text below on head-tag, zoom in/out not working on mobile phone. <meta content='width=device-width, initial-scale=1' name='viewport'/> ex: http://chenweilun.blogspot.tw/2016/11/test.html it works, when add following text in article: <meta content='width=device-width, initial-scale=1' name='viewport'/> ex: http://chenweilun.blogspot.tw/2016/07/blog-post.html it stops working. did miss something? there reference link zoom in/out on blogger: http://fuseinteractive.ca/blog/avoiding-landscape-zoom-in-effect-on-mobile#.wcgks_b97iu in blogger template set scale meta tag <meta expr:content='data:blog.ismobile?quot;width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0&quot;:&quot;width=1100&quot;' name='viewport'/> replace above next meta tag after <head> element directly allow user-scalable. can change maximum-scale value. <meta content='widt...

xaml - Binding fires on unloaded view/view-model when creating a new view -

if bind radiobutton view-model property using type converter, every time create view, setter on previous viewmodel gets called, though view unloaded , should not exist anymore. here minimum code reproduce issue: 1) define enum type: enum enumtype { value1, value2, } 2) define convereter: public class enumtypetobooleanconverter : ivalueconverter { public object convert(object value, type targettype, object parameter, string language) { return true; } public object convertback(object value, type targettype, object parameter, string language) { return enumtype.value1; } } 3) define view-model: class viewmodel : inotifypropertychanged { private enumtype value; public viewmodel() { debug.writeline(string.format("viewmodel ({0})::ctor", this.gethashcode())); } public enumtype value { { debug.writeline(string.format("viewmodel ({0})::value::get", this.gethashcode())); ...

angularjs - Component does not displays in UI page -

i started learning angular2 , tried "hello world" program. have created .ts file this: appcomponent.ts import { ngmodule, component } '@angular/core'; import {browsermodule} '@angular/platform-browser'; import {platfrombrowserdynamic} '@angular/platfrom-browser-dynamic'; @component({ selector:'hello-world', template:` <div> hello world </div>` }) class helloworld { } @ngmodule({ declaration: [helloworld], imports:[browsermodule], bootstrap:[helloworld], }) class helloworldappmoduel{ } platformbrowserdynamic().bootstrapmodule(helloworldappmoduel); but when deployed , ran code in tomcat, didn't show anything, should show "hello world". not able why nothing appeared in ui. /* importing component decorator function anularjs library module */ system.register(['@angular/core', '@angular/platform-browser'], function(exports_1, context_1) { "use strict"; ...

c++ - Parsing string to get comma-separated integer character pairs -

i'm working on project i'm given file begins header in format: a1,b3,t11, 2,,5,\3,*4,344,00, . going sequence of single ascii character followed integer separated comma sequence ending 00, . basically have go through , put each character/integer pair data type have takes both of these parameters , make vector of these. example, header gave above vector ('a',1), ('b',3),('t',11),(',',5)(' ',2),('\',3),('*',4),('3',44) elements. i'm having trouble parsing it. far i've: extracted header text file first character until before ',00,' header ends. can header string in string format or vector of characters (whichever easier parse) tried using sscanf parse next character , next int adding vector before using substrings remove part of string i've analyzed (this messy , did not me right result) tried going through string vector , checking each element see if integer, character, or comma , acting ...

count - c++ linked list counting letters -

c++ linked list counting numbers struct letternode { char letter; size_t frequency; letternode* next; letternode(char ch, size_t frq, letternode* ptr) { letter = ch; frequency = frq; next = ptr; } const string tostring() { return ("letter " + to_string(this->letter) + " occured: " + to_string(this->frequency)+" times."); } }; c++ linked list counting numbers what 2 functions marked do? letternode(char ch, size_t frq, letternode* ptr) set letternode object, method (function) called constructor. const string tostring() returning string information letternode object can't sure don't know to_string doing. another question size_t frequency in letternode struct increase , shows how many of them in string? frequency not increasing in code provided set when letternode creating new object in void insert(char ltr, size_t frq) i sorry answer not solved problems feel free add important information code main function. ...

spring boot - get java.lang.ArrayStoreException on Springboot and ehcache -

i have method calls webservice , same input arguments, want result cached. so, here did far: main class: import org.springframework.boot.autoconfigure.springbootapplication; import org.springframework.boot.context.web.springbootservletinitializer; import org.springframework.cache.cachemanager; import org.springframework.cache.annotation.enablecaching; import org.springframework.cache.ehcache.ehcachecachemanager; import org.springframework.cache.ehcache.ehcachemanagerfactorybean; import org.springframework.context.annotation.bean; import org.springframework.context.annotation.componentscan; import org.springframework.core.io.classpathresource; @enablecaching @componentscan @springbootapplication public class accserver extends springbootservletinitializer { @bean public cachemanager cachemanager() { return new ehcachecachemanager(ehcachecachemanager().getobject()); } @bean public ehcachemanagerfactorybean ehcachecachemanager() { ehcachemanagerfactorybe...

date - Force oracle sql developer to show timestamp -

i new sql developer each time queries changes time stamp readable date format, want result in time stamps in database. please go to: tools/preferences/database/nls , set there date format , timestamp format want. oracle stores date , timestamp type display according nls settings. either call alter session set nls_timestamp_format = 'yyyy-mm-dd hh:mi:ss.ff'; or set nls settings in client tool. documentation

php soap entity parameters send -

this soap function. createsales(string useremail, string userpass, string apikey, entity.sales sales , list salesitem , entity.customer customer , entity.payment payment , int branchid, int userid) entity.sales sales list salesitem entity.customer customer entity.customer customer how can send values parameters? my example code, $result = $client->createsales( array( "useremail" => $this->useremail, "userpass" => $this->userpass, "apikey" => $this->apikey, "sales" => $client->sales( array( "salesid" => $salesid, "departureregionid" => $departureregionid, "departuredate" => $departuredate, "departuretime" => $departuretime, "arrivalregionid" => $arrivalregionid, "transfertypeid" => $tra...

android - encoding/decoding on the B4a and vb.net -

i'm running following code in b4a sub encrypt(datatoencrypt string) string dim su stringutils dim kg keygenerator dim c cipher dim md messagedigest dim encrypted() byte dim chashkey string ="1234" if chashkey.trim = "" return false kg.initialize("aes") kg.keyfrombytes(md.getmessagedigest(chashkey.getbytes("utf8"), "md5")) c.initialize("aes/ecb/pkcs7padding") encrypted = c.encrypt(datatoencrypt.getbytes("utf8"), chashkey.getbytes("utf8"), false) return su.encodebase64(encrypted) end sub i'm going result sent web service... , want decode is encrypted communication between web , mobile service i searched found nothing in vb.net

javascript - Extending namespaced module from within -

code: ;(function (ns, undefined) { ns = { foo1: "bar1" } this.ns = { foo2: "bar2" }; ns.foo3 = "bar3"; return ns; })(window.ns = window.ns || {}); results: calling ns result: object {foo2: "bar2"} iife returns: object {foo: "bar1", foo3: "bar3"} 1. understand correctly? ns new, private object inside iife returned this.ns belongs window.ns , expands 2. why this keyword in this.ns ? since iife invoked in global context, this keyword linked global, hence: document.ns (the namespace) 3. how access this.ns properties inside iife? e.g console.log(this.ns.foo2) - proper way? 4. since passed window.ns ns argument, why have use this.ns , not ns only? what argument iife called with? the window object not have .ns property on @ runtime. therefore window.ns evaluate undefined , in || expression coerce false while {} coerce true . || expression therefore en...

amazon web services - What is the easiest option to stream videos in different resolutions from CloudFlare -

would easier have convert them needed resolutions, or can cloudflare stream in lower resolutions automatically? a quick search turns this: sites streaming content, however, should move streaming content subdomain don't proxy[,] in dns settings. we have seen sites have performance issues because of number of connections streamed content causes when running through cloudflare proxy. https://support.cloudflare.com/hc/en-us/articles/200169706-can-i-use-cloudflare-with-a-streaming-music-or-video-site- given saying "don't route streaming request through cloudflare, because we've received reports doesn't scale if do," seems reasonable assumption not offer automated manipulation (transcoding) of streams... so, yes, you'll have transcode yourself. if there services handle conversion "lower resolutions automatically," exception, not norm: transcoding video resource-intensive process has subjective tunable parameters not h...

routes - Rails show maximum amount of a Bid for every id product -

i'm trying print out in index view page next every product maximum amount of bid product. outcome should in index view: banana (maximum amount banana) table (maximum amount table) etc i know how print out maximum of total of products, not maximum amount of each product. being said attach code: routes: rails.application.routes.draw # details on dsl available within file, see http://guides.rubyonrails.org/routing.html "/new", to: "users#new" # "/index", to: "products#index" "/products", to: "products#index", as: :products "/new_products", to: "products#new" # el form_for siempre necesitará un path en forma de as: ... ya que no le sirve solo la url post "/products", to: "products#create" "/products/show/:id", to: "products#show", as: :product post "/bids/new_bid", to: "bids#create" # post ...

visual studio 2012 - cannot link petsc libraries to my c++ project -

i using petsc libraries. when compiled project ve got these errors. enter image description here i checked libraries , .h files. set right path.

How to apply searching facility to a listview in android -

i want know how add search functionality listview in android here listview being loaded internet. essential ,thank please @ psudo code:--- public class searchableadapter extends baseadapter implements filterable { private list<string>originaldata = null; private list<string>filtereddata = null; private layoutinflater minflater; private itemfilter mfilter = new itemfilter(); public searchableadapter(context context, list<string> data) { this.filtereddata = data ; this.originaldata = data ; minflater = layoutinflater.from(context); } public int getcount() { return filtereddata.size(); } public object getitem(int position) { return filtereddata.get(position); } public long getitemid(int position) { return position; } public view getview(int position, view convertview, viewgroup parent) { // viewholder keeps references children views avoid unnecessary calls // findviewbyid() on each row. viewholder holder; // wh...

hiveql - NULL column names in Hive query result -

i have downloaded weather .txt files noaa , looks like: wban,date,time,stationtype,skycondition,skyconditionflag,visibility,visibilityflag,weathertype,weathertypeflag,drybulbfarenheit,drybulbfarenheitflag,drybulbcelsius,drybulbcelsiusflag,wetbulbfarenheit,wetbulbfarenheitflag,wetbulbcelsius,wetbulbcelsiusflag,dewpointfarenheit,dewpointfarenheitflag,dewpointcelsius,dewpointcelsiusflag,relativehumidity,relativehumidityflag,windspeed,windspeedflag,winddirection,winddirectionflag,valueforwindcharacter,valueforwindcharacterflag,stationpressure,stationpressureflag,pressuretendency,pressuretendencyflag,pressurechange,pressurechangeflag,sealevelpressure,sealevelpressureflag,recordtype,recordtypeflag,hourlyprecip,hourlyprecipflag,altimeter,altimeterflag 00102,20150101,0001,0,ovc043, ,10.00, , , ,27, ,-2.8, ,26, ,-3.1, ,25, ,-3.9, , 92, , 0, ,000, , , ,30.05, , , , , ,30.36, ,aa, , , ,30.23, 00102,20150101,0101,0,ovc045, ,10.00, , , ,27, ,-2.8, ,26, ,-3.1, ,25, ,-3.9, , 92, , 6, ,080, , ,...

email - JavaMail and Gmail: first attempt results in "Remote host closed connection during handshake" but after next attempt everything works -

i trying send emails using java web application. use java 8, spring 4 , wildfly 9.2 server app. environment set on local machine. problem when run code first time, returns following exception: javax.mail.messagingexception: not convert socket tls; nested exception is: javax.net.ssl.sslhandshakeexception: remote host closed connection during handshake but next attempts result in success, email sent. use following code: try { string user = "user"; string password = "password"; string emailaddress = "to@gmail.com" properties emailproperties = new properties(); emailproperties.setproperty("mail.smtp.host", "smtp.gmail.com"); emailproperties.setproperty("mail.smtp.port", "587"); emailproperties.setproperty("mail.smtp.starttls.enable", "true"); emailproperties.setproperty("mail.smtp.debug", "true"); emailproperties.setproper...