text stringlengths 256 65.5k |
|---|
I'm trying to run the embedding example and I can't load a module from the current working directory unless I explicitly add it to sys.path then it works:
PyRun_SimpleString("import sys");
PyRun_SimpleString("sys.path.append(\".\")");
Shouldn't Python look for modules in the current directory ?
Edit1: Tried just impor... |
derzhou
problème home en lecture seul
Bonjour,
J'ai installé ubuntu 12.10 depuis quelques jours et voilà d'un coup qu'il m'interdit toute écriture dans mon home.
J'ai booter sur cdlive et lancer un fsck, mais au redémarrage sur mon DD, même problème le home est toujours en lecture seul.
Une idée ?
merci pour vos répons... |
Unfortunately your rle_walk has a bug; it takes parameter gen but should take parameter data, so it's operating on the wrong input. Also, it's unfair to make rle_walk use a lambda where rle_list works inline. Rewriting like so:
def rle_walk(data):
return [(k, sum(1 for _ in g)) for k, g in groupby(data)]
def rle_li... |
Rather than trying to fsck the dos partition how about just zero'ing the parition table, create the partition table from new and re-format the DOS partition.
Suppose the USB stick is on /dev/sdc, first make sure /dev/sdc1 is unmounted:
umount /dev/sdc1
Then clear the partition table, say by copying a bunch of zeros ov... |
PotatoMasher
Re : Script d'installation pour imprimantes Brother
D'accord, alors j'ai retiré brscan2 de /etc/sane.d/dll.conf. brscan-skey -l donne toujours le même device, "Not Registered".
Après avoir jeté un coup d'oeil aux groupes, je réalise que mon utilisateur n'est pas membre du groupe "scanner" et du groupe "san... |
sosmayo
[Résolu]Udev HDMI pulseaudio changement automatique de la sortie audio
Bonjour à tous !
Il y a quelque temps j'ai partagé une petite astuce permettant de rediriger automatiquement le son vers HDMI lorsque celui ci est branché http://forum.ubuntu-fr.org/viewtopic.php?id=1119211.
Cependant depuis une mise à nivea... |
I just read another users question while looking for a way to compute the differences in two lists.
My question is why would I do
def diff(a,b):
b = set(b)
return [aa for aa in a if aa not in b]
rather than doing
def diff(a,b):
tmp = []
for i in a:
if(i not in b):
tmp.append(i)
retu... |
Please consider using this website to upload your scripts:
It's a bit more organized and allows for easier browsing/uploading/viewing/downloading. If you have any comments/suggestions on that site, please use the feedback link. Eventually the scriptshare website's functionality will be incorporated into pnotepad.org, b... |
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 ... |
I am creating UserResource and UserProfileResource. When I create a new user I see that my userprofile database table is also being updated. Which is good. But when I GET the user I get an error saying:
The model '' has an empty attribute 'profile' and doesn't allow a null value.
My code:
resources.py
class UserProfil... |
Here's my ORM entity class. The primary key is composite cause 'id_string' may be the same for different users (identified by uid). One thing I understood from Postgres SQL error when creating a table based on this class (
ProgrammingError: (ProgrammingError) there is no unique constraint matching given keys for refere... |
Basically I have a subpackage with the same name as a standard library package ("logging") and I'd like it to be able to absolute-import the standard one no matter how I run it, but this fails when I'm in the parent package.
It really looks like either a bug, or an undocumented behaviour of the new "absolute import" su... |
From time to time I get requests to make some high power switching, so I decided to design a solid-state relay that could handle a lot of different situations. The most common use for it I have is refurbishing old ceramic kilns. Since our technical life is close to the stage (both theatre and music), I also wanted it t... |
This IPython notebook show some features of the Python Nazca library :
from IPython.display import HTMLHTML('<iframe src=http://en.mobile.wikipedia.org/wiki/Record_linkage?useformat=mobile width=700 height=350></iframe>')('http://data.bnf.fr/11907966/victor_hugo/', 'Victor Hugo', 1802, 1885, u'Besançon (Doubs)', u'Pari... |
I am trying to insert data into MySQL with a list using Python.
The list contains both strings and integers.
I am not able to use %s for string replacement also % does not work.
def insert(self,data):
db = MySQLdb.connect(db=self.database,host=self.host,port=self.port,user=self.user,passwd=self.password)
c=db.... |
grim7reaper
Re : Besoin de conseils pour débuter en python
Merci, cette documentation me semble plutôt complète et complexe pour un débutant python
Complexe, non je ne pense pas.
Du moins ce n’est pas le but.
Outre ce cadre universitaire assez réduit, ce cours s’adresse à toute personne désireuse d’apprendre Python en ... |
At work recently I was writing some tests with Python’s out-of-the-box unit-testing framework unittest. I’m new to Python and accustomed to Perl and Haskell’s testing frameworks, which are lightweight and let you write tests without much hoop-jumping. In particular, QuickCheck and LectroTest make it easy to test at the... |
pops
logiciel d'animation en pixel art
Bonjour,
Je voulais vous présenter un petit logiciel d'animation en pixel art sur lequel je travaille depuis un peu plus d'un mois.
C'est encore très sommaire, mais il commence a être utilisable :
On peut dessiner avec des couleurs indexées, animer, il y a quelques brosse et on pe... |
(También podéis seguir las explicaciones de este post con este Notebook)
En esta entrada trataremos de dar a conocer plotly, un servicio web gratuito para generar gráficos interactivos y que permite la creación de proyectos colaborativos.
Los paquetes que vamos a emplear son,
pandas0.14.0, para importar y analizar estr... |
I can write both Prim's and Kruskal's algorithms to find a minimum spanning tree in C++ or Java, but I want to know how to implement them in Haskell with O(mlogm) or O(mlogn) (pure functional programs is better). Thanks a lot.
As svenningsson suggests, priority search queue is well suited for both Kruskal's and Prim's ... |
prettyplotlib: Painlessly create beautiful matplotlib plots
A while back I wrote a few tutorials about how to work with Python’s plotting library, matplotlib, so that it behaves nicely and produces beautiful plots. Well, I got tired of tweaking every single figure individually so I wrote this library, prettyplotlib to ... |
jegougou
Re : [Info] Installation du driver Libre ATI Radeon
j'ai suivis ton conseil voila le resultat
4294 frames in 5.0 seconds = 858.715 FPS
4254 frames in 5.0 seconds = 850.774 FPS
4190 frames in 5.0 seconds = 837.903 FPS
3269 frames in 5.0 seconds = 653.660 FPS
4400 frames in 5.0 seconds = 879.915 FPS
4398 frames ... |
Parslet Tree Mangling and Transformations
A simple parser in parslet will at first only output strings from its parsing stage:
class SimpleParser < Parslet::Parser
root :ifthenelse
rule(:ifthenelse) {
_if >> _then >> _else.maybe
}
rule(:_if) { str('if') >> space? >> number }
rule(:_then) {... |
smo
Re : logiciel creation/remasterisation/clonage de distributions base ubuntu
je viens d ajouter quetzal i386 je telecharge pour tester je maj le git apres si ok ... (pas d raisons..)
ht5streamer, streaming youtube/dailymotion...: http://forum.ubuntu-fr.org/viewtopic.php?id=1299461 / http://ht5streamer.free.fr
ubukey... |
I'm looking for a simple and fast way to find the root of the package and the full module name from a path to .py file.
I want the user to choose a .py and import it without breaking. Importing a module if it's part of the package will likely break. Thus I want to automatically append the directory wherein the root of ... |
Le_Novice
Configurer les canaux logiciels
Bonjour !!
J'ai suivi la documentation concernant la configuration des canaux logiciels...
- J'ai supprimé tous les dêpots présents comme indiqué en utilisant l'option Enlever.
- Puis, j'ai ajouter les 4 canaux disponibles, en cochant tous les composants à chaque fois (Officiel... |
lekokeliko
Tictactux jeu en Python
Je tient a vous présenter ma grande réalisation :
le Tictactux en python développé depuis la nuit du 24 decembre 2007
morpion like parametrable a souhait
quelques précisions :
versions antérieures :
-1.07.29 beta test
-1.07.30 détails des modifs plus bas (post 7)
-1.07.31 modification... |
Despite not being Catholic, the papal election fascinates me. Not sure if it’s the old rituals, the world-wide interest, or simply the fact that the Catholic Church has left a huge mark on history.
There’s no way I know enough about the inner workings of the Catholic Church to have any idea on who the next Pope may be.... |
I've got a GAE-app that uses Jinja2 templates to serve its html pages.
Now in my main python file I've got one class, mainhandler, with a GET and a POST method. This all works for the welcome screen where there is a button to do something. When the button is clicked, the POST method is invoked which calls a second page... |
This is a really broad question: "How to get emails from Gmail?", "How to filter the emails?" and "How to parse structured data from an email?"
How to get emails from Gmail?
You can fetch emails from Gmail using the IMAP protocol. This can be done using the imaplib standard library.
Another StackOverflow user gave a sn... |
On peut choisir le niveau d'overclocking par le menu raspi-config:
Une fois que l'on redemarre:
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
Ca nous donne 700000, soit 700,000 KHz ou encore 700 MHz. Mais j'ai choisi 800, non? C'est un overclock dynamique.
Il faut mettre une charge sur le cpu, ce que je fai... |
I noticed that if you use the simplejson function in django all the strings are enclosed with single quotes, and the whole json object string is enclosed in double quotes. When I take this string and hand it in to JSON.parse, it gives me an error because they want to use single quotes to enclose the whole object and do... |
Other recipes
Upgrading
In the "site" page of the administrative interface there is an "upgrade now" button. In case this is not feasible or does not work (for example because of a file locking issue), upgrading web2py manually is very easy.
Simply unzip the latest version of web2py over the old installation.
This will... |
A common way to get the animation data is to loop over the scene's frame range and read the matrices for every single frame. This is okay most of the time, and way easier to do than reading the F-Curve data directly (which won't include F-Curve modifiers and Drivers AFAIK).
Assume the Armature object is currently activ... |
chaoswizard
Re : TVDownloader: télécharger les médias du net !
Bonsoir,
Non ce n'est pas possible, RtmpDump (et je suppose Flvstreamer) n'arrive pas à parser l'URL si elle n'est pas découpée.
J'avais étudié ce problème en mettant au point Arte Live Web pour TVO.
Bon courage pour votre projet
Je viens pourtant de tester... |
The response is absolutely no surprise: in fact
In [1]: -5768830964305142685L & 0xffffffff
Out[1]: 1934711907L
so if you want to get reliable responses on ASCII strings, just get the lower 32 bits as uint. The hash function for strings is 32-bit-safe and almost portable.
On the other side, you can't rely at all on gett... |
Hi I have a function that read in data from two files. What I want to be happening is that the outer loop starts to read in the the first file and if lum from the first file is greater than the defined value (LC) the loop skips to the next iteration. If not the code moves to the inner loop which reads in the hlist and ... |
Class: ProtocolBuffers::Message
Inherits:
Object
Object
ProtocolBuffers::Message
Defined in:
lib/protocol_buffers/runtime/message.rb
Overview
Generated Code
This text describes exactly what Ruby code the protocol buffer compiler generates for any given protocol definition. You should read the language guide before read... |
Hizoka
Re : [glade2script-GTK2] Interface graphique pour script bash ou autre.
bah le principe en lui même je le pige.
mais c'est son application où j'ai du mal.
Il va falloir que je me penche bien sur tes exemples.
Hors ligne
frafa
Re : [glade2script-GTK2] Interface graphique pour script bash ou autre.
CouCou !
oulah ... |
How Shellcodes Work
by Peter Mikhalenko
05/18/2006
It's not an easy task to find a vulnerable service and find an exploit for it. It's also not easy to defend against users who might want to exploit your system, if you are a system administrator. However, writing an exploit by yourself, to convert a news line from bug ... |
hectorau_ben
Re : [tuto]Installation de Dofus 2.0 par paquet debian et rpm (pour la doc)
Même si tu m'as toujours pas répondu, dofus marche parfaitement, sans AUCUN ralentissement, mais le son ne marche pas ... Même si l'Updater est ouvert et que j'ai activé le son dans le options et biensûr, je n'ai pas trouvé la solu... |
AlexandreP
Re : Generateur de sources.list en Francais
Euh... en même temps, je suis pas totalement sûr que ce soit ça : si on regarde le message d'erreur, Ubuntu tente de rejoindre l'adresse IP 1.0.0.0. Je doute très très fortement que se soit la bonne adresse du serveur
Un connaisseur, siouplease ?
«La capacité d'app... |
malbo
[Tuto] Principes (quelques) de Ubuntu en mode UEFI
- Equivalence Bios-UEFI pour les amorceurs de Grub
L'amorceur de Grub dans le système Bios peut se trouver dans le MBR ou dans le secteur de Boot d'une partition. Son équivalent dans le système UEFI est un fichier qui porte l'extension .efi et qui se trouve (dans... |
First, a brief re-introduction. A few months back, I thought it would be a cool experiment to use crowdsourcing to optimize my choices in buying airplane tickets.
Unfortunately, though, I didn’t really finish what I started. This post is going to fix that.
To spice things up a little bit, I added over 3000 data points ... |
Class: ShopifyAPI::Asset
Inherits:
Object
ShopifyAPI::Asset
Includes:
Defined in:
lib/shopify_api/resources/asset.rb
Overview
Assets represent the files that comprise your theme. There are different buckets which hold different kinds of assets, each corresponding to one of the folders within a theme's zip file: "layout... |
I remember learning the rule for when to use cualquier, cualquiera, and cualesquiera, but was always confused about the exact differences. When should each be used, and what role do number, gender, and word placement play? Specifically, what should the translation be in the phrase "any of us," and why is that the prope... |
Ras'
Re : Topic des lève-tôt… Faisons manger leurs caleçons aux couche-tard! [4]
Hors ligne
ljere
Re : Topic des lève-tôt… Faisons manger leurs caleçons aux couche-tard! [4]
voici le code
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# auteur Gabriel Pettier
# license GPL V3 or later
# sert uniquement a compter le... |
br.follow_link takes either a Link object or a keyword arg (such as nr=0).
br.links() lists all the links.
br.links(url_regex='...') lists all the links whose urls matches the regex.
br.links(text_regex='...') lists all the links whose link text matches the regex.
br.follow_link(nr=num) follows the numth link on the pa... |
I am currently able to use the post method of jQuery to a view pointed by myurl
jQuery.post("/myurl", {'value1':value1, 'value2':value2,
'csrftoken': '{{ csrf_token }}'},
function(data) {
alert("Data Loaded: " + data);
});
Howeve... |
I don't think there is quite the need for the continued downvoting, I am just trying to learn here!
One.py
from two import *
ADooDah = Doodah()
something = Thing(ADooDah)
something.DoThis()
something.DoThat
something.DoAnother
if (something.has_done_stuff() == True)
self.SomeFunction
Two.py
class Thing(var):
d... |
Possible Duplicate:
how to extract domain name from URL
I want to extract the website from an URL, i.e. console.aws.amazon.com from the following URL.
>>> ts
'https://console.aws.amazon.com/ec2/home?region=us-east-1#s=Instances,EC2 Management Console,12/3/2012 4:34:57 PM,11,0,,25806'
>>> re.match(ts,'(")?http(s)?://(.*... |
Consider the following:
>>> import re
>>> a = "first:second"
>>> re.findall("[^:]*", a)
['first', '', 'second', '']
>>> re.sub("[^:]*", r"(\g<0>)", a)
'(first):(second)'
re.sub()'s behavior makes more sense initially, but I can also understand re.findall()'s behavior. After all, you can match an empty string between f... |
Topic: [FAQ] How to enable signing disclaimer on outgoing mails?
Note
Signing disclaimer on outgoing mails is available in iRedMail/iRedOS-0.5.0 and later, users upgrade from 0.4.0 or even older versions can add this feature manually with steps explained in our Upgrade Tutorial (0.4.0 -> 0.5.0).
iRedMail uses Amavisd-n... |
My main problem is that i have just acquired an ASUS laptop with WINDOWS 7 and I want to install Ubuntu on it.
I want to have a dual boot to choose between both Operating systems, I read that it's better to first install Windows and then Ubuntu, because Windows installer overwrites Ubuntu's boot loader.
So, i tried to ... |
mojomojo.org
/alfamart
Home node for Alfamart official partner merchandise FIFA piala dunia Brazil 2014
TERMS & CONDITION Alfamart official partner merchandise FIFA piala dunia Brazil 2014
Peraturan Lomba :
Lomba dimulai tanggal 16 Januari - 16 April 2014
Penutupan Pendaftaran tanggal 16 April 2014 Pukul 17:00 WIB
Peme... |
I need to remove empty new lines from text file in terminal.
Example file
123123123123123123
I've searched in google a bit but only solution found was sed '/^$/d' myFile > tt and it does not help. I still got these empty new lines.
You can use
Try:
Your command also seems to work:
The solution you posted will delete em... |
When you install TeX Live, there is a bunch of path settings that you can modify:
<D> directories:
TEXDIR (the main TeX directory):
/usr/local/texlive/2011
TEXMFLOCAL (directory for site-wide local files):
/usr/local/texlive/texmf-local
TEXMFSYSVAR (directory for variable and automatically generated data)... |
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... |
Question
How do I remove class attributes from html using python and lxml?
Example
I have:
<p class="DumbClass">Lorem ipsum dolor sit amet, consectetur adipisicing elit</p>
I want:
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit</p>
What I've tried so far
I've checked out lxml.html.clean.Cleaner however, i... |
The focus of my question pertains to getting control over the right hand side y-axis limits. The code:
if y2_lim != None:
par2.set_ylim(y2_lim)
Has no affect before or after the plot call. I am stumped. Any input help would be greatly appreciated, especially an explanation of why it doesn't work. This type of conu... |
I'm new to Python (v 2.6.5) and am trying to write an ArcMap (10) script that reads the vertex coordinates of a polygon shapefile which includes a small hole (doughnut polygon). I've been working from the ESRI Help page on reading geometries. The script I've developed outputs coordinate information until it hits coordi... |
What's the best approach to writing multi-threaded applications in Python, I'm aware of the basic concurrency mechanisms provided by the language and also of Stackless Python. What would you recommend and why?
Many good questions generate some degree of opinion based on expert experience, but answers to this question w... |
A simple use of De Moivre's formula, is sufficient to show that the cube root of a value, regardless of sign, is a multi-valued function. That means, for any input value, there will be three solutions. Most of the solutions presented to far only return the principle root. A solution that returns all valid roots, and ex... |
This video is great. One of the voice actors sounds a lot like Monarch henchman #24.
These four paragraphs have the same number of characters, but because the letter M is fat and the letter I is skinny, different amounts of characters appear in each line:
M M M M M M M M M M M M M M M M M M M M M M M M M M M M M M M M ... |
Multiple Dispatch not a terrible idea
tl;dr: We present a multiple dispatch system for Python. We discuss issuesthat arise from multiple dispatch. We try to allay fears related to theseissues.
Dispatch
Abstract operations like addition, +, have several different implementations.We choose which implementation to use bas... |
I am trying to pair my HTC myTouch 3G with a Bluetooth device that will stream data via SPP to the phone. I have looked at the Chat examples and found them lacking for what I need due to the fact of the high data rates I will need and the Chat example does block on the UI thread. But that said my main problem is when I... |
Overview Info
Domain Nameentekhab.ir
Favicon
Alexa Rank#2796
Google Page Rank
Ip Address94.182.146.40
Page Size156.9 KB
Images312 GIF, 62 JPG, 0 PNG
Heading
H1
H2
H3
H4
H5
H6
0 0 0 0 0 0
DNS Analysis
DNS servers
ns1.iransamaneh.com [94.182.146.2]
ns2.iransamaneh.com [94.182.130.2]
DNS Records
Answer records
entekhab.ir... |
Have a look at this example on how to connect events to callbacks in Gtk 3 and Python. In short, you use the connect() method to connect a signal name (which is emitted when an event such as a button click occurs) to a callback, which is the function that will handle your event.
def __init__(self):
# Other initiali... |
The traceback I'm getting makes me believe I have to reset all my repositories on my Ubuntu 12.04 installation. How do I do that?
Traceback (most recent call last):
File "/usr/bin/add-apt-repository", line 183, in <module>
if not sp.add_source_from_line(line):
File "/usr/lib/python2.7/dist-packages/softwareprop... |
blob: c727b41bf30840ad42751b19a5fa6b657dd930e9 (
plain
)
diff -up firstboot-1.113/firstboot/xfrontend.py.kwin firstboot-1.113/firstboot/xfrontend.py
--- firstboot-1.113/firstboot/xfrontend.py.kwin 2010-08-30 05:57:44.000000000 -0500
+++ firstboot-1.113/firstboot/xfrontend.py 2010-09-15 14:26:03.900021796 -0500
@@ -42,7... |
Is there an efficient way to know how many elements are in an iterator in Python, in general, without iterating through each and counting?
No. It's not possible.
Example:
import random
def gen(n):
for i in xrange(n):
if random.randint(0, 1) == 0:
yield i
iterator = gen(10)
Length of
This code s... |
__ ________
_____ _/ |_ _____ ____ ____ \_____ \______
\__ \\ __\/ \ / _ \ / \ _(__ <_ __ \
/ __ \| | | Y Y ( <_> ) | \/ \ | \/
(____ /__| |__|_| /\____/|___| /______ /__|
\/ \/ \/ \/... |
I've been forced by the TeX.sx chatroom mafia to post my lovely, buggy, terrible, traumatic, post-apocalyptic poor man's implementation of a replacement script. :)
Well, sadly this won't be a TeX answer. :) Here's my humble attempt, with a script language I'm terrible at.
(I'm looking at you, Python!)
import re
import ... |
A dict's keys are stored in a hashtable so that is their 'natural order', i.e. psuedo-random. Any other ordering is a concept of the consumer of the dict.
sorted() always returns a list, not a dict. If you pass it a dict.items() (which produces a list of tuples), it will return a list of tuples [(k1,v1), (k2,v2), ...] ... |
I know that it is not allowed to remove elements while iterating a list, but is it allowed to add elements to a python list while iterating. Here is an example:
for a in myarr:
if somecond(a):
myarr.append(newObj())
I have tried this in my code and it seems to works fine, however i dont know if its bec... |
I want to connect to a remote host, login, run a command and save the output in a variable. Following is the code I'm using.
import telnetlib
HOST = "172.19.35.69"
user = 'user'
password = 'pass'
tn = telnetlib.Telnet(HOST)
tn.read_until("User: ")
tn.write(user + "\n")
tn.read_until("Password:")
tn.write(password + "\n... |
I am sendng json data to another jsp page - for testing really.
You enter a JSON formatted string in a text field on my jsp from. I submit this through a form request, handled by jquery processing. It is sent to a receiver JSP. I am using the following code to do this.
Before I send it I get the data using:
jsonData = ... |
I've written a simple script to parse XML chat logs using the BeautifulSoup module. The standard soup.prettify() works ok except chat logs have a lot of fluff in them. You can see both the script code and some of the XML input file I'm working with below:
Code
import sys
from BeautifulSoup import BeautifulSoup as Soup
... |
I installed python3-numpy package, but trying to import it in Python3 interpreter I get this:
$ python3
Python 3.2.3 (default, May 3 2012, 15:54:42)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1... |
There are a number of ways of getting callbacks when Text or Entry widgets are changed in Tkinter, but I haven't found one for Listbox's (it doesn't help that much of the event documentation I can find is old or incomplete). Is there some way of generating an event for this?
def onselect(evt):
# Note here that Tkin... |
I installed the jenkins package on a mac using sudo easy_install python-jenkins. The installation went fine, no errors, but when I open python and type in import jenkins I get the following error.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.macosx-10.7-intel/egg/jenkins.... |
If I understand your question correctly, I think this is what you're after:
from scipy.optimize import minimize
import numpy as np
def f(coord,x,y,r):
return np.sum( ((coord[0] - x)**2) + ((coord[1] - y)**2) - (r**2) )
x = np.array([0, 2, 0])
y = np.array([0, 0, 2])
r = np.array([.88, 1, .75])
# initial (bad)... |
What is wrong here?
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.apples.co.uk
DocumentRoot /var/www/apples.co.uk
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.apples\.co\.uk$ [NC]
RewriteRule ^(.*)$ http://www.apples.co.uk/$1 [L,R=301]
</VirtualHost>
<VirtualHost *:80>
ServerName www.bananas.co.uk
Document... |
The Document is the Database
When you need to store and display a modest amount of structured or semistructured data, it's tempting to store it directly in an HTML file. I've used this strategy many times; undoubtedly you have too. The advantages and disadvantages of working directly with a presentation format are pret... |
There are many reasons why you may want to increase your Twitter followers: for engagement, status and for greater reach are a few that come to mind. I’m certainly in the latter - more reach == more potential hits to my blog.
If you’re in the status camp you’ll most likely have gone down the route of paying for followe... |
I'm trying to setup blackberry sync'ing with Evolution on a LTSP client. It works on the server.
I'm using Ubuntu 10.04 64bit on the server and here are the instructions I've followed to get the server working:
Install required syncing packages
$ sudo apt-get install libopensync0 multisync-tools libbarry0 opensync-plug... |
I am updating a Django model using tastypie API from a mobile client using JQuery.When I send the PUT request, I get the error that Column 'created' cannot be null.
The 'created' column is in my model to be updated which is of type
models.DateTimeField(auto_now_add=True).
When updating using tastypie API, the update c... |
Can someone please explain why the code below does not work when setting the facecolor of the figure?
import matplotlib.pyplot as plt
# create figure instance
fig1 = plt.figure(1)
fig1.set_figheight(11)
fig1.set_figwidth(8.5)
rect = fig1.patch
rect.set_facecolor('red') # works with plt.show().
... |
I want to extract the value of the "archivo" key of something like this:
...
<applet name="bla" code="Any.class" archive="Any.jar">
<param name="abc" value="space='1' archivo='bla.jpg'" </param>
<param name="def" value="space='2' archivo='bli.jpg'" </param>
<param name="jkl" value="space='3' archivo='blu.jpg'" </param>... |
There are a few topics on this, but none with a satisfactory answer.
I have a python application running in an IPython qt console
When I encounter an error, I'd like to be able to interact with the code at that point.
try:
raise Exception()
except Exception as e:
try: # use exception trick to pick up... |
I was looking for a parser library to convert a wikisource text into other formats. The wikisource text contains Holy Bible translation into Malayalam language known as "Sathyavedapusthakam".
I found Parsley very interesting after watching the PyCon talk by its author. Parsley doesn't support Python 3 yet. Then, I used... |
You can achieve it using Ajax and jQuery:
models.py:
type = models.CharField(verbose_name="Expression",max_length=32)
action = models.CharField(max_length=32, choices = (('', ''), ))
admin.py:
class MyModelAdmin(admin.ModelAdmin):
list_display = ('type', )
class Media:
js = ['/static/js/action_change... |
is there a builtin function of Python that does on python.array what argsort() does on a numpy.array?
I timed the suggestions above and here are my results.
First of all, the functions:
def f(seq):
# http://stackoverflow.com/questions/3382352/equivalent-of-numpy-argsort-in-basic-python/3383106#3383106
#non-lamb... |
I'm trying to use subprocess in a python script which I call within an oozie shell action. Subprocessis supposed to read a file which is stored in Hadoop's HDFS.
I'm using hadoop-1.2.1 in pseudo-distributed mode and oozie-3.3.2.
Here is the pythonscript, named connected_subprocess.py :
#!/usr/bin/python
import subproce... |
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... |
The other day, I stumbled across Mark Nelson's blog post describing a fairly simple NPR word puzzle: "Take the names of two U.S. States, mix them all together, then rearrange the letters to form the names of two other U.S. States. What states are these?"
Mark Nelson is a programmer, so his first instinct of course was ... |
今天编译的时候出错了,百度了一下只有这一个结果
自己留着,以后用得着
How to embed Lua 5.1 in C++
Lua, is a scripting language providing dynamic data structures, maths, io and string manipulations just like any interprete language such as Bash, Python, Ruby etc.
What is so special about Lua?
Lua is Fast, Light-weight and Embeddable.
Lua can be embedded ... |
I'm beginning with biopython and I have a question about parsing results. I used a tutorial to get involved in this and here is the code that I used:
from Bio.Blast import NCBIXML
for record in NCBIXML.parse(open("/Users/jcastrof/blast/pruebarpsb.xml")):
if record.alignments:
print "Query: %s..." % record.q... |
I'm wondering about the best way to get a stacktrace when there is an exception inside a function executed via the multiprocessing module. Here's an example:
import multiprocessing
def square(x):
raise Exception("Crash.")
return x**2
if __name__ == '__main__':
pool = multiprocessing.Pool(processes=4)
re... |
(Updated version: Incorporates fixes from reader comments)
A colleague asked me to look into a problem with him, mentioning that “Tlib hangs when we run it”. Tlib is a fairly large project that is written in Python. His initial analysis showed that it hangs at a very early phase, during with it tries to fetch the lates... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.