text stringlengths 256 65.5k |
|---|
I'm working on a Python script and I was searching for a method to redirect stdout and stderr of a subprocess to the logging module, the subprocess is createdusing the subprocess.call() method.
The difficulty I faced is that with subprocess I can redirect stdout and stderr only using a file descriptor. I did not find a... |
Babdu89
Re : HY-D-V1 un nouveau Desktop
Bonjour...
Alors, comme j'ai toujours du temps, de la place sur mes hdd, et de la suite dans les idées ...
Toujours au sujet de la tentative d'Hybrydiser la Cubuntu 13.04 32 bits ... Voir post ci-dessus .
J'ai réinstallé, j'ai fais les maj système en commande, j'ai été obligé d'i... |
obare
Serveur firewall entreprise
Bonjour,
J'ai un soucis avec la mise en place de mon serveur. Beaucoup de messages sur google discute de ce genre de situation mais je ne trouve pas d'où vient mon problème (je suis loin d'être expérimenté mais je dois mettre en place ce qui m'est demandé).
Voici la demande:
Avoir un s... |
What's the easiest way to truncate a c++ float variable that has a value of 0.6000002 to a value of 0.6000 and store it back in the variable?
Thanks in advance!
What's the easiest way to truncate a c++ float variable that has a value of 0.6000002 to a value of 0.6000 and store it back in the variable?
Thanks in advance... |
tiramiseb
Re : configuration des DNS
S'il-te-plait, pour des citations utilise la balise "[ quote ]" et non la balise "[ code ]", c'est pénible de devoir défiler horizontalement pour lire les phrases que tu cites...
Hors ligne
kr2sis
Re : configuration des DNS
ça y est je sui perdu...:o
est ce qu'on peut faire doucemen... |
I have something that should be really simple, but it's killing me.
l = LineItem.first
#<LineItem id: 5, product_id: 1, quantity: 1, price: #<BigDecimal:7f7fdb51a3f8,'0.999E3',9(18)>, cart_id: 5, discount_percentage: 10, discount_amount: nil, discount_active: true, created_at: "2012-01-12 16:17:41", updated_at: "2012-0... |
I have a Django model with a decimal field:
class User(models.Model):
...
balance = models.DecimalField(max_digits=10, decimal_places=2, blank=True, null=True)
...
I have my app running on my development machine (Python 2.7.1, Mac OSX, Django 1.4, MySQL InnoDB), and on a production server (Python 2.6.5, Ub... |
Pleased to annouce small, yet powerful administrative interface building framework for Flask.
Flask-AdminEx is not limited to model scaffolding - you can implement interface of any complexity. And it comes with few batteries built in: SQLAlchemy model scaffolding and simple file management interface.
Here's simple mode... |
Request-Response-Cycle
Contents
Web application frameworks usually fall into one of two groups: those that hide the transient nature of the HTTP protocol and those that don't. Helma tries to take a sane middle course. It provides access to HTTP headers and values through request and response objects while judiciously a... |
Python Standard Logging
by Jeremy Jones
06/02/2005
Python 2.3 introduced the logging module to the Python standard library. logging provides a standard interface for outputting information from a running application. The classic example of a logging mechanism is writing data to a text file, which is a plain old log fil... |
Gaara
barre de progression sur notification en root [finalisé]
Bonjour,
J'essaie de me faire un petit script qui me prévient avec une notification quand mes mises à jours sont effectuées, en utilisant unattended-upgrades.
J'ai réussi à le faire fonctionner avec yad, mais c'est pas très joli. Je voudrais donc utiliser n... |
Is it possible to use the LINQ types and extension methods in IronPython?
If so how? And also is there often more pythonic to do the same thing?
IronPython 2.7 finally bridges this gap with the
>& 'C:\Program Files\IronPython 2.7\ipy.exe'
IronPython 2.7 (2.7.0.40) on .NET 4.0.30319.225
Type "help", "copyright", "credit... |
If you search Google for "how to install Django on JustHost" you may be surprised to find tens of thousands of articles claiming that it can't be done and none claiming that it can.
Well, it can and here's how:
Log in using SSH access
In the Security section of your control panel click "SSH/Shell Access" -> "Manage SSH... |
I'm trying to compose seq-m and error-m to do list comprehensions on things that can return errors. My output has unexpected types, though other than that it does actually seem to be sensible. i've exploded my code below, but here is a working gist as well.
here is my monadic business logic
def get_loan(name):
m_qu... |
I'm following a web.py tutorial that is using the web.py form module. Basically, this little app creates a form consisting of a text box, does some validation to make sure it's a number and that it's greater than 10, and decides if that number was odd or even. I'll post the code before the question as it'll be easier t... |
A simple test in the console shows you cannot modify a dictionary while iterating over it:
>>> mydict = {'one': 1, 'two': 2, 'three': 3, 'four': 4}
>>> for k, v in mydict.iteritems():
... if k == 'two':
... del mydict[k]
...
------------------------------------------------------------
Traceback (most recent c... |
The itertools module has a useful method called permutations(). The documentation says:
itertools.permutations(iterable[, r])
Return successive r length permutations of elements in the iterable.
If r is not specified or is None, then r defaults to the length of the
iterable and all possible full-length permutations a... |
A web server in twisted - Part 2
Yesterday I wrote this post about how to write a very simple web server for a predefined content. Now I want to change it and discuss the solution a bit more in detail. First of all let's make it a real webserver, serving files from a known directory instead of serving some dummy conten... |
Enhancing the DocumentTemplate
Although MFC and PythonWin support multiple document templates, there's a slight complication that isn't immediately obvious. When MFC is asked to open a document file, it asks each registered DocumentTemplate in turn if it can handle this document type. The default implementation for Doc... |
The Landscape: HTML5
HTML5 is an emerging and in-flux client-side standard for developing web applications. It’s really more of a rich client platform specification than just a markup language, including the following slew of new features:
canvas for vector graphics
video and audio for multimedia
local offline storage
... |
krystoo
Comment installer des mises à jour téléchargées ?
Bonsoir, alors je vais faire le tour je crois ^^
après troisième installe sur le pc portable, se coup ci j'avais 197 mises à jour. J'ai fait en plusieurs fois car sinon interminable.
Quand aux 6 dernières màj que j'ai téléchargé, visiblement elles ne se sont pas... |
From what I have known it would evaluate and return the second expression
That's not a completely correct statement. Yes, the second is evaluated and returned, but you're implying the first is ignored.
The way the comma operator works is all expressions are evaluated and the last is returned. For example:
int a, b, c, ... |
Django generic views are just view functions (regular old python functions) that do things that are very common in web applications.
Depending on the type of app you are building, they can save you from writing a lot of very simple views.
For example, the direct_to_template generic view simply renders a template with t... |
I am writing 2 small programs (a server and a client) and whenever I run both, and have the client connect to the server, the server output says that I am connected on a port of which I didn't bind in the code. I binded both the server and the client socket to the localhost and port 8000, but every time the server is c... |
This post is mainly going to be an update on what I am thinking and what I’ve been working on the past few weeks.
Work
At the beginning of this year, I took a new position (same company) in a security group. Our primary focus is to ensure that the company is shipping secure, OSS compliant, legally compliant code. Howev... |
A list of 1000 zeroes is created called M. A random number is picked from 1 to 1000. Each time one of these is picked, the zero in the list ( at that index ) is changed to a 1. For instance if the random number is 276 then M[276]=1. What is the average number of random numbers that must be picked to have 200 ones in th... |
GAHH, code not working is bad code indeed!
in RemoveRETNs toOutput[currentLoc - 0x00400000] = b'\xCC' TypeError: 'bytes' object does not support item assignment
How can I fix this:
inputFile = 'original.exe'
outputFile = 'output.txt'
patchedFile = 'original_patched.exe'
def GetFileContents(filename):
f = open(filen... |
Fun With The Arduino Esplora: A Digital Picture Frame
Materials Needed
In this section you will find the materials that you need to obtain to build this project.
Arduino Esplora Board
The Arduino Esplora is the most feature rich of all the Arduino boards. It has the shape of a game controller, which makes it the cooles... |
I would like to update the data source of a specific layer in multiple map documents using ArcPy, however I'm getting a <type 'exceptions.SyntaxError'>: invalid syntax error on this line:
if lyr.datasetName == inputlayer
import arcpy, string, os
import arcpy.mapping as MAP
try:
MXDList = string.split(arcpy.GetParam... |
I need to get the first N sentences from a text where the last char of the sentence can be a period, a colon, or a semicolon. For example, given this text:
Lorem ipsum, dolor sit amet. consectetur adipisicing elit; sed do eiusmod tempor.
incididunt ut labore: et dolore magna aliqua. Ut enim ad. minim veniam.
The first... |
Test - provides a simple framework for writing test scripts
use strict;
use Test;
# use a BEGIN block so we print our plan before MyModule is loaded
BEGIN { plan tests => 14, todo => [3,4] }
# load your module...
use MyModule;
# Helpful notes. All note-lines must start with a "#".
print "# I'm testing MyModule version... |
Author momo
Submission date 2011-08-31 09:26:29.833692
Rating 6775
Matches played 2521
Win rate 68.58
Use rpsrunner.py to play unranked matches on your computer.
import random
def highest(v):
return random.choice([i for i in range(len(v)) if max(v) == v[i]])
def lowest(v):
return random.choice([i for i in range... |
I am trying to find k random numbers in the range 1..n such that none of the k numbers are contiguous. The code I came up with is
def noncontiguoussample(n,k):
import random
numbers = range(n)
samples = []
for _ in range(k):
v = random.choice(numbers)
samples.append(v)
for v in r... |
Assuming I have a numpy array like: [1,2,3,4,5,6] and another array: [0,0,1,2,2,1] I want to sum the items in the first array by group (the second array) and obtain n-groups results in group number order (in this case the result would be [3, 9, 9]). How do I do this in numpy?
There's more than one way to do this, but h... |
So, I won't be posting here again, but that's OK because I stopped posting anyway. I have a new blog at jouire.com these days, so update your feed readers and bookmarks accordingly.
Tuesday, February 2
OK so Blogger are now officially shutting down FTP support. That's how I publish this blog. I understand why they're d... |
When I visit /admin/newpost I expect my edit.html template to render and diplay my form fields. Instead, I get a blank page with no error. However, when I view source I see the following.
<Template '/edit.html'>
I don't get any errors so there is not stack track.
GAE Version: 1.7
Windows 7 64 bit
jinja2 version latest
... |
A useful alternative answer to the first question, using the examples from tomeedeeâs answer, would be to use numpyâs vstack and column_stack methods:
Given a matrix p,
>>> import numpy as np
>>> p = np.array([ [1,2] , [3,4] ])
an augmented matrix can be generated by:
>>> p = np.vstack( [ p , [5 , 6] ] )
>>> p = n... |
The algorithm sorts all the numbers except the first one, and sets it as last. Please help!
def bubbleSort(numbers): # Bubble Sort Algorithm
numbers = list(numbers)
i = 0
j = 0
for i in range(len(numbers)):
for j in range(len(numbers) - i):
if numbers[j] < numbers[j-1]:
... |
MySQL Conference and Expo April 14-17, 2008, Santa Clara, CA
Cross-Browser Animation
by Dave Thau and Apple Developer Connection
05/24/2002
The fundamental idea behind animation has been around for a long time: when a group of images are presented quickly, the series of images seems to form a single moving picture. One... |
music notation and note generators
So, I’ve been flipping through a book on ‘contemporary music theory’. In the first few pages I learned what a tetrachord is and how two of them can be combined to build a major scale. Given the rules, I built a patch (rather than working through the books pencil and paper exercise).
t... |
joko
Re : Qarte arte.tv browser (ex Qarte+7)
bonjour, grands compliments à VinsS et consors, vraiment épaté. bravo à tous les p'tits fouineurs !
qualité vidéo géniale, rien à voir avec celle du site d'arte +7 !!!
Dernière modification par joko (Le 06/11/2012, à 12:35)
Je suis un homme, quoi de plus naturel en somme ?
l... |
galinux
Re : Mypaint : vos dessins & brosses
pas mal tenez regardé ça ! ça prête a sourire, il m'avait interdit plusieurs post qu'il sont rétabli en parti sauf celui là
vieux packard bell imedia, intel core2 duo 1.86 ghz, 2.5 Go ram, nvidia gt 220 LMDE (xfce) 64 b + voyager 12.10 32 b sur clef pour l emmené partout
un ... |
Phoen1x
Re : [HOW TO] adesklets : configuration des desklets
J'ai besoin d'un coup de main, donc j'ai voulu installer les adesklets
Weather forecast et system moniteur
Le problème c'est que j'avais pas vu le tuto pour l'installation de adesklest .
J'ai bigouilller un long moment sur weather car il ne me le lancait pas ... |
I decided to use str for printing the contents of a tree in tree-like structure,using something like
print tree
The nodes of the tree are all objects of user-created classes and I overload their __str__ magic method in order to use the child nodes' str after indent t tabs like that
def __str__ (self,t=0) :`
return... |
I am trying to run a program with two files. file1 contains two classes and one line of code. When I run file1.pyfrom the command line the single line of code runs and calls one of the classes from this file. For file2.py to work it needs to use just one of the classes from file1.py. However no matter what method I use... |
Kubke Lab:Research/ABR/Notebook/2013/10/29
From OpenWetWare
(→Feedback from Andy: more feedback)
(→Feedback from Andy)
Line 18: Line 18:
* Try an fft to see where the low pass cutoff should be. If the filter order is too high you get ringing. [ see http://t.co/QfrGaDjvj2 ]
* Try an fft to see where the low pass cutoff ... |
Overview Info
Domain Nameegyhq.com
Favicon
Alexa Rank#21903
Google Page Rank
Ip Address198.143.147.140
Page Size79.8 KB
Images1 GIF, 72 JPG, 1 PNG
Heading
H1
H2
H3
H4
H5
H6
0 0 0 0 0 0
DNS Analysis
DNS servers
ns2.softlayer.com [67.228.255.5]
ns1.softlayer.com [67.228.254.4]
DNS Records
Answer records
egyhq.com SOA
864... |
I found an old version of adeskmenu on launchpad and figured it would be nice to take advantage of tint2's new launcher feature. So with a help from MoD from silver.irc we re-worked the script to just open the menu when clicked. Here is a screenshot.
All you need is the single page menu script and a .desktop pointing t... |
As Wedge said, you want to multiply to make things brighter, but that only works until one of the colors becomes saturated (i.e. hits 255 or greater). At that point, you can just clamp the values to 255, but you'll be subtly changing the hue as you get lighter. To keep the hue, you want to maintain the ratio of (middle... |
Can someone explain how to do nested dict comprehensions?
>> l = [set([1, 2, 3]), set([4, 5, 6])]
>> j = dict((a, i) for a in s for i, s in enumerate(l))
>> NameError: name 's' is not defined
I would have liked:
>> j
>> {1:0, 2:0, 3:0, 4: 1, 5: 1, 6: 1}
I just asked a previous question about a simpler dict comprehens... |
I have a tuple of tuples and I want to put the first value in each of the tuples into a set. I thought using map() would be a good way of doing this the only thing is I can't find an easy way to access the first element in the tuple. So for example I have the tuple ((1,), (3,)). I'd like to do something like set(map([0... |
Scripting
Intermediate
Interfaces
Checked with version: 4.1
-
Difficulty: Intermediate
-
Date: 13 Mar 2014
How to create interfaces and implement them in classes.
Interfaces
Intermediate Scripting
Interfaces
Code snippet
using UnityEngine;
using System.Collections;
//This is a basic interface with a single required
//m... |
I use Watir in RadRails IDE. I create a class which checks if some text is present on my web page:
class Text
def initialize(text, object)
@text = text
@object = object
if $ie.contains_text(@text)
puts "Test for" + @object + "failed"
puts $ie.link(:text => /Exception:/)
h = $ie.link(:t... |
I've just learned the basics of Ruby after being very happy with Python for several years (I'm still using Python for some things), but I'd like to know if there's an idiom or hack to solve this particular problem.
I have a Ruby script which I'd like to be able to do require script_name with, but I'd also like to be ab... |
I want to read user input in Python to get a url (e.g. http://www.google.com) and then print the web page in HTML formatting (text only) to the terminal. I tried using pexpect.spawn('elinks') but elinks doesn't seem to write to stdout. I also looked at the HTMLParser module, but I don't know how I format the resulting ... |
I installed python3.2&cherrypy3.2 on my centos5.5, but when I tried to run helloworld I got the following message:
Traceback (most recent call last): File "/usr/local/lib/python3.2/site-packages/cherrypy/_cpcompat.py", line 179, in <module>
from Cookie import SimpleCookie, CookieError ImportError: No module n... |
Are there pythonic ways to maintain state (for purposes of optimisation, for example) without going fully object-oriented?
To illustrate my question better, here's an example of a pattern I use frequently in JavaScript:
var someFunc = (function () {
var foo = some_expensive_initialization_operation();
return so... |
I have two lists which are guaranteed to be the same length. I want to compare the corresponding values in the list (except the first item) and print out the ones which dont match. The way I am doing it is like this
i = len(list1)
if i == 1:
print 'Nothing to compare'
else:
for i in range(i):
if not (i ... |
I have a file structure like this:
dir_a __init__.py mod_1.py mod_2.pydir_b __init__.py my_mod.py
I want to dynamically import every module in dir_a in my_mod.py, and in order to do that, I have the following inside the __init__.py of dir_a:
import os
import glob
__all__ = [os.path.basename(f)[:-3] for f in glob.glob(o... |
All, thank you for the input. I really appreciate it. Unfortunately I realized that the way I currently posed the question, it is completely invalid. The keys in d2 correspond to subnet masks, which are not all unique, so the way I had it structured is not even a valid dictionary.
After a lot of fussing, I came up with... |
I have implemented oauth and openid separately (that is, sign in with OpenId, separate authorization to Google Data API with OAuth) and would like to combine them.
Currently I have the following in my app.yaml
- url: /_ah/login_required
script: main.py
- url: .*
script: main.py
login: required
Then, in main.py I... |
Secure your cookies
In settings.py put the lines
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True
and cookies will only be sent via HTTPS connections. Additionally, you probably also want SESSION_EXPIRE_AT_BROWSER_CLOSE=True. Note if you are using older versions of django (less than 1.4), there isn't a setting f... |
I need some properties to be unique. How can I achieve this?
Is there something like unique=True?
I'm using Google App Engine for Python.
There's no built-in constraint for making sure a value is unique. You can do this however:
query = MyModel.all(keys_only=True).filter('unique_property', value_to_be_used)
entity = qu... |
Here's what I've got so far:
project_dir = '/my/project/dir'
project_depth = len(project_dir.split(os.path.sep))
xml_files = []
for dirpath, dirnames, filenames in os.walk(project_dir):
for filename in fnmatch.filter(filenames, '*.xml'):
dirs = dirpath.split(os.path.sep)[project_depth:]
print(dirs)
... |
This IPython notebook show some features of the Python Nazca library :
Named Entities Matching is the process of recognizing elements in a text and matching it to different types (e.g. Person, Organization, Place). This may be related to Record Linkage (for linking entities from a text corpus and from a reference corpu... |
Python
runeveryday — 2010-03-23T05:12:33-04:00 — #1
def buildConnectionString(params):
"""Build a connection string from a dictionary of parameters.
Returns string."""
return ";".join(["%s=%s" % (k, v) for k, v in params.items()])
if __name__ == "__main__":
myParams = {"server":"mpilgrim", \\
"database":"master", \\
"u... |
Maisondouf
Re : Postfix est en train de me rendre fou ...
Pourtant à première vue, ce que tu veux pouvoir gérer n'est pas spécialement complexe mais je ne sais peut-être pas tout.
ASUS M5A88-v EVO avec AMD FX(tm)-8120 Eight-Core Processor, OS principal Precise 12.04.1 LTS 63bits½
Bricoleur, menteur, inculte, inadapté s... |
Where to get wxPython
The latest version of wxPython can always be found at http://alldunn.com/wxPython/. From this site you can download a self-installer for Win32 systems that includes a prebuilt extension module, documentation in HTML help format, and a set of demos.
Also available from this site is a Linux RPM, wxP... |
Ian Ward's email:
first name at this domain
wardi on OFTC, freenode andgithub
mkzip.py creates zip files from files stored on the web server. It can also calculate the final output size before creating a zip file. It uses no intermediate storage.
mkzip.py is designed to create custom zip files for web sites that let us... |
Also known as "The slowest implementation of the Game of Life in 2013". This is what happens when you have insomnia.
What I did was first clear out the entire world, then place a plane of glass across the entire world at y=1. The actual Life cells are Cobblestone blocks on the y=0 plane (the grid is on the Minecraft x-... |
PhoneGap
-> Callback
-> Cordova
-> PhoneGap?
Github -> Apache JIRA
https://issues.apache.org/jira/secure/IssueNavigator.jspa?reset=true&jqlQuery=project+%3D+CB+AND+fixVersion+%3D+%221.6.0%22+AND+resolution+%3D+Unresolved+AND+component+%3D+CordovaJS+ORDER+BY+priority+DESC&mode=hide
Phonegap is unusable as an app platfor... |
aeacides
Re : Ultimate Smash Friends: un smash bros like en python
Kewl! Bon boulot! De mon côté il me reste une semaine et demi de labeur, et après je devrais pouvoir m'y mettre :- )
@+
http://www.q-be.ca
Hors ligne
tshirtman
Re : Ultimate Smash Friends: un smash bros like en python
cool .
Mon petit frère (qui a dessi... |
I am trying to list directories and files (recursivley) in a directory with python:
./rootdir ./file1.html ./subdir1 ./file2.html ./file3.html ./subdir2 ./file4.html
Now I can list the directories and files just fine (borrowed it from here). But I would like to list it in the following format and ORDER (which is very i... |
I'm doing a project with this layout:
project/
bin/
my_bin.py
CHANGES.txt
docs/
LICENSE.txt
README.txt
MANIFEST.in
setup.py
project/
__init__.py
some_thing.py
default_data.json
other_datas/
default/
other_default_datas.j... |
Some background information: We have an ancient web-based document database system where I work, almost entirely consisting of MS Office documents with the "normal" extensions (.doc, .xls, .ppt). They are all named based on some sort of arbitrary ID number (i.e. 1245.doc). We're switching to SharePoint and I need to re... |
I'm looking for a nice way to write a generator that takes a stream of items from another list / generator / iterable and groups them.
Splitting items is easy. For example, if we want to take lines of a file and split them into characters:
def lines2chars(filename):
with open(filename) as fh:
for line in fh... |
This page describes how to make Pyjamas work with web2py. It is easy actually and it does not require any additional library other than web2py and pyjamas.
(Updated by Alexei Vinidiktov (alexei.vinidiktov (at) gmail.com) to work with pyjamas 0.5p1 and the built-in jsonrpc gateway of web2py.)
Inspired by this Django pag... |
In the June issue of Linux Journal (#158) there’s an article on Lua in which the author compares it to Python. The article is only available to subscribers at the moment, so I decided to post my comment here as well.
“There is no need to worry about different types of integers.”There is non need to do that in Python ei... |
Posted:February 18th, 2009 |
Author:Scott Barnham |
Filed under:Django | 2 Comments »
When we built the centralized authentication system for Red Robot Studios we wanted all authentication and account resources to be available solely over https.
This article covers some tips and tricks we discovered while building the ... |
Maisondouf
Re : Postfix est en train de me rendre fou ...
Pourtant à première vue, ce que tu veux pouvoir gérer n'est pas spécialement complexe mais je ne sais peut-être pas tout.
ASUS M5A88-v EVO avec AMD FX(tm)-8120 Eight-Core Processor, OS principal Precise 12.04.1 LTS 63bits½
Bricoleur, menteur, inculte, inadapté s... |
Module: Bio::Sequence::Common
Included in:
, ,
Defined in:
lib/bio/sequence/common.rb,
lib/bio/sequence/compat.rb
Overview
DESCRIPTION
Bio::Sequence::Common is a Mixin implementing methods common to Bio::Sequence::AA and Bio::Sequence::NA. All of these methods are available to either Amino Acid or Nucleic Acid sequence... |
gtk.TreeSortable — an interface for sorting a gtk.TreeModel
class gtk.TreeSortable(gobject.GInterface):
def sort_column_changed()
def get_sort_column_id()
def set_sort_column_id(sort_column_id, order)
def set_sort_func(sort_column_id, sort_func, user_data=None)
def set_default_sort_func(sort_func, u... |
An Introduction to Haskell, Part 1: Why Haskell
Pages: 1, 2
Writing this function in a more modern language like Java, C++ or C# isn't as odious, because automatic memory management takes care of the first half of this function. Writing the expression 'filter even [1..10]' in dynamic languages like Perl, Python and Rub... |
I just started python, any suggestions would be greatly appreciated. I'm reading a table generated by another program and pulling out 2 numbers from each line, I'll call them a and b. (they are saved as flux and observed in my program) I need to take these two numbers from each line and format them like this-
(a,b),(a,... |
Ive got a problem with running rails on apache + passenger. When I goto the site, I get in the /var/log/apache:
[Tue Nov 13 21:54:21 2012] [notice] Apache/2.2.16 (Debian) Phusion_Passenger/2.2.11 configured -- resuming normal operations
/usr/local/rvm/gems/ruby-1.9.2-p320/gems/mysql2-0.3.11/lib/mysql2/mysql2.so: [BUG] ... |
This is my solution to get ranges with float steps.
Using this function it's not necessary to import numpy, nor install it.
I'm pretty sure that it could be improved and optimized. Feel free to do it and post it here.
from __future__ import division
from math import log
def xfrange(start, stop, step):
old_start = s... |
Adobe Flash Professional version MX and higher
Adobe Flex
This technique relates to:
The objective of this technique is to show how non-text objects in Flash can be marked so that they can be read by assistive technology.
The Flash Player supports text alternatives to non-text objects using the name property in the acc... |
No, there is no standard guideline
But there are some techniques that can make a function with a lot of parameters more bearable.
You could use a list-if-args parameter (args*) or a dictionary-of-args parameter (kwargs**)
For instance, in python:
// Example definition
def example_function(normalParam, args*, kwargs**):... |
switched to
db file scattered reads
. Argh! This is not what I wanted.
direct path reads
For reference, when a server process asks the operating system for multiple blocks at once (for example, using the system call
) and places them into the buffer cache, Oracle records the time using the wait event facility and gives... |
I've seen a quite a few questions on the Project Euler and other places asking how to time the execution of their solutions. Sometimes the given answers are somewhat kludgey - i.e., adding timing code to __main__, so I thought I'd share my solution.
Python includes a profiler called cProfile. It not only gives the tota... |
enum ofp10_port_state {
OFPPS10_STP_LISTEN = 0 << 8, /* Not learning or relaying frames. */
OFPPS10_STP_LEARN = 1 << 8, /* Learning but not relaying frames. */
OFPPS10_STP_FORWARD = 2 << 8, /* Learning and relaying frames. */
OFPPS10_STP_BLOCK = 3 << 8, /* Not part of spanning tree. */
OFPPS10_... |
My understanding is that finally clauses must *always* be executed if the try has been entered.
import random
from multiprocessing import Pool
from time import sleep
def Process(x):
try:
print x
sleep(random.random())
raise Exception('Exception: ' + x)
finally:
print 'Finally: ' + x
Pool(3).map(Proc... |
Here we have some amazing tools: tmux, ranger, vim... Would be amazing to configure ranger to open the files (when text editable) in a tmux newpane? Is that easy and how it is done?
I did some research and find it is not too hard.
To open the current selected file in ranger in a new pane (to the right) in an ad-hoc man... |
64-bit VISTA
Python 3.1
from urllib import request
a = request.urlopen('http://www.marketwatch.com/investing/currency/CUR_USDYEN').read(20500)
b = a[19000:20500]
idx_pricewrap = b.find('pricewrap')
context = b[idx_pricewrap:idx_pricewrap+80]
idx_bgLast = context.find('bgLast')
rate = context[idx_bgLast+8:idx_bgLast+15]... |
The wiki page is always a good place to start. If you see the end of the page, it links to examples in both C and Python:
Here's the Python function, copied from the second link:
def sieveOfErat(end):
if end < 2: return []
#The array doesn't need to include even numbers
lng = ((end/2)-1+end%2)
# Create ... |
XML File Sample
<GateDocument>
<GateDocumentFeatures>
...
</GateDocumentFeatures>
<TextWithNodes>
<Node id="0"/>
MESSAGE SET
<Node id="19"/>
<Node id="20"/>
1. 1/1/09 - sample text 1
<Node id="212"/>
sample text 2
<Node id="223"/>
sample text 3
...
<Node id="16065... |
wlourf
Postez vos scripts Lua pour Conky !
Bonsoir à tous ceux pour qui chaque pixel du bureau compte,
J'ouvre ce topic suite aux discussions sur le topic des conky pour discuter des scripts Lua dans conky.
Lua est un langage de script léger et facile a utiliser qui permet d'ajouter de nouvelles fonctionnalités à nos c... |
For some reason most instances of classes are returning Type errors saying that insufficient arguments were passed, the problem is with self. This works fine:
class ExampleClass:
def __init__(self, some_message):
self.message = some_message
print ("New ExampleClass instance created, with message:")
... |
I am at a loss. I believe I have looked at every possible answer on google and stack overflow, but I am still banging my head against a wall. I have tried every different django integration of openid to no avail. I am currently using django_openid_auth
A more full description of the error:
check_authentication failed: ... |
How can I 'throw' deferred's into the reactor so it gets handled somewhere down the road?
Situation
I have 2 programs running on localhost.
A twisted jsonrpc service (localhost:30301)
A twisted webservice (localhost:4000)
When someone connects to the webservice, It needs to send a query to the jsonrpc service, wait for... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.