Posts

Showing posts from 2012

Sql statement for a query with the Django ORM?

from django.db import connection sql_statement = connection.queries.pop() print sql_statement['sql']

Forestello dejó de ser el Técnico de Atlético de Rafaela!

Image
Gracias por todo Yagui!

Dump sql file from sqlite3 db

[carpincho@bender]$ sqlite3 database.db3 .dump | grep '^INSERT INTO "tablename"' source

Horizontal Line in Latex

\begin{center}     \line(x-slope,y-slope){length} \end{center} For example: \line(1,0){250}

Matplotlibs colors

Here is a list of some weirds colors you can use to change the always classic colors. For example:     ax.scatter(band1, band2, s=size_point, color='tomato') cnames = { 'aliceblue' : '#F0F8FF' , 'antiquewhite' : '#FAEBD7' , 'aqua' : '#00FFFF' , 'aquamarine' : '#7FFFD4' , 'azure' : '#F0FFFF' , 'beige' : '#F5F5DC' , 'bisque' : '#FFE4C4' , 'black' : '#000000' , 'blanchedalmond' : '#FFEBCD' , 'blue' : '#0000FF' , 'blueviolet' : '#8A2BE2' , 'brown' : '#A52A2A' , 'burlywood' : '#DEB887' , 'cadetblue' : '#5F9

Installing matplotlib under Mountain Lion

Follow this steps in order: [carpincho@MacBook-2]$ pip install numpy [carpincho@MacBook-2]$ pip install -e git+https://github.com/scipy/scipy#egg=scipy-dev [carpincho@MacBook-2]$ pip install git+https://github.com/matplotlib/matplotlib.git#egg=matplotlib-dev source and a link to an explanation why numpy and matplotlib can't be installed using pip straightforward

Guía para hacer café para todos los gustos

Image
La verdad es que no se quien es el autor, pero todos los derechos a su autor.

La Mega 90.5 - La radio de Rock

Image
Url para escuchar la Mega Rock online usando Vlc o mplayer url: mmsh://70.38.79.19:80/larocka975?MSWMExt=.asf

APN para Movistar Argentina

Por si a alguien le sirve Para Datos: APN: wap.gprs.unifon.com.ar User: wap Pass: wap Para Internet: APN: internet.gprs.unifon.com.ar User: internet Pass: internet Hoy (29/3/12) funcionan

git: Syncing local and remote (with deleted) branches git

Sometimes, you delete a branch and if you run git branch -a it still listed under /remote. One way to sync your local branches is to execute the following: git fetch -p After fetching, will remove any remote-tracking branches which no longer exist on the remote. from man git-fetch

git: diff files in different branches

git difftool somebranch:UNREADME otherbranch:README from stackoverflow

git: delete local and remote branch

Delete local branch "serverfix": git branch -d serverfix Delete remote branch "serverfix": git push origin :serverfix progit.org

Kivy, an open source library for rapid app develop

Image
Kivy is an open source software library for rapid development of applications equipped with novel user interfaces, such as multi-touch apps. Cross Platform: Runs on Linux, Windows, MacOSX, Android and IOS. It can use natively most inputs protocols and devices like WM_Touch, WM_Pen, Mac OS X Trackpad and Magic Mouse, Mtdev, Linux Kernel HID, TUIO. A multi-touch mouse simulator is included. Business Friendly: It is 100% free to use, under LGPL 3 licence. The framework is stable and has a documented API, plus a programming guide to help for in the first step Gpu Accelerated: The graphics engine is built over OpenGL ES 2. The toolkit is coming with more than 20 widgets designed to be extensible. Many parts are written in C using Cython, tested with regression tests. Homepage: Kivy.org   Images and info from kivy official site

Script to open Ninja ide from Terminal and minimize the calling Terminal

Create a file with sh extension with the following code #!/bin/sh /usr/bin/osascript -e 'tell application "System Events" to click (first button of (first window of (application process "Terminal")) whose role description is "minimize button")' python /Users/carpincho/Dev/ninja-ide/ninja-ide.py Just edit the apps names with the ones you like.

Swig compiling issues Mac Os Lion

One problem that happened to me, was the fact that working under a virtualenv with an specific python version as one can expect, works with ONLY that python version. So if you try to import a module compiled with one version different with the one you are running, will no work. The exception message: Fatal Python error: Interpreter not initialized (version mismatch?) Abort trap: 6 How we can solve this issue? First, knowing which python version are we running and of course, compile the module to THAT version. Below are some examples of how to compile a module to 2.6 or 2.7 (which is Mac Os Lion python default version) To use python default version just type the following: $ swig -python example.i $ cc -c `python-config --cflags` example.c example_wrap.c $ cc -bundle `python-config --ldflags` example.o example_wrap.o -o _example.so If you run: $ python-config --ldflags the output is: -L/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config -ldl -framework

Swig Tutorial example Mac Os Lion

This tutorial is based on Leopard Tutorial but still works, thou some warnings. First, we create an example.c file with this content: /* File : example.c */ #include <time.h> double My_variable = 10.0; int fact(int n) { if (n <= 1) return 1; else return n*fact(n-1); } int my_mod(int x, int y) { return (x%y); } char *get_time() { time_t ltime; time(&ltime); return ctime(&ltime); } Second, we create the interface between C and Python with the following file: /* example.i */ %module example %{ /* Put header files here or function declarations like below */ extern double My_variable; extern int fact(int n); extern int my_mod(int x, int y); extern char *get_time(); %} extern double My_variable; extern int fact(int n); extern int my_mod(int x, int y); extern char *get_time(); Now that we have all the source files we need, we compile them in this way: $ swig -python example.i $ cc -c `python-config --cflags` example.c example_

timeit example

An example of how to time a statement >>> import numpy as np >>> arr1 = np.random.randint(0,1600,(3000,3000)) >>> timeit arr1.argmin() 10 loops, best of 3: 34.2 ms per loop Tested under Mac Lion Os proc i7 and Python 2.7.1 r271:86832

What's the iPad resolution?

iPad has a 1024 by 768 resolution. Just that.

Escaping Charecters in python

Just an example commonly used Escaping the "\" with another "\" >>> with open('C:\\Folder1\\Folder2\\file') as file_handler: Or just add an "r" before the path (this stands for "raw"). >>> with open(r'C:\Folder1\Folder2\file') as file_handler:

Using wget to download a page and browse it locally

Run:  [carpincho@bender]$ wget -r --convert-links url What the arguments do: -r (its the same using --recursive)   Turn on recursive retrieving.   The default maximum depth is 5. -k (its the same using --convert-links) After the download is complete, convert the links in the document to make them suitable for local viewing. This affects not only the visible hyperlinks, but any part of the document that links to external content, such as embedded images, links to style sheets, hyperlinks to non-HTML content, etc. url (obvious :P) Note: You can run it under any Unix based Os or under Mac Os previouly installing it with macports

Miscellaneous Symbols

Character (decimal) Decimal Character (hex) Hex Entity Name ☀ 9728 ☀ 2600   BLACK SUN WITH RAYS ☁ 9729 ☁ 2601   CLOUD ☂ 9730 ☂ 2602   UMBRELLA ☃ 9731 ☃ 2603   SNOWMAN ☄ 9732 ☄ 2604   COMET ★ 9733 ★ 2605   BLACK STAR ☆ 9734 ☆ 2606   WHITE STAR ☇ 9735 ☇ 2607   LIGHTNING ☈ 9736 ☈ 2608   THUNDERSTORM ☉ 9737 ☉ 2609   SUN ☊ 9738 ☊ 260A   ASCENDING NODE ☋ 9739 ☋ 260B   DESCENDING NODE ☌ 9740 ☌ 260C   CONJUNCTION ☍ 9741 ☍ 260D   OPPOSITION ☎ 9742 ☎ 260E   BLACK TELEPHONE ☏ 9743 ☏ 260F   WHITE TELEPHONE ☐ 9744 ☐ 2610   BALLOT BOX ☑ 9745 ☑ 2611   BALLOT BOX WITH CHECK ☒ 9746 ☒ 2612   BALLOT BOX WITH X ☓ 9747 ☓ 2613   SALTIRE ☔ 9748 ☔ 2614   UMBRELLA WITH RAIN DROPS ☕ 9749 ☕ 2615   HOT BEVERAGE ☖ 9750 ☖ 2616   WHITE SHOGI PIECE ☗ 9751 ☗ 2617   BLACK SHOGI PIECE ☘ 9752 ☘ 2618   SHAMROCK ☙ 9753 ☙ 2619   REVERSED ROTATED FLORAL HEART BULLET ☚ 9754 ☚ 261A   BLACK LEFT POINTING INDEX ☛ 9755 ☛ 261B   BLACK RIGHT POINTING INDEX ☜ 9756 ☜ 261C   WHITE LEFT POINTING INDEX