text stringlengths 256 65.5k |
|---|
If you want to give a little life to interactive (or not) elements, itâs always nice to have more tricks to manipulate images for nifty effects.
One of such ways is mapping a Texture on a special canvas instruction, that will distort your texture based on the position of its points.
[kivy.graphics.Mesh](http://kivy.o... |
import MySQLdb
import csv
import sys
db = MySQLdb.connect("host","username","password","dbname" )
c = db.cursor()
posfile = 'C:/Users/name/Desktop/textfile.txt'
csv_data_pos = csv.reader(open(posfile, 'rb'))
count_pos = 0
for row_pos in csv_data_pos:
count_pos = count_pos + 1
pos_file_update = "UPDATE Sentence ... |
nesthib
[JEU] challenge bash #6
Espaçeur de paragraphes
Imaginons un texte, celui-ci est composé de différents paragraphes. La plupart du temps un paragraphe sera coupé en deux à la fin d'une page. Le but de ce challenge est de réaliser un script qui formate le texte de façon à ce qu'un paragraphe ne soit jamais coupé ... |
The First Law of Systems Administration
This post details an outage I caused this week by making several poor decisions.
Each point contains lessons I have learned over the past 10 years, and in this instance studiously ignored. Things I am typically very careful to avoid doing. My record for not breaking things is act... |
I understand the differences between DFS (Depth First Search) and BFS (Breadth First Search), but I'm interested to know when it's more practical to use one over the other? Could anyone give any examples of how DFS would trump BFS and vice versa? Thanks!
That heavily depends on the structure of the search tree and the ... |
I was recently working on one small tool for Midgard Project, and had to deal with a new framework: PyGI. Strictly speaking, it’s not “totally new”, but it is: a) new for me b) just starts to get attention from application developers.
PyGI is a project, which implements dynamic bindings to GObject based libraries for P... |
When I am going to post user data in users table at parse.com I am getting Bad Request Error. What is wrong with this code? Any help Plz. Here is my code
if form.is_valid(): # All validation rules pass
username = form.cleaned_data['username']
name = form.cleaned_data['name']
password1 = form.cle... |
Is it possible to see files with certain extensions with the os.listdir command? I want it to work so it may show only files or folders with .f at the end. I checked the documentation, and found nothing, so don't ask.
import glob
for f in glob.glob("*.f"):
print f
Don't ask what?
[s for s in os.listdir() if s.ends... |
anonym_user
Re : Besoin de testeurs pour Pap'rass
Salut,
Excellente idée ce soft !
J'ai juste un petit problème : les doc ne se classe pas dans les chemises que je crée. Après chaque tentative de classement la recherche sur le classeur m'indique qu'il est vide. La recherche par mot clé retrouve le doc mais le document ... |
On Windows, subprocess.Popen.terminate calls win32's TerminalProcess. However, the behavior I see is that child processes of the process I am trying to terminate are still running. Why is that? How do I ensure all child processes started by the process are killed?
On Windows,
By using psutil:
import psutil, os
def kill... |
Is there a way to identify where traffic to a Google App Engine website is coming from? e.g. the previous website that the user was on?
Thanks.
Is there a way to identify where traffic to a Google App Engine website is coming from? e.g. the previous website that the user was on?
Thanks.
def get(self):
referer = sel... |
Im trying to get this working code from python to work in Google App Engine Launcher, but having trouble possibly with my code. It is working code in python, but for some reason the GAE Launcher will not work right. This is the code:
fname = raw_input('Enter your first name: ')
lname = raw_input('Enter your last name: ... |
I'm using django non-rel for appengine (djangoappengine) and have an app where the user selects an image and I have to return a crop from the selected image.
The images in my app are uploaded to the Blobstore following the django-filetransfers instructions. I've managed to upload (and even download) files just fine.
Th... |
Introduction to MapReduce with Hadoop on Linux
MapReduce with Hadoop
Hadoop is mostly a Java framework, but the magically awesome Streaming utility allows us to use programs written in other languages. The program must only obey certain conventions for standard input and output (which we've already done).
You'll need J... |
Selected ramblings of a geospatial tech nerd
Best bang for your analytical buck
As (geo)data scientists, we spend much of our time working with data models that try (with varying degrees of success) to capture some essential truth about the world while still being as simple as possible to provide a useful abstraction. ... |
I'm trying to go through a file line by line (each line is no more than 50 characters), shift each character by 10 or -10 (to encrypt and decrypt) and then print the shifted string where the old string was. But I'm getting some really funny output.
heres the code:
#include <stdio.h>
int main(void){
FILE *fp;
fp... |
Trying to drill through a directory on my drive that has subfoldrs within it. When I find files that have the file extensions I'm looking for I want the full file path. Right now this is what I have:
import os
import Tkinter
import tkFileDialog
from Tkinter import Tk
from tkFileDialog import askopenfilename
root = Tkin... |
I have a dictionary where I want to alphabetically sort the keys that have the same value assigned to them.
For example: {chai:1, apple:1, dom banana:1}
How do I sort these keys alphabetically?!
Thanks.
>>> from collections import defaultdict
>>> items = {'chai':1, 'apple':1, 'dom banana':1}
>>> d = defaultdict(list)
>... |
I'm trying to write a decorator that provides method overloading functionality to python, similar to the one mentioned in PEP 3124.
The decorator I wrote works great for regular functions, but I can't get it to work for methods in a class.
Here is the decorator:
class Overload(object):
def __init__(self, default):
... |
In my Python script I need to retrieve both the IP address of the machine the script is running on and its network address and its network bytes.
As for the IP address, I found the solution in the archive:
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("www.google.com",80))
myAddress = (s... |
I'm writing a program for converting media file to mp3 file with GStreamer. It works, but I would like to know the duration of audio stream, too. Following is the simplified code.
import logging
import pygst
pygst.require('0.10')
import gst
# this is very important, without this, callbacks from gstreamer thread
# will ... |
djara
Re : Récupération de windows après insttallation de ubuntu 12.10 64bit
Merci. Je te tiens informer dans quelques minutes du résultats.
Merci
Hors ligne
djara
Re : Récupération de windows après insttallation de ubuntu 12.10 64bit
Voila ce que j'ai obtenu en reprenant avec la version officiel le lien : http://paste... |
Below is description of my que:
I have added bookmarklet feature to my site. For this, I have provided one link called "my bookmark" in my site.. So, I will drag that link to bookmark and it will be added to bookmark. So, from now, when I m visiting other site say "yahoo.com" .. and I like any content of that site so I... |
gtk.RadioToolButton — a toolbar item that contains a radio button (new in PyGTK 2.4)
class gtk.RadioToolButton(gtk.ToggleToolButton):
gtk.RadioToolButton(group=None, stock_id=None)
def set_group(group)
def get_group()
+--gobject.GObject+-- gtk.Object +-- gtk.Widget +-- gtk.Container +-- gtk.Bin +-- gtk.Too... |
If you are not into long explanations, see Paolo Bergantinoâs answer.
Decorator Basics
Pythonâs functions are objects
To understand decorators, you must first understand that functions are objects in Python.This has important consequences. Letâs see why with a simple example :
def shout(word="yes"):
return wo... |
In my last post, I briefly mentioned autojump’s awesome j command toquickly move between directories. But once in a while you need that little extrabang when working with files and directories. Well, there are file managers likeMidnight Commander, for those stuck in an era when people shared Monkey Islandon floppy disk... |
smo
Re : Gmediafinder : Youtube/dailymotion/vimeo.. sans flash et bien plus....
ola
ok cool je vais regarder ca apres, la j en fais un "normalement" c est un peu (beaucoup...) plus complique pour les ppa
j vous tiens au jus !
et whoue si vous avez des idees, hesitez pas hein ... j aimerais bien avoir des visualisations... |
The Ledger - How Balanced Records Funds Flow
Balanced, like many companies, has a number of internal applications. Today, I’d like to talk to you about how one of those apps, called ‘balanced’, handles its accounting, since that’s at the heart of what we do.
balanced has a few atoms which interact to model funds flow:
... |
I am trying to connect MySQLdb to MySQL. It was working fine when when my server was localhost and port 80. But due to some reason I had to change the port to 8080. Now how do I specify the port in the connect command?
This is what I was using earlier:
db = MySQLdb.connect(host = "localhost", user = "root", passwd = ""... |
By: Matt Brown
22 Jan 2014
Nothing has advanced my skill and career more than being around programmers who are much better than I am at programming. There's something awe-inspiring when you first meet people who are better at coding than you. They are like wizards, commanding all of nature to bend to their will. In an ... |
As simple as it gets...
MediaPlayer player = MediaPlayer.create(context, R.raw.somemp3file);
player.start();
But nothing happens? From: http://developer.android.com/guide/topics/media/index.html
Android 2.2 @ HTC Desire
MediaPlayerService
06-11 22:11:00.392: VERBOSE/MediaPlayerService(18690): Client(28) constructor
06... |
I'm trying to reimplement python slice notation in another language (php) and looking for a snippet (in any language or pseudocode) that would mimic the python logic. That is, given a list and a triple (start, stop, step) or a part thereof, determine correct values or defaults for all parameters and return a slice as a... |
Fast, isolated development environments using Docker.
Define your app's environment with Docker so it can be reproduced anywhere:
FROM python:2.7ADD . /codeWORKDIR /codeRUN pip install -r requirements.txt
Define the services that make up your app so they can be run together in an isolated environment:
web: build: . com... |
I'm new to python and dbus, but is there a data binding (= a way to send and receive) python classes via dbus-python?
My class looks like this:
class Item:
def __init__(self, one, two, three, four, five, *more):
self.one= one
self.two= two
self.three= three
self.four= four
se... |
I have just learned about SIGPIPE, and then read about how to handle these in Python.
Among other sources, I have read: How to handle a broken pipe (SIGPIPE) in python?
Let's say that the pipe reading script exits, then all the answers suggest that the writing script wrappes its write calls in a try clause.
However, I ... |
I want to send emails with various attachments. These attachments are stored as FileField in a django model. I manage to create the mail and to send an attachment, but the attachment is empty, whereas I would like it to contain the FileField content. Thanks for your help!
def sendEmailHtml(fromaddr, toaddrs, body, subj... |
The role of the network administrator is broad and varied. While most of our time is spent with day-to-day operational tasks such as assigning IP addresses and configuring hosts and applications to use an existing network, we'll occasionally be called upon to do some more interesting things.
One of the more interesting... |
Partial GET requests are a handy way for a client to request a portion of a resource, rather than the entire resource. HTTP clients send a Range: bytes=start-stop request header, where start and stop are non-negative integers. The HTTP server can then send only those bytes (inclusive) in the response. Multiple byte ran... |
I have installed scipy with port on my mac. it says all is fine:
$ sudo port install py-scipy
Password:
---> Computing dependencies for py-scipy
---> Cleaning py-scipy
but when i pull up python, it doesn't see it:
$ python2.6
Python 2.6.7 (r267:88850, Jul 27 2011, 11:54:59)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3... |
The Python language
About Python
Python is a general-purpose high-level programming language. Its design philosophy emphasizes programmer productivity and code readability. It has a minimalist core syntax with very few basic commands and simple semantics, but it also has a large and comprehensive standard library, incl... |
This series of articles by David Mertz assumes readers have a familiarity with basic object-oriented programming concepts: inheritance, encapsulation, and polymorphism. We pick up where the basics leave off; how some "exotic" techniques can make applied programming tasks easier, more maintainable, and just plain more e... |
Hada de la Luna
[résolu] 12.04 LTS : régler la luminosité de façon "définitive"
Bonjour,
pour une personne qui a des problèmes avec la luminosité excessive de l'écran, j'aimerais savoir comment régler cela de façon "fixe" qui ne soit pas remise en question à chaque démarrage.
En effet, en utilisant : Paramètres système... |
IronPython requires .NET 4.0 to run. As of V8, Mathematica launches .NET 2.x by default. See this question for details about how to use .NET 4.0. Having done that, we need to load the IronPython assembly into the .NET framework:
Needs["NETLink`"]
InstallNET[];
$pythonDll = "C:\\Program Files (x86)\\IronPython 2.7.1\\Ir... |
The problem is to used fixed-point iteration method to find an approximation to $\sqrt{3}$. The equation from the book is $f(x) = \dfrac{1}{2}\left(x + \dfrac{3}{x}\right)$. It make senses to me however I realize there are other equations can be used to approximate $\sqrt{3}$ as well, for example $f(x) = 2x - \sqrt{3}$... |
Convertir notación de coordenadas (Administración de datos)
Resumen
Convierte notaciones de coordenadas que representan ubicaciones de un formato a otro.
Uso
La tabla de entrada puede ser un archivo de texto o cualquier tabla compatible con ArcGIS.
La salida es una clase de entidad de puntos en la que cada ubicación de... |
n3o51
Liste des onglets
Bonsoir y a t'il un moyen de copier directement dans un fichier txt la liste des onglets ouverts dans opera et firefox ?
ligne par ligne ?
Merci d'avance
Edit modérateur : si vous n'avez pas de réponses à donner, ne sortez pas le sujet des "Sujets sans réponses".
Dernière modification par xabilo... |
I am trying to scan my harddrive for jpg and mp3 files.
I have written the following script which works if I pass it a directory with file in the root but does not return anything if I pass it the root directory.
I am new to Python so would love some help.
def findfiles(dirname,fileFilter):
filesBySize = {}
def... |
Django has done a lot right with their framework and signals is one of the best parts. Signals help decoupled applications get notified when other actions occur in the framework.
Using signals
Out of the box Django gives you several signals that are incredibly useful. You have the ability to do things pre and post save... |
I'm still new to Python and I've been working with a script to get system info from my Raspberry Pi, like cpu temp and such and import it to a google doc spreadsheet. My goal is to extract the numbers from the output, which is in the form temp=54.1'C. I need the numbers alone to be able to graph the data over time...
I... |
Although this post is about writing a redirect script for App Engine, it doesn't require that any of the sites are hosted on App Engine, so it could be useful to you even if you're hosting .NET websites elsewhere, but need to handle redirecting old domains.
If you believe what Derek Says, I change my domain every 5 min... |
You can do it a couple of ways:
1.You can have a document file model which keeps track of it manually.
class DocumentFile(CachedModel):
content_type = models.ForeignKey(ContentType, null=True, blank=True)
object_id = models.PositiveIntegerField(null=True, blank=True)
content_object = generic.GenericF... |
This is honestly the most finicky and inept language I've ever coded in. I'll be glad when this project is good and over with.
In any case I have to us PHP so here's my question.
I have an Array named $form_data as such:
$form_data = array
('trav_emer_med_insur',
'trav_emer_single',
'trav_emer_single_date_go',
'trav_e... |
OK, After a bit of fiddling, I've tweaked a script from the site hyperlink in the second comment line. The purpose of the script is to clip/mask a LARGE raster (i.e. that cannot fit into a 32-bit Python 2.7.5 application) in GTiff format with a shapefile with multiple polygons (each with a "Name" record) and save the c... |
I love SQLObject, but this is a rant about the tiny frustrations I face with it.
First, this is a minor point. I don’t really care about database independence that much. Postgres has a lot of wonderful features: I never have to worry about choosing the table engine that will enforce foreign key constraints, I like crea... |
I'm trying to fit a normalized curve to my data. I have thousands of datapoints in a csv file, and I'm using matplotlib to plot it. I'm not sure which statistic to use exactly. I was thinking that this would be a normal/Gaussian distribution. If so I'm still not sure how I would calculate/graph it.
Here's an example of... |
I'm having problems trying to validate a form so that it only ever picks a distinct partner. The classes work like this:
class EmpployeeAdmin(admin.ModelAdmin):
#.......
class EmployeeRoles(models.Model):
partner = model.ForeignKey(Partner, relative_name='employee')
employee = model.ForeignKey(Employee,... |
So i have a piece of code that looks like this:
<read-write buffer ptr 0x000000000286AB78, size 855 at 0x000000000286AB40>
I think it should be an image file :)
I look around and found some links to memoryview but looking at the documentation didn't seem like it would be what im after. Of course im rather new to progra... |
I haven't had anyone help me out with code review, etc, so I thought I'd post a Python class I put together for interfacing with Telnet to get information from a memcached server.
import re, telnetlib
class MemcachedStats:
_client = None
def __init__(self, host='localhost', port='11211'):
self._host = h... |
Введение
Добрый день, уважаемые читатели.
Недавно, бродя по просторам глобальной паутины, я наткнулся на
турнир
, который проводился банком ТКС в начале этого года. Ознакомившись с заданиями, я решил проверить свои навыки в анализе данных на них.
Начать проверку я решил с задачи о скоринге (Задание №3). Для ее решения ... |
I've written the following program in Python:
import re
import os
import string
folder = 'C:\Users\Jodie\Documents\Uni\Final Year Project\All Data'
folderlisting = os.listdir(folder)
for eachfolder in folderlisting:
print eachfolder
if os.path.isdir(folder + '\\' + eachfolder):
filelisting = os.listdir(... |
What is the naming convention for a variable referencing a class in Python?
class MyClass(object):
pass
# which one is correct?
reference_to_class = MyClass
# or
ReferenceToClass = MyClass
Here is another example that resembles my situation:
# cars.py
class Car(object):
pass
class Sedan(Car):
pass
class Co... |
CoffeeScript is a little language that compiles into JavaScript. Underneath that awkward Java-esque patina, JavaScript has always had a gorgeous heart. CoffeeScript is an attempt to expose the good parts of JavaScript in a simple way.
The golden rule of CoffeeScript is: "It's just JavaScript". The code compiles one-to-... |
There are some children sitting around a round table. Each child is given an even amount of $1$-cent coins ($0$ is even) by their teacher, all the children at once. A child will give half his money to the child by his right, then the receiving child gives half of his to the one by his right and it goes on like that. If... |
I am developing a native application for Ubuntu using quickly. How can I disable few key bindings such as prevent Ctrl + F4 from closing the window, and other key combinations?
This is how you'd modify the global keybindings managed by Compiz. However, this would only work for systems using compiz as the window manager... |
g_barthe
interface python et apprentissage boa constrictor
Bonjour,
Je voudrais commencer à developper qq applications (avec interfaces graphiques) en python (pour windows et linux). Je recherche donc un éditeur qui permettrait de realiser l'interface de maniere simple et non en code pur. J'ai bien trouvé "wxglade" mai... |
Python
novice2010 — 2010-12-14T10:27:45-05:00 — #1
I have been tearing this code apart and putting it back together.
I understand some of the concept but not all of them.
Can you please tell me what each line in this code does?
class Site(object):
def __init__(self, SiteNum="0", SiteAddr="", SiteInv=0):
self.ID=SiteNum... |
I have not had much luck hunting for finding a good explanation of what invalid argument errors are and what would cause them.
My current sample I am working with is
import sys
mylog="mylog.log"
sys.stdout = open(mylog,'w')
#lots of code
#.
#.
#.
#End of lots of code
from time import clock
print "blablabla",clock()
I ... |
I'm running a loop through 360+ txt files that counts occurrence of certain words in each file. Code is below:
>>> cnt=Counter()
>>> def process(filename):
words=re.findall('\w+',open(filename).read().lower())
for word in words:
if word in words_fra:
cnt[word]+=1
if word in words_1:
cnt[word]+=1... |
Writing a python script and it needs to find out what language a block of code is written in. I could easily write this myself, but I'd like to know if a solution already exists.
Pygments is insufficient and unreliable.
Writing a python script and it needs to find out what language a block of code is written in.
Pygmen... |
In most well-known OO languages, an expression like SomeClass(arg1, arg2) will allocate a new instance, initialise the instance's attributes, and then return it.
In most well-known OO languages, the "initialise the instance's attributes" part can be customised for each class by defining a constructor, which is basicall... |
Manipulating sys.modules
You can manipulate the modules cache directly, making modules available or unavailable as you wish:
>>> import sys
>>> import ham
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named ham
# Make the 'ham' module available -- as a non-module object... |
The loop variable d is always a reference to an element of the iterable object. The question is not really a matter of when or when isn't it a reference. It is about the assignment operation that you are performing with the loop.
In the first example, you are rebinding the original reference of an element in the object... |
I have a python script that checks continuously for snmpd and a socket script to be running .If any of these get killed it should kill both and start new session. The problem is once socket is running it wait for connection for long ,in between if anyone kill snmpd its not getting started (think its not going to loop b... |
I have this issue when I would like to go the Game Over screen.
Traceback (most recent call last):
File "C:\Users\MO\Desktop\Twerk\ballbounce_changed.py", line 215, in <module>
game()
File "C:\Users\MO\Desktop\Twerk\ballbounce_changed.py", line 191, in game
text("Game Over",30,white,300)
TypeError: 'pygame.Surfa... |
I want to connect to a mongodb database using excel macros, does anybody knows how to acomplish this task?
Simple way is
.
Private Sub CallMongo()
Dim mongoObj As New MyMongoAssembly
mongoObj.AddItem("adas");
End Sub
thats all..
My own solution was to let Python glue them together using pymongo and win32com. I... |
Jx7
Re : [script] Télécharger de nombreuses quotidiennes de canal+ (suite)
J'ai l'impression que tu as un problème de droits d'écritures.
Hors ligne
Jx7
Re : [script] Télécharger de nombreuses quotidiennes de canal+ (suite)
Où as-tu placer le script?
Hors ligne
Jx7
Re : [script] Télécharger de nombreuses quotidiennes d... |
CSS
scott1964 — 2013-11-18T10:37:06-05:00 — #1
Greetings ... I am developing a site that uses a wordpress theme ... the customer wants it customized to include two login panels for Attorneys and Reporters at the very top of the screen. I've altered the index file to include the correct markup, but for some reason, the ... |
Implementing the ID3 Heuristic
The ID3 heuristic uses the concept of entropy to formulate the gain in information received by choosing a particular attribute to be the next node in the decision tree. Here's the entropy function:
def entropy(data, target_attr):
"""
Calculates the entropy of the given data set fo... |
DatEpicCoderGuyWhoPrograms
less info
106 reputation
3
bio website mobile.twitter.com/…
location Minneapolis, MN
age 28
visits member for 2 months
seen Jul 23 at 14:15
stats profile views 1
life == "good"
Here's some things you should know about me.
Don't wake me up earlier than 7:30, unless you want your face dented in... |
Within a Python scope, any assignment to a variable not already declared within that scope creates a new local variable unless that variable is declared earlier in the function as referring to a globally scoped variable with the keyword global.
Let's look at a modified version of your pseudocode to see what happens:
# ... |
I need the string SKU: E02165 witch is somehow encoded as
SKU: E02165
by some means, here is the full div strait from the web site
<div class="sku">SKU: E02165 </div>
I have tried
soup = BeautifulSoup(data)
info = soup.find('div' , {'class':'sku'}).contents
as well all of the flowing... |
ogaby
Re : [ATTENTION] Faille de sécurité critique dans le noyau Linux !
vi...
Avec cette simple ligne, on peut bénéficier des mises-à -jour de sécurité plus rapidement que sur un dépà´t européen. Je dis "européen" car je vis en Allemagne et mon dépà´t "normal" n'a pas encore cette mise-à -jour.
Hors ligne
zappinggg
Re... |
I need to match ANY strings that start with:
'/Engine
and end with:
ir_vrn'
I have used this:
vrn_page = re.compile('\'/Engine[a-zA-Z0-9._+-&/?:=]+ir_vrn\'')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/re.py", line 190, in compile
return _compile(pattern, flag... |
Nose cannot do this by default, to my knowledge. Here are some options:
1. Fake it from the command line
Probably not what you're looking for, but I had to mention it. You could alsocreate a wrapper script to simplify this:
python -c 'import testFile; testFile.check_even(2, 6)'
2. Create a custom nose test loader
This... |
pilote
[résolu] impossible d'acceder au site adobe.com
bonjours,
voici le problème
-> Firefox ne peut établir de connexion avec le serveur à l'adresse www.adobe.com
-> Opéra: Vous tentez d'accéder à l'adresse http://www.adobe.com/, actuellement injoignable... etc.
a priori c'est le seul site à me faire ça !
Je ne sais ... |
Entertainment Weekly caught up with both Robert Downey Jr. and director Jon Favreau this week after the mega-success of "Iron Man" at the box-office and dis
cussed the upcoming sequel.
Most interesting is that Favreau wasn't aware of the announcement until it happened - "We've been speaking informally about it. In con... |
So I am trying to import a module "foo" that contains directories "bar" and "wiz". "bar" contains python files a.py, b.py, and c.py. "wiz" contains python files x.py, y.py and z.py.
$ ls foo
__init__.py bar wiz
$ ls foo/bar
__init__.py a.py b.py c.py
$ ls foo/wiz
__init__.py x.py y.py ... |
I need to send a PUT request to a web service and get some data out of error headers that is the expected result of the request. The code goes like this:
Request = urllib2.Request(destination_url, headers=headers)
Request.get_method = lambda: 'PUT'
try:
Response = urllib2.urlopen(Request)
except urllib2.HTTPError, e... |
DatEpicCoderGuyWhoPrograms
less info
106 reputation
3
bio website mobile.twitter.com/…
location Minneapolis, MN
age 28
visits member for 2 months
seen Jul 23 at 14:15
stats profile views 1
life == "good"
Here's some things you should know about me.
Don't wake me up earlier than 7:30, unless you want your face dented in... |
Write a program to factorize a semi-prime number in the shortest amount of time.
For testing purposes, use this: 38!+1 (523022617466601111760007224100074291200000001)
It is equal to: 14029308060317546154181 Ã 37280713718589679646221
Python (w/ PyPy JIT v1.9) ~1.9s
Using a Multiple Polynomial Quadratic Sieve. I took th... |
I have a Python application, executing in Google App Engine. The app uses Google Calendar API and api-client-library. My code, simplified, looks like this:
import webapp
oauth2_decorator = oauth2decorator_from_clientsecrets(
CLIENT_SECRETS,
scope=CALENDAR_SCOPE,
message=MISSING_CLIENT_SECRETS_MESSAGE)
class... |
r³
r³ is a map reduce engine written in python using a redis backend. It's purpose is to be simple.
r³ has only three concepts to grasp: input streams, mappers and reducers.
The diagram below relates how they interact:
If the diagram above is a little too much to grasp right now, don't worry. Keep reading and use this ... |
So I checked out the question on the Python the Hard Way website that you linked to...I think he was actually just asking you to re-write his original script using a for loop and range in that case you could do something like this:
numbers = []
for i in range(6):
print "at the top i is", i
numbers.append(i)
... |
Is there a way to whiten out the background of the axis label so that when it crosses the axis line itself, the latter does not run through it?
For example, this script (the best I managed so far)
#!/usr/bin/python
import matplotlib.pyplot as plt
xx=[1,2,3]
yy=[2,3,4]
dy=[0.1,0.2,0.05]
fig=plt.figure()
ax=fig.add_subp... |
Two questions about presets in Max 6
Here is a simple test for reading and writing presets.
allof the following text. Then, in Max, select
New From Clipboard.
----------begin_max5_patcher----------
651.3ocuVt0jaBBEG+Y8SgCOmlwa4VeqeN5rSFhbxF1AAG.SR6N46dQTxpIl
MVqceQGO.mK+3+A4ceOzNwYPgB9dvOC77d22yyZpxfWy2dnb74LFVYmFhCmD
... |
I'm trying to find the functional equivalent of logic statements in Python (e.g. and/or/not). I thought I had found them in the operator module, but the behavior is remarkable different.
For example, the and statement does the behavior I want, whereas operator.and_ seems to requir an explicit type comparison, or else i... |
The simpler way might be to construct the date explicitly as so:
now = datetime.now()
previous_midnight = datetime.datetime( now.year, now.month, now.day )
That gets you the timestamp for the just passed midnight. As you already know time.mktime will get you your the epoch value. Just add or subtract 24 * 60 * 60 to g... |
k3c
[script] Rebooter une livebox Mini avec un script Python
J'ai retrouvé ce script Python pour rebooter une Livebox Mini.
remplacez fti/abcdefg
par votre fti/...
c'est tout il me semble
Je ne peux le tester, n'ayant pas de Livebox.
Il reste des "print" de debug, à virer.
#!/usr/bin/python
# -*- coding: cp1252 -*-
imp... |
There's two parts to making seamlessly tileable fBm noise like this. First, you need to make the Perlin noise function itself tileable. Here's some Python code for a simple Perlin noise function that works with any period up to 256 (you can trivially extend it as much as you like by modifying the first section):
import... |
I'm using Node.js, Express and Jade and I'm trying to figure out how to post, validate & process form data.
In my jade file I create a contact form:
div#contact-area
form(method='post',action='')
label(for='name') Name:
input(type='text',name='name',id='name')
label(for='email') Emai... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.