w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to execute code when a Python script is closed out?
import MySQLdb con = MySQLdb.connect(...) cursor = con.cursor() try: # do stuff with your DB finally: con.close() The finally clause is executed on success as well as on error (exception). If you hit Ctrl-C, you get a KeyboardInterrupt exception.

Categories : Python

Code after showDialog is not execute when the modal window is closed by the other thread -- C#
Unless you have a long running or slow operation, there is no reason why you should complicate your life with a separate thread. Just show your dialog form in modal mode and proceed when the user has input the required data.

Categories : C#

what's the difference between pycurl.WRITEFUNCTION and pycurl.WRITEDATA?
With the WRITEDATA callback option, you can control which file the default WRITEFUNCTION callback writes to. The function set with the WRITEFUNCTION option is the one which is actually called as soon as there is data received that needs to be saved. Normally, the value you specify to WRITEDATA will be passed to the WRITEFUNCTION callback, but in PyCurl, the WRITEFUNCTION callback just takes a single string as argument, so there's not much use in using WRITEDATA with WRITEFUNCTION together in PyCurl.

Categories : Python

Node.js console gets closed immediately after i execute the program from Visual Studio 2012 in Windows 8
Instead of directly executing node app.js from Visual Studio, you could instead call a batch file: wait.bat app.js Which inside of wait.bat it simply: node %1 pause press [enter] or, you could do this on one line, or wrap it in a module or a function: require('readline') .createInterface(process.stdin, process.stdout) .question("Press [Enter] to exit...", function(){ process.exit(); }); It's using an currently marked as "unstable" module of Node to read line input from stdin. It ignores the input though and then closes the process using the exit function.

Categories : Javascript

ActiveRecord execute SQL need to close connection? DEPRECATION WARNING: Database connections will not be closed automatically
In This case You need to close your connection manually. After running your script, you can close it Manually like this. after do ActiveRecord::Base.connection.close end

Categories : Ruby On Rails

Running some code when browser is closed
In my knowledge it is impossible to detect a browser close separately from a browser navigation. the browser does not provide the window with that information. SEE HERE ALSO

Categories : Javascript

Executing code when my form is closed
I think that what you need is not access to the close button, but rather access to the event which is fired when the form is closed. Taken from this previous SO post, what you might need is something like so: void FormClosed(object sender, FormClosedEventArgs e) { // do something useful }

Categories : C#

VBA code crashing Excel if closed early
For non english languages, you could use .FormulaLocal or .FormulaR1C1Local. Developer reference says "Returns or sets the formula for the object, using R1C1-style notation in the language of the user. Read/write Variant". However, I strongly recommend not using the above, as it will mean it won't work if the macro is run on a different language version. Instead, better practice is to use English in conjunction with .Formula and .FormulaR1C1. This will still open as French in a French version, as Excel automatically displays formulae text in the relevant language. For example: (I use "FALSE" only as an example - the below is true for formulae too like "=SUM(A1)", and of course, if you really want to set a boolean value then please don't use string "TRUE"!) ActiveCell.Formula = "FALSE"

Categories : Excel

Pycurl list set options
I don't think there's such an option. But it would be easy to encapsulate the curl object into another one that would be like: class ExtendedCurl: invpycurl = {v:k for k, v in pycurl.__dict__.items()} def __init__(self): self._pycurl = pycurl.Curl() self._options = {} def setopt(self, opt, val): self._pycurl.setopt(self, opt, val) self._options[opt] = val def unsetopt(self, opt): self._pycurl.setopt(self, opt, val) del self._options[opt] def reset(self): self._pycurl.setopt(self, opt, val) self._options = dict() def getopts(self): for opt, val in self._options.iteritems(): if opt in self.invpycurl.keys(): print "{}: {}".formart(opt, val) def errstr(self):

Categories : Python

Pycurl won't import on Raspberry Pi
The first line is misleading. ./pycurltest.py: 1: ./pycurltest.py: import: not found It looks like the interpreter is suggesting that a blank import cannot be found, or it's finding: import Pycurses#<---something else is here Check that your .py script does not have any weird characters at the end of the line and that it has a proper newline character: import pycurl From the python docs: A physical line is a sequence of characters terminated by an end-of-line sequence. In source files, any of the standard platform line termination sequences can be used - the Unix form using ASCII LF (linefeed), the Windows form using the ASCII sequence CR LF (return followed by linefeed), or the old Macintosh form using the ASCII CR (return) character. All of these forms can be used equal

Categories : Python

How to execute code on TFS server after a user checks in code
There are different ways you can approach this: Team Build. By using a TFS Build Server you can create a Continuous Integration build or a Gated Checkin build. In the build workflow you can then respond to whatever changes you've detected. You can use the TFS Client Object Model to grab the Changeset object. That contains all the data you'll need. The ALM Rangers have written an extensive guide explaining how to extend and customize the build process to suit your needs. Checkin Policy. By creating a custom checkin policy you can run code pre-checkin on the client (inside Visual Studio). This policy could serve as a sample on how to interact with the pending changes. ISubscriber TFS Application Tier plugin. Already mentioned by @ppejovic. The Application Tier plugin is installed on the TF

Categories : C#

Getting ResultSet is closed exception but i didn't close it in the code
You're closing the statement - that will close your result set too. From the docs for ResultSet: A ResultSet object is automatically closed when the Statement object that generated it is closed, re-executed, or used to retrieve the next result from a sequence of multiple results. You should extract all the relevant data from the result set immediately, then close it (and the statement and the connection) in finally blocks - or using the try-with-resources statement in Java 7. I'd also strongly suggest that you separate your UI code from your data access code. (Your current "UI" also appears to be a mixture of a console app (System.out.println) and Swing, which is odd...)

Categories : Java

How to send DELETE request in Pycurl ?
Based on the example from requests quickstart: import json url = 'http://url/json' payload = {'key': 'value'} headers = {'Accept': 'application/json', 'Content-Type': 'application/json'} r = requests.delete(url, data=json.dumps(payload), headers=headers) print(r.json()) A more literal translation of the curl command could be: import os import sys import requests headers={"Content-Type": "application/x-www-form-urlencoded"} r = requests.delete("http://url/json", data=b'{"key": "value"}', headers=headers) n = os.write(sys.stdout.fileno(), r.content) # support bytes in Python 2 & 3

Categories : Python

How can I use the CURLOPT_MAX_RECV_SPEED_LARGE option with pycurl and Python?
I'm not sure this will work, but you can try to change this line c.setopt(c.CURLOPT_MAX_RECV_SPEED_LARGE, 1024) with this line c.setopt(CURLOPT_MAX_RECV_SPEED_LARGE, 1024)

Categories : Python

Pycurl: uploading files with filenames in UTF-8
This is easy to answer, harder to fix: pycurl uses libcurl for formposting. libcurl uses plain fopen() to open files for posting. Therefore you need to tell libcurl the exact file name that it should open and read from your local file system.

Categories : Python

No module named pycurl on mac terminal
You are using a module called pycurl that may not be installed in your machine. To test if it is installed in your machine, do the following: $ python >>> import pycurl and see if you are getting an error message. If so, download it: pip -v install pycurl

Categories : Python

My code gives me and error called "There is already an open DataReader associated with this Command which must be closed first"
Try to use a new connection instead in the sqldread.Read() SqlConnection conn2 = new SqlConnection(); conn2.ConnectionString = ""; //your connection string SqlCommand scmd1 = new SqlCommand(QueryStr, conn2); scmd1.Parameters.Add("@Image", SqlDbType.VarBinary).Value = imgbytes; conn2.Open(); scmd1.ExecuteNonQuery(); conn2.Close();

Categories : C#

Code to search in SQL for a value and if present execute a code
public List<UserData> GetData(int clientNo) { var theResults = new List<UserData>(); var connStr = "serverstring"; using (var cnn = new SqlConnection(connStr)) { cnn.Open(); using (var cmd = new SqlCommand("SELECT [Name], [PaternalLastName], [MaternalLastName] FROM [SocioInfo] Where ([SocioNum] = @SocioNum)",cnn)) { cmd.Parameters.AddWithValue("@SocioNum", txtInput.Text); using (var rdr = cmd.ExecuteReader()) { if (rdr.HasRows) { while (rdr.Read()) { theResults.Add(new UserData {

Categories : C#

Code first: Database only created after execute certain code?
Database initialization is triggered lazily by Entity Framework. It will only occur when EF tries to connect to the database. You can manually trigger database initialization using the following. using (var db = new Models.TnHContext()) { db.Database.Initialize(force: false); } Setting the force parameter to false tells EF not to run initialization if it has already been triggered.

Categories : Dotnet

make pycurl use different curl/libcurl installation
If you install pycurl by hand (setup.py, not pip), you can run: python setup.py --curl-config=/usr/local/bin/curl-config install (To install with pip, I would try moving /usr/local/bin first in your path so it will find the right curl-config, but I haven't tried this myself) If your installation of curl is not in /usr/local, you might also need to add the appropriate lib directory to DYLD_LIBRARY_PATH.

Categories : Misc

Finalizing a Cursor that has not been deactivated or closed or database not closed error
When you are done with the cursor, you need to call Cursor.close(). Leaving it not closed leads to memory leaks. E.g.: Cursor cursor = null; try { cursor = getContentResolver().query(myUri, MY_PROJECTION, null, null, null); if (cursor != null && cursor.moveToFirst()) { // moar code } } finally { if (cursor != null) { cursor.close(); } }

Categories : Android

Can I set low priority upload request using pycurl/curl to avoid using all upstream
Check these libcurl examples, their usage and options names are almost the same like in pycurl. (see examples from right column).

Categories : Python

pycurl, how to send POST data for Multiple Select Form?
From that it looks like the data you're sending is going to just be { 'multipleSelectForm':'value2' } Because it's a dictionary. If you set it up as tuple pairs it will do what you want. data = (('multipleSelectForm', 'value1'), ('multipleSelectForm', 'value2')) You can test this your self by setting up a tiny debug http server: from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer class hand(BaseHTTPRequestHandler): def __init__(self, socket, *args): print socket.recv(1000

Categories : Python

install a python library, specifically pycurl, on my heroku box (Rails application)
add a requirements.txt file to your python deployment. Write your python dependencies in it (add any other dependencies you have not only pycurl). check this doc from heroku guys I use pycurl on my heroku app and have found no problem uploading to heroku.. Installing dependencies using Pip (1.3.1) Downloading/unpacking pycurl==7.19.0 (from -r requirements.txt (line 11)) Running setup.py egg_info for package pycurl Using curl-config (libcurl 7.19.7) Installing collected packages: pycurl Running setup.py install for pycurl Using curl-config (libcurl 7.19.7) building 'pycurl' extension gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DHAVE_CURL_OPENSSL=1 -DHAVE_CURL_OPENSSL=1 -DHAVE_CURL_SSL=1

Categories : Python

Execute a part of JS code after code above it
One Solution that just struck my mind is to use Callback functions. Wrap game code in a function like this: function callMeLater() { var activeFrame = 4, gameArray = []; for (var i = 0; i < 9; i++) { gameArray.push(['-','-','-','-','-','-','-','-','-']); } console.log(mode); // <<----- THIS HERE <<--------- if ( mode === 1 ) { $('body').on('click', 'div.frame', function() { var index = $frame.index(this); if ( index === activeFrame ) console.log('click on active Frame'); }); } else if ( mode === 2 ) { } } and call it from .animate() $notifier.css('display', 'table').animate({'opacity': 1}, 500, callMeLater); But this seems a bit weird to me. Any other choice that I have?

Categories : Javascript

Application gets closed when terminal is closed, how to stop this?
Use nohup to prevent child processes from being killed when the terminal closes. spawn nohup /usr/bin/firefox https://www.google.com/ I assume there's more to the script, since there's no need to use Expect just to start firefox.

Categories : Python

Why won't this tic-tac-toe code execute?
Well there're many things which need improvement in your code (you have to rewrite your CheckAll function at least so it could check board of any size), but two things will help you to debug - first, you have to actually return something from your CheckAll function: ... if board[0] == board[1] == board[2]: return True if board[3] == board[4] == board[5]: return True ... second, you may actually want to print output: if checkAll() == True: print "The game is over!" break;

Categories : Python

Is it possible to execute code using a URL?
It's possible if something on the server takes the data in the URL and puts it somewhere where it might be treated as code (e.g. in an eval statement, in an SQL query or in an HTML document). The defences are all specific to the place where you put the data, but usually involve escaping it. See also SQL Injection, XSS, and the open web application security project.

Categories : PHP

Make PHP code execute only once
The usual approach: URL to create a new entry would be http://your.site/requests/new or http://your.site/requests/create or just http://your.site/request. URL to update an existing entry would be http://your.site/requests/123. After a new entry is created, the user is redirected to the /123 page where they can update their entry. The php is the same for both URLs. Check that isset($_GET['ID']) in which case, you are editing an existing record. If $_GET['ID'] is not set, then you are creating a new record. Wrap the INSERT statement in an if (isset($_GET['ID'])) block.

Categories : PHP

How do I execute a module's code from another?
Move the if __name__ == '__main__': in module a to the end of the file and add pass or some test code. Your problems are that: Any thing in the scope of if __name__ == '__main__': is only considered in the top level file. You are defining a class but not creating a class instance. module a, to be imported import statements class a1: def __init__(self, stuff): do stuff def run_proc(): #do stuff involving 'a1' when called from another module if __name__ == '__main__': pass # Replace with test code! Module that I'll run, that imports and uses 'a': import a def do_a(): A = a.a1() # Create an instance A.run_proc() # Use it if __name__ == '__main__': do_a()

Categories : Python

Execute code before and after specification
Okay, as mentioned in my comment, I actually had this same issue. I needed to test Unfiltered endpoints, and the best way for each spec was to startup an Unfiltered server with a single endpoint, run the spec and then shutdown the server. To accomplish that, I first defined a base specification similar to this: import org.specs2.mutable.Specification abstract class SpecificationBase extends Specification{ //Do setup work here step{ println("Doing setup work...") success } //Include the real spec from the derived class include(spec) //Do shutdown work here step{ println("Doing shutdown work...") success } /** * To be implemented in the derived class. Returns the real specification * @return Specification */ def spec:Specification } Ba

Categories : Scala

Why does it matter how I execute this code?
I'm sure you're right that it's to do with the delay between declaring the synthdef and it being ready. I'm not really experienced enough with sclang to immediately tell you exactly how you should change your code (I generally use scsynth via OSC, only using sclang to write SynthDefs), but you should be able to do something with the optional completionMsg argument to SynthDef.add.

Categories : Misc

Using AJAX to execute PHP code
take a look to: http://api.jquery.com/load/ you can load only on part of a page in a html element $('#result').load('ajax/test.html #container');

Categories : PHP

Execute PHP code in DOMDocument
You ca use php eval() function to execute php inside the text. But i am not sure this is a safe way of doing it. You can see the PHP manual here: http://php.net/manual/en/function.eval.php

Categories : PHP

java set of code does not execute
The following condition is invalid: if(myArray[i].contains("(") && myArray[i].contains(")") ) The same place in the array cannot hold both "(" and ")" - this condition will always return false! the array SUB is never initialized. Remark: for(i=0;!(line=reader.readLine()).isEmpty() && i<20;i++) will stop on the first empty line in the file, but sometimes there are empty lines and you still want to keep reading, if that is the case you should use != null instead if ! isEmpty()

Categories : Java

Python: Why does this code execute?
This is the output I get: 1 2 2 1 3 0 4 -1 5 -2 6 -3 7 -4 8 -5 9 -6 10 -7 Your question as to why it runs. Your outer most conditional is a while loop, which is true upon the first execution, however it runs right into a nested for loop. When this happens the while, will not be checked until the for loop finishes its first execution (which is why p = -7). What you want is this: p = 2 for i in range(10): if p <= 0: break print i+1 , p p-=1 which gives output: 1 2 2 1

Categories : Python

How does the PHP code execute even without closing the ?> PHP tag?
The closing tag exists to tell the interpretter that it should stop executing the text and just output it verbatim. Unlike XML, which requires openning and closing tags to match to be valid, the PHP interpretter simply uses the tags to delimit where execution should start and stop. Just like a PHP file could have no opening tag - meaining that the entire contents would be output, no closing tag is necessary as once the end-of-file is reached execution ends.

Categories : PHP

Execute a program in my C code
To achieve what you want to do, you need to use popen(), not system(). Popen starts a new process that executes the program you specify in the command, and then maps the input or output stream of that program to a file descriptor available in your own program. Then, you can communicate with this program through this file descriptor. You code should look like (not actually compiled): FILE* file = popen("/path/to/your/program", "w") if (!file) { // Something not nice happened } fprintf(file, "command1 "); //... pclose(file);

Categories : C

How to execute some code after a segue is done?
In case you don't want to use the viewDidAppear: method, you could create a custom segue. In the perform method you would use an animation for the transition, and that can have a completion block. You can add the code there after the animation is complete.

Categories : IOS

How to draw closed spline 3D (closed curve 3d) through unordered list of points3D. How to arrange points3D?
It sounds like you're looking for the Concave Hull of the data set. Unfortunately, I don't know of any pre-canned algorithms, but the link references a paper that another developer was starting from, as well as some sample code, so maybe that'll help you in the right direction.

Categories : C#



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.