Posts

Showing posts from April, 2013

java - Testing Throughput of postgres database using thread pool and connection pool. But why do I only have 300 inserts per second when it should be 6000? -

i want test throughput of system has connection postgresql database. system consists of 2 main components: threadpoolexecutor newfixedthreadpool maximum of 10 threads , pgpoolingdatasource called connectionpool has maximum of 10 connections database. call stored procedures in postgres database, stored procedure simple insert , returns error message if insert failed. executing single call of stored procedure takes 20-30 ms. the system works this: main thread creates message tasks , passes them thread pool. message task following: gets connection connection pool , calls stored procedure on postgres server. waits response , task finished. thread in thread pool can work on new message task. now, think should work fine , extent. slow , have absolutely no idea why. using following code record 300-500 inserts second when should 6000 inserts per second. have no idea why. when using systems monitor, see cpus @ 20% load. when uncomment section indicated (1), 1 cpu @ 100% load while othe

AngularJS validation errors -

i have working form ngmessages. my issue when displayed form , empty, not want show errors, when user has focused out input. is possible? use $touched : snippet: var app = angular.module('app', ['ngmessages']); app.controller('mainctrl', function($scope) { // js code }); <!doctype html> <html ng-app="app"> <head> <script src="https://code.angularjs.org/1.5.7/angular.js"></script> <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" /> <script src="http://code.jquery.com/jquery-2.0.3.min.js"></script> <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script> <script src="https://code.angularjs.org/1.4.7/angular-messages.js"></script> </head> <body ng-controller="mainctrl"> &l

Django Channel web sockets - append message to Model.objects -

lately, i've been investigating onto integrating web sockets django. according documentation, using channels way go. given illustrative model query class request(models.model): id = models.integerfield(name="id", primary_key=true) query = models.charfield(name = 'query', max_length=1024) i want have web application connected web socket server. when web socket server receives message, should broadcast message particular subset of socket connections established client. the client (namely web browser), once receiving broadcasted message, should append request.objects . there on, list of queries should automatically updated using django templates , within defined model - without forcing user explicitly refresh it. hence, questions of mine are: (i) using channels (if preferred way of dealing web socket connections in django), how can append newly arrived query object query.objects - without storing object database because has been inserted prio

java - How to obfuscate request properties in tomcat log file -

i have rest based weapp runs on tomcat. every time hit of rest endpoints on server - log request details written in log file. how can configure tomcat obfuscate sended values of json request. ex. instead of: { "country": "usa" } be: {"country":"******"} thanks! inorder apply masking on filter . need perform this.. http://vozis.blogspot.com/2012/02/log4j-filter-to-mask-payment-card.html

vba - Writing from one instance of Excel to another open instance -

Image
i using workbook display operator data. work book open , needs stay open. im trying open different instance of excel , have write , update values on open display workbook. path workbook g:\tls-shared\maintenance\powder line display\input.xlsm , open workbook g:\tls-shared\maintenance\powder line display\display.xlsm need transfer 7 columns, 30 rows of each column input.xlms sheet name "data" open book sheet name displaydata. need regularly update or click button update. copy data input workbook , in display workbook (has in same excel instance) click paste > paste link now in data tab can click refresh update data when needed you can change connection property refresh every minute: works if input workbook closed.

php - Invalid query: You have an error in your SQL syntax; syntax to use near -

i have problem error , don't know how solve it. know many have issues issue can not orient. problem: invalid query: have error in sql syntax; check manual corresponds mysql server version right syntax use near 'from `user` `id` = 0' @ line 6 code: <?php function fetch_users(){ $result = mysql_query('select `id` `id`, `username` `username` `user`'); $users = array(); while(($row = mysql_fetch_assoc($result)) !== false){ $users[] = $row; } return $users; } // fetches profile information given user. function fetch_user_info($id){ $id = (int)$id; $sql = "select `username` `username`, `firstname` `firstname`, `lastname` `lastname`, `email` `email`, `user` `id` = {$id}"; $result = mysql_query($sql); if (!$result) { die('invalid query: ' . mysql_error()); } return mysql_fetch_assoc($result); } ?> remove

android - Can navigation drawer be set behind the content? -

is possible set main content frame on top of navigation frame, making content slide navigation tab? i think this library looking for. check out its demo on play store see how works.

java - ART kills WebView before loading finished -

i'm trying retrieve html website uses javascript. method goes follows: create headless webview (without view defined in xml) , enable js. create javascriptinterface method called when loading finishes. override onpagefinished method of webclientview provide. code here injects javascript call method defined in javascriptinterface, passing html contents of page parameter. what's interesting is, code works, inconsistently. 1 time work intended, , next time nothing happen. getting sorts of weird logcat messages, 1 of suspected bad sign: w/art: attempt remove non-jni local reference, dumping thread . today idea popped mind: maybe webview gets killed because runtime environment optimizations (and webview has no xml view object linked it)? and so, decided try creating webview in xml , use same code instead of creating 1 in code. right code works consistently, every time run it, , no longer receive thread dumping log messages. see page finishes loading, code executed. d

c# - Can't refresh database model -

i can't refresh database model. using asp .net 5. this short example of done: 1.create class person in "person.cs" file, inside "model" directory. namespace myweb.models { public class person { public int personid { get; set; } public string login { get; set; } public string password { get; set; } public string name { get; set; } public string surname { get; set; } public datetime dateofbirth { get; set; } } } 2. create mycontext.cs file in models directory. namespace myweb.models { public class mycontext : dbcontext { public dbset<person> persons { get; set; } } } 3.create myinitializer.cs inside models directory namespace myweb.models { public class myinitializer :dropcreatedatabaseifmodelchanges<mycontext> { protected override void seed(mycontext context) { var persons= new list<person> {

pyspark - Joining multiple key-value pair files in spark -

i have multiple features_xx , id_xx files, , each of them maintain order in correspondence. example - features_00 file has 50 rows each 5 numbers. id_00 file contains id each of these 50. order important in both files. have 1-1 mapping. , there 100 of these pair files. i want have mapping in 1 dataframe. how can stitch/zip them in common spark dataframe id 1 of columns alongside features.

c++ - What happens when an uninitialised pointer variable is deleted in an infinite loop? -

suppose if execute infinite loop(sentinel) in there uninitialised pointer being deleted after every single execution of loop, question , possible pointer access system variables being used run computer? searched answer , found close 1 dangling pointers answers did not specify whether can have access or not system variables , , if has can deleted cause problem computer irrepairable? edit:( think created wrong impression doubt upon readers , never intend or have done in case such condition arises happen? question.) what happens when uninitialised pointer variable deleted ... assuming "deleted" mean delete ptr; , behavior undefined. if you're asking whether x could happen, answer yes, physically possible value of x. (operating systems have safeguards against rogue behavior individual programs. safeguards not 100% reliable.) ... in infinite loop? that makes no difference.

gcloud - Google App Engine service (module) not starting, and flooding 404's to /_ah/start -

Image
i'm refactoring existing codebase. switched using appcfg.py using gcloud command, seemed go fine. our entire codebase running on 1 default frontend instance, i'm trying break services. start, created 1 "worker" backend service, , i'm using cron job test. i can see worker in console, no instance started. logs service rapidly flooded 404's /_ah/start. i've tried manual , basic scaling. documentation states it's okay not have startup script, , 404 @ endpoint considered success. however, instance not starting. logs worker.yaml service: worker runtime: python27 api_version: 1 instance_class: b2 manual_scaling: instances: 1 threadsafe: false handlers: - url: /work/.* script: worker.app secure: login: admin worker.py import webapp2 import handlers config = { #... } app = webapp2.wsgiapplication([ webapp2.route( '/work/test<:/?>', handlers.test, methods=['get'], ), ], d

python - How to add an empty new line between concatenated files? -

i'm concadenating files this: filenames = ['ch01.md', 'ch02.md', 'ch03.md', 'ch04.md', 'ch05.md'] open('chall.md', 'w') outfile: fname in filenames: open(fname) infile: outfile.write(infile.read()) the problem is, end this: ## title 1 text 1 ## title 2 text 2 and want this: ## title 1 text 1 ## title 2 text 2 how modify script that? add them explicitly iterating on every line in infile , adding 2 line-breaks \n\n every time write line outfile : with open(fname) infile: line in infile: outfile.write(line + "\n\n") edit: if need write after every file can write new lines after every file process, write() takes string argument , writes it: open(fname) infile: outfile.write(infile.read()) outfile.write("\n\n")

python - Best way to get info out of dictionary -

i struggling wrap head around best way title, artist name out following list. {'status': 'ok', 'results': [{'score': 0.94222, 'id': 'ca222fc1-d1ed-4c30-b21f-eb533cc909aa', 'recordings': [{'artists': [{'id': '84dc4f23-c0b8-4fe1-bbca-a3993ddc8fc2', 'name': 'primus'}], 'id': '2f6227ba-e061-48b2-a700-15e209ed3650', 'title': 'wynona’s big brown beaver', 'duration': 264}, {'artists': [{'id': '84dc4f23-c0b8-4fe1-bbca-a3993ddc8fc2', 'name': 'primus'}], 'id': '520ebd07-d12c-429c-a137-19d13303a706', 'title': 'wynona’s big brown beaver', 'duration': 261}, {'artists': [{'id': '84dc4f23-c0b8-4fe1-bbca-a3993ddc8fc2', 'name': 'primus'}], 'id': '757439ce-58b1-4808-af3b-3b90092890c1', 'title': 'wynona’s big brown beav

php - PDO insert not working with OOP -

if try insert line database, don't error or anything, not working... here codes: the insert line: $inserted = $user->create(array( 'fb_id' => $userid, 'name' => $userdata->getname(), 'mail' => input::get('first-time-email'), 'password' => hash::make(input::get('first-time-pattern')), 'img' => $userpicture, 'last_ip' => $_server['remote_addr'], 'code' => $salt )); the user class: public function create($fields = array()) { return $this->_db->insert('users', $fields); } the db class: public function insert($table, $fields = array()) { $keys = array_keys($fields); $values = null; $x = 1; foreach($fields $value) { $values .= "?"; if($x < count($fields)) { $values .= ', '; } $x++; }

Unit Testing Entity Framework with ms unit test framework -

i using ms unit test unit test project in i'm using entity framework. able mock using following example in msdn have scenario need use transactions in entity framework in following way var tran = testdbcontext.database.begintransaction() and test fails database null testdbcontext. i wondering if can mock somehow working using linked msdn article reference notice have abstracted dbcontext. using same thinking should abstract creation of transaction. first create abstraction of expected functionality transaction object. /// <summary> /// wraps access transaction object on underlying store connection /// </summary> public interface idbcontexttransaction : idisposable { /// <summary> /// commits underlying store transaction /// </summary> void commit(); /// <summary> /// rolls underlying store transaction /// </summary> void rollback(); } this mirrors functionality want database transaction.

monkeypatching - Overriding len in __init__.py - python -

i assign function len in __init__.py file of package following way: llen = len len = lambda x: llen(x) - 1 it works fine, in __init__.py file. how can make affect other modules in package? when try load name not defined module-level global or function local, python looks in __builtin__ ( builtins in python 3) module. in both versions of python, module availabe __builtins__ in global scope. can modify module , this affect not code python code anywhere runs after code runs!! import __builtin__ builtins # import builtins in python 3 llen = len builtins.len = lambda a:llen(a) - 1

android - Assemble several flavors with gradle -

i'm trying configure gradle build circle ci, , i'm running problems. what want assemble several of app flavors, , can't figure out how. i want run ./gradlew assemblerelease but not variants, this ./gradlew assemblevararelease, assemblevarbrelease i know possible because android studio release tool can, don't know how thanks lot if have 2 product flavours phone , tablet having tasks as ./gradlew assemblephonerelease assembletabletrelease for more details: gradle build flavour

php - Laravel 5.1 Sentinel::getUser() return null -

i using sentinel authenticate users , auth middleware. middleware code: public function handle($request, closure $next) { var_dump(sentinel::guest()); // prints false if (sentinel::guest()) { if ($request->ajax()) { return response('unauthorized.', 401); } else { return redirect()->guest('/login'); } } return $next($request); } controller code: public function getaccount() { var_dump(sentinel::guest()); // prints true return sentinel::getuser(); } routes.php route::group(['middleware' => ['auth']], function () { route::get('api/v1/temp/users/account', 'app\http\controllers\userscontroller@getaccount'); } then if browse api/v1/temp/users/account var_dump() in middleware printing false, while var_dump() inside controller printing true seems nonsense. what's wrong? it turned out using native facade instead of laravel facade

html - Elements Extend Beyond Page -

Image
i'm moving elements around on site , have found 2 of them invisibly extending beyond right edge of page. site www.abadcaseofthedates.com , 2 elements above fold: html8 (site search) , archivelist (the pull-down archive menu). realize they're extending far result of them being children of column-center-inner, can't figure out how downsize extensions of these 2 elements (but not else in column-center-inner) off side of page. html8: <div class="widget html" id="html8"> <h2 class="title">search site</h2> <div class="widget-content"> <form action="http://www.google.com" id="cse-search-box" target="_blank" _lpchecked="1"> <div> <input type="hidden" name="cx" value="partner-pub-8645914820193959:3645685348"> <input type="hidden" name="ie" value="utf-8"> <input type=&quo

c# - TextBox with bottom border -

Image
i want have textbox bottom border graphics drawn textbox distorted/broken on resize because of color.transparent . using code found, able create underlined textbox (drawn rectangle tranparent top, left, right). problem when resize form/window: when resize smaller, resize again expand it, graphics drawn distorted. any fix this? here photos: the second photo has been resized smaller, larger size. here's code: [dllimport("user32")] private static extern intptr getwindowdc(intptr hwnd); struct rect { public int left, top, right, bottom; } struct nccalsize_params { public rect newwindow; public rect oldwindow; public rect clientwindow; intptr windowpos; } float clientpadding = 0; int actualborderwidth = 2; color bordercolor = color.black; protected override void wndproc(ref message m) { //we have change clientsize make room borders //if not, border limited in how thick i

github - Git error message "remote origin already exists" -

i created repo on github, tried connect , got error: $ git remote add origin https://github.com/jatalamo/heroku-test-site.git fatal: remote origin exists. this did not happen yesterday when created different repo. can me figure out how push existing repo on gibash? i'm total newbie! the reason you're getting remote origin exist because remote name of origin exists. can check typing git remote -v show remotes of git repo. should see this: origin https://github.com/jatalamo/heroku-test-site.git (fetch) origin https://github.com/jatalamo/heroku-test-site.git (push) the command clone github repo git clone https://github.com/jatalamo/heroku-test-site.git <folder_name> . if remote called origin automatically setup you, therefore not need add https://github.com/jatalamo/heroku-test-site.git remote manually typing git remote add origin https://github.com/jatalamo/heroku-test-site.git . the case in need type git remote add origin https://github.com/j

c# - read the txt file and sort it -

like title txt file the grades 0~100 sample: name,grades name,grades name,grades and have sort grades is way solve split them array sorting? i have load file string char[] spli = { ' ', ',', '\t' }; string line; string[] sline; streamreader file = new streamreader(textbox1.text,encoding.default); line = file.readtoend(); sline = line.split(spli); foreach (string item in sline) { listbox1.items.add(item); } plz when read data text file , parsing it, validation. never know data in file. see code. class mylistuser { public string name; public int grades; } private list<mylistuser> readuserfile() { list<mylistuser> lstuser; string[] smydata = file.readalllines("myfile.txt"); if (smydata != null) { mylistuser otmp; string[

java - STSheetViewType class is missing in poi-ooxml-schemas-3.14 JAR -

currently i'm trying implement code given in answer this question: ctsheetview view = sheet.getctworksheet().getsheetviews().getsheetviewarray(0); view.setview(stsheetviewtype.page_layout); but poi-ooxml-schemas (version 3.14) jar file not contain class stsheetviewtype. delved poi-ooxml-schemas jar file (using 7zip) , found class file stsheetviewtype$enum.class existed within path: org.openxmlformats.schemas.spreadsheetml.x2006.main.stsheetviewtype$enum.class but (if i'm not mistaken) '$' signifies inner/nested class, meaning stsheetviewtype enum encapsulated within class. checked documentation on stsheetviewtype class in older version of poi-ooxml-schemas (version 1.1) here , found class stsheetviewtype contained inner enum stsheetviewtype.enum. this seems confirmed errors i'm receiving within eclipse. these errors when using code shown above: "stsheetviewtype cannot resolved variable" "the type org.openxmlformats.schemas.spreadsh

Pause command not working in Selenium IDE -

i trying run test (on servicenow platform) using selenium ide. in order execute background scripts put sleep time using pause() command. it's not working. please find screen shot reference. test case screen shot

php - Regex to seperate concatenated phone number and email -

i have strings unfortunately phone number , email concatenated this: $phone_email = "617.651.3123mya123@some-site.com"; i'd able split between last number , first letter. desired output $phone = "617.651.3123"; $email = "mya123@some-site.com"; i'm using php strategy straightforward in language. edit i've tried many things including trying grab email removing digits. $email = preg_replace('#^\d+#', '', $phone_email); results in removing 617 ignoring . as others have pointed out, splitting between "the last number , first letter" may not strategy, since email addresses can start numbers. said, believe asked for: $phone_email = "617.651.3123mya123@some-site.com"; $matches = []; preg_match("/([^a-za-z]*)(.*)/", $phone_email, $matches); $phone = $matches[1]; $email = $matches[2]; echo "phone: $phone\n"; echo "email: $email\n"; // output: // phone: 61

GitLab CI Pipeline Stage Timeout -

i'm using self-hosted gitlab ci server (community edition v8.9.5) , gitlab-ci-multi-runner 1.2.0 build project. 1 of pipeline stages (test) takes while run , following erm: error: build failed: execution took longer 3600 seconds where put override timeout? can apply test pipeline stage? this set in gitlab. see "project settings -> ci/cd pipelines -> timeout" or "project settings -> builds -> timeout" in older versions. i'm afraid it's not possible set per stage or job.

amazon web services - Installation: Redmine on Ubuntu EC2 instance -

i need install redmine in amazon vps. i'm following post: https://fosskb.in/2015/02/23/installing-redmine-on-ubuntu-14-04/ have error when try install apt. i followed instructions of same post in virtualbox machine , had problem, found well. this error: dbconfig-common: writing config /etc/dbconfig-common/redmine/instances/default.conf creating config file /etc/dbconfig-common/redmine/instances/default.conf new version creating config file /etc/redmine/default/database.yml.new new version granting access database redmine_default redmine_default@localhost: exists. creating database redmine_default: success. verifying database redmine_default exists: success. dbconfig-common: flushing administrative password creating config file /etc/redmine/default/database.yml new version creating config file /etc/redmine/default/session.yml new version new secret session key has been generated in /etc/redmine/default/session.yml populating database redmine instance "default".

c++ - Possible bug with GCC, foreach loops operate on shadows, rather than the actual objects -

i believe i've stumbled upon bug in gcc 4.82 consider following mcve: class foreachtestobject { std::string somevalue; public: foreachtestobject(int i) { somevalue = "default value "+to_string(i); } void resetsomevalue(string newvalue) { somevalue = newvalue; } string getvalue() { return somevalue; } }; int main() { vector<foreachtestobject> vec; vec.push_back(foreachtestobject(1)); vec.push_back(foreachtestobject(2)); //reading via foreach unproblematic for(auto obj : vec ) { cout<<"object is: "<<obj.getvalue()<<endl; } //changing values inside foreach (auto obj : vec) { obj.resetsomevalue("new name"); } //printing second time for(auto obj : vec ) { cout<<"object is: "<<obj.getvalue()<<endl; }//notice nothing has changed. //now changin

swift - Picking notable words from dictionary -

i see many ios apps on line of word of day. in process of making 1 such swift ios app picking random word dictionary picks lousy words. above said apps seem pick useful notable words have learning value. my question is, how can improve random function picked words notable? a simple approach assign each word in dictionary weight. weight (or probability of being selected) inverse of probability of appearing in corpus. in order that, need corpus (or large chunk of text) , compute frequency of each word in text (but can use available corpora (there's list here: http://corpus.byu.edu/ ). the words more "rare" might valuable , have highest learning value.

google api - Incompatibility windows form application -

i want make program search videos on youtube using youtube data api, v3, have key , access , im using vb.net in windows form in visual studio 2013 , dont found example in console doesn't help. example: http://pastebin.com/k5liynje , http://pastebin.com/getkfia6 help the youtube data api lets request set of videos match particular search term. api supports variety of standard google data query parameters , custom parameters related video search. to execute search request, create youtubequery object specifies search criteria , pass object youtuberequest.get() method. in client library code, query class , subclasses youtubequery responsible constructing feed urls. youtubequery object in example above constructs following feed url: here's sample code snippet uses .net platform: var searchlistrequest = youtubeservice.search.list("snippet"); searchlistrequest.q = "google"; // replace search term. searchlistrequest.maxresults =

Silent remote notification if app is terminated in iOS -

this question has answer here: will ios launch app background if force-quit user? 6 answers when remote notification need perform segue.this process happening in background. if app terminated/ killed sliding in app preview not getting notification. silent notification , user cannot see it. user has no way launch app in foreground on receiving notification. how handle situation? apns handled operating system not notify app if it's not foregrounded or running in background. apple has specific regulations on how applications can have extended background processes here https://developer.apple.com/library/ios/documentation/iphone/conceptual/iphoneosprogrammingguide/backgroundexecution/backgroundexecution.html regardless, once app terminated apns not start application. user must start application either tapping icon or interacting notification.

stackApply with multivariate function in R -

i looking use stackapply() in raster package , approx() linearly interpolate grid cell of 1 raster between stack of rasters. have written similar function calculation on dataframe, preform on stack of rasters rather rows in dataframe. have found previous examples of using stackapply() user defined function, none involve multiple variables. in other words, have stack of rasters , lone raster grid (they have matching extent , resolution). want "drill" through stack, cell cell, create vector of values , linearly interpolate value of matching grid cell in lone raster stack-created vector. my code along lines of... require(raster) set.seed(42) x1 <- runif(100) x2 <- x1 x3 <- x1 x1[sample(1:100, 30)] <- na x2[sample(1:100, 30)] <- na x3[sample(1:100, 30)] <- na r1 <- raster(matrix(x1, nrow=10, ncol=10)) r2 <- raster(matrix(x2, nrow=10, ncol=10)) r3 <- raster(matrix(x3, nrow=10, ncol=10)) s <- stack(r1, r2) myfunc <- function(x,

java - Automating run task in several Linux machines using script -

i have java program (/workspace/task) , want run in several linux machines ( m1 , m2 , m3 ... mn ). i need use linux script run program task on machines 1 one. in other words, want run task on m1 , when initials, run program on m2 ,... etc. meaning task must not start on new machine until initials on previous machine.

.htaccess - how to create redirects in apache2 htaccess basing on status code -

i know how create redirects in htaccess status codes except errors (404,503,etc.) , serve specific file test.txt this trying not work. @ moment trying 503 status code rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewritecond %{request_uri} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [nc] rewriterule (.+) index.php?p=$1 [qsa,l] redirect 503 /test.txt ??? errordocument 503 /test.txt ???

Azure Back end app services with no public ip -

i'm trying create environment in azure front end (publicly addressable) app service , several end app services containing war , web api apps. there should no way end can addressed publicly. note want app services, not cloud services. i know need vnet can't head around how remove default public endpoints end apps. how set such environment up? take @ app service environment , fine grained control on network on traffic level: https://azure.microsoft.com/en-us/documentation/articles/app-service-app-service-environment-control-inbound-traffic/

arrays - Fibonacci Sequence Error C -

i have assignment have write fibonacci's sequence , print first n numbers of it, n input user. wrote is: #include <stdio.h> int main(int argc, char*argv[]){ int n, i, seq[n]; scanf("%d", &n); seq[0]=0; seq[1]=1; for(i=2; i<n; i++) seq[i]=seq[i-1]+seq[i-2]; for(i=0; i<n; i++) printf("%d ", seq[i]); return(0); } which works until n equal or bigger nine. supposing input 8, sequence 0 1 1 2 3 5 8 13 should be. if input 9 or bigger sequence looks 0 1 1 2 3 5 8 13 21 -9 (bunch of random numbers). anyone can point out problem? thx in advance. you declare int n, i, seq[n]; before have value of n set array's length with. behavior uninitialized variable undefined. you don't need array assignment described. need remember last , current fibonacci values. sum them produce new one, migrate current -> last , new -> current. put logic in loop controlled n .

My While loop isn't working in python -

my while loop not repeating though sentry value has not been met break loop. please help.the while loop looks me should not break until varaiable computernumber equal number import random print("hello , welcome ai guessing game pick number 1 100 press h or l give clue") number=input("pick number 1 100") number=int(number) tries = 0 computernumber=1 while computernumber !=(number): computernumber=random.randint(1,100) print (computernumber) higherorlower=input("is number higher or lower use h or l please!") if higherorlower == "h": computernumber +=1 tries = int(tries) tries +=1 computernumber=random.randint (computernumber,number) else: computernumber -=1 computernumber=random.randint (1,computernumber) tries = 0 tries = int(tries) tries +=1 print (computernumber) break if computernumber == number: i

c++ - DrawText WinAPI Not Showing Result -

i tried use windows api drawtext() draw string on current program's console window, program suppose(i think) draw "hello world" in green color(0x33cc33), don't result showing up, don't know did wrong. here's piece of code: #include <stdio.h> #include <windows.h> int main(void) { rect rect; setconsoletitlea("win32cpptest"); hwnd winhandle = findwindowa("consolewindowclass", "win32cpptest"); if (winhandle == null) { printf("failed find target window hande.\n"); return getlasterror(); }; hdc windc = getwindowdc(winhandle); if (windc == null) { printf("failed target window dc.\n"); return getlasterror(); }; getclientrect(winhandle, &rect); //get rect structure target handle settextcolor(windc, 0x33cc33); //set text color green setbkmode(windc, transparent); //set background mix mode rect.left = 40;

c# - error in get data from access database to datagridview Vb.Net -

i have problem when click item in datagridview more information ! ok ? code : try if (datagridview1.rows.count = 0) return textbox1.text = string.empty textbox2.text = string.empty textbox3.text = string.empty textbox4.text = string.empty dim id string = datagridview1(2, datagridview1.selectedrows(0).index).value dim dt datatable = new dbconnect().selectdata(string.format("select items.clientname, items.clientaddress, items.clientphone, items.clientcredit, items.clientlastpay items items.clientid = {0}", id)) textbox1.text = dt.rows(0)(0).tostring textbox2.text = dt.rows(0)(1).tostring textbox3.text = dt.rows(0)(2).tostring textbox4.text = dt.rows(0)(3).tostring dt.dispose() dt = nothing catch ex exception messagebox.show(ex.message) end try by debugging error in line : dim id string = datagridview1(2, datagridview1.selectedrows(0).index).value.tos

CUDA - My GPU (Quadro M2000M) is listed as CUDA compatible, but CUDA installation fails? -

i'm running nvidia quadro m2000m on windows 8.1. gpu listed compatible (compute compatibility 5.0) on developer.nvidia.com/cuda-gpus , when try installing cuda 7.5 (latest version), error "graphics driver not find compatible graphics hardware". further, when check device list of 7.5, m2000m not listed. tried hack device in .inf file, got same error. tried installing , running cuda via theano on python, got error message "cuda unavailable". i tried rolling older versions (6.0, 5.5, 5.0), still recieved same error. has ideas? thanks in advance. i not have same gpu model, in order fix kind of problems when trying install cuda on windows proceed follows: download , install latest version of nvidia drivers offering support intended gpu. execute local installer cuda version need. in wizard deselect options install video driver. set environment variables, cudnn packages, etc. execute tests. according install guide can use -s flag perform sub

python - Gmail API reply to a thread with a new subject -

in gmail, when click "reply", have option "edit subject" if want reply , quote existing thread in new thread different subject. i have managed send email either in new thread, or reply existing thread, have not figured out how achieve behaviour explained above. i believe i'm looking "quote thread" functionality, not sure how achieve this. below small code snippet context: msg = mimemultipart() msg['to'] = "email.com" msg['from'] = "email.com msg['subject'] = "subject" msg.attach(mimetext(html, 'html')) body = {'raw': base64.urlsafe_b64encode(msg.as_string()), 'threadid': thread_id} service.users().messages().send(userid="me", body=body).execute() edit: i'm trying achieve: email 1; thread 1: subject: subject1 hey dude how's everything email 2; thread 1: subject: subject1 yo dude, y u no reply? on tue, nov 3, 2015 @ 10:41 am, dude | h

javascript - Importing Rx.Disposable in Typescript -

how correctly import disposable in ts file: import { disposable } 'rxjs' import { disposable } 'rxjs/rx' import * rx 'rxjs' then rx.disposable() or disposable.create() etc... none of these options works. end error such as: rx has no exported member 'disposable' i have used typings such: typings install dt~rx --global ah.. semi correct in syntax disposable has been renamed subscription in beta 5

javascript - getState in redux-saga? -

i have store list of items. when app first loads, need deserialize items, in create in-memory objects based on items. items stored in redux store , handled itemsreducer . i'm trying use redux-saga handle deserialization, side effect. on first page load, dispatch action: dispatch( deserializeitems() ); my saga set simply: function* deserialize( action ) { // how getstate here?? yield put({ type: 'deserislize_complete' }); } function* mysaga() { yield* takeevery( 'deserialize', deserialize ); } in deserialize saga, want handle side effect of creating in-memory versions of items, need read existing data store. i'm not sure how here, or if that's pattern should attempting redux-saga. you can use select effect import {select, ...} 'redux-saga/effects' function* deserialize( action ) { const state = yield select(); .... yield put({ type: 'deserislize_complete' }); } also can use selectors cons

Jquery 'Justified Gallery' reload/reinitilse -

im using jquery 'justified gallery' plugin display pictures. im uploading pictures picture folder. im trying reinitilise or reload gallery when image uploaded (this example use refresh button). the documentation states:"can called again update layout (after add or remove of images)". when attempt ignored , requires page reloaded make change. this should simple...what doing wrong? //initilise gallery $(window).load(function() { $('#layout-gallery').justifiedgallery({ rowheight : 300, margins : 15, captions : true, imagesanimationduration : 1000 }); //refresh gallery $('#refresh').on('mousedown', function(e) { $('#layout-gallery').justifiedgallery({ rowheight : 300, margins : 15, captions : true, imagesanimationduration : 1000 }); }); } me being stupid...it reloading gallery! needed re

word wrap - How to display "..." (3 dots) if a sentence takes more than 2 lines in php? -

i looked on online not find. found use string longer specific number defined need display dots if sentence takes more 2 lines. for example, sentence below long : the eiffel tower wrought iron lattice tower on champ de mars in paris, france. named after engineer gustave eiffel, company designed , built tower. tower 324 metres (1,063 ft) tall, same height 81-storey building, , tallest structure in paris. base square, measuring 125 metres (410 ft) on each side. i display above sentence as: the eiffel tower wrought iron lattice tower on champ de mars in paris, france. named after engineer gustave eiffel, company designed , built tower. tower is... try below function <?php function trim_text($text, $count){ $text = str_replace(" ", " ", $text); $string = explode(" ", $text); ( $wordcounter = 0; $wordcounter <= $count;wordcounter++ ){ $trimed .= $string[$wordcounter]; if ( $w

Python 2.7 IndentationError -

i getting indentationerror when trying run program in python interpreter: line 127 global map ^ indentationerror: expected indented block i using python version 2.7 what's wrong following code?: def make_map(): global map python expects 4 spaces or tab indent , align code - similar java expecting curly {} brackets start of loop, method or class etc. def some_function(): somecode morecode ... should formatted as def some_function(): somecode morecode ... it appears code throws exception on line 127, check , indent code required. def some_code(): in range(1, some_value): some_method() if need_more_indent: indent_code() do_this_after_indent_code() this_runs_after_for_loop() return 'lol'

PHP/MySQL - inserting JSON data into DB on Bluehost server, empty DB entry -

this one-use script insert json data mysql database on bluehost. i've used various echo statements inside , outside loop make sure json info parsed correctly , loop works expected. bluehost files tell me use sql statements instead of sqli or dbo. <?php $con = mysql_connect ("localhost:port", "username", "password"); if (!$con) { die('could not reach database: error code ' . mysql_error() . "<br>"); } else { echo 'connected database. ' . "<br>"; } mysql_select_db ("db_name", $con); $jsondata = file_get_contents('bfz.json'); $data = json_decode($jsondata, true); $cards = $data['cards']; // loop through cards array , load each set of variables db for($i = 0; $i <= count($cards); $i++) { $card_name = $cards[$i]['name']; $card_manacost = $cards[$i]['manacost']; $card_cmc = $c

android fragments - ViewPager inside RecyclerView -

i have recyclerview 20 viewpagers ( viewpager fragment) want display different pictures inside viewpagers hel of fragments. have problems viewpagers. first viewpager ok!, next 19 clear, without pics. after scroll down , up, pictures appears in viewpager , after swipe on viewpager disappear. here viewpager adapter: public class viewpageradapter extends fragmentpageradapter { arraylist<string> mpics; public viewpageradapter(fragmentmanager fm, arraylist<string> pics) { super(fm); mpics = pics; (string pic: mpics) { log.d("!!!!!!!->",pic); } } @override public fragment getitem(int position) { return viewpagerfragment.newinstance(mpics,position); } @override public int getcount() { return mpics.size(); }} and recyclerview onbindviewholder @override public void onbindviewholder(final flatviewholder flatviewholder, int position) { flat flat = mflat.get(position); if (flat.getadv_pics().size()>0){