Skip to content

Instantly share code, notes, and snippets.

View WTF!
int LibBLABLABLA_HayPeticionApagado( void )
{
int Respuesta;
if( VGTPeticionApagado == true )
{
Respuesta = true;
}
else
{
View writeString
public void writeString(BinaryWriter w, string s)
{
byte[] utf8Bytes = System.Text.Encoding.UTF8.GetBytes(s);
w.Write((UInt32) utf8Bytes.Length);
if(utf8Bytes.Length > 0)
w.Write(utf8Bytes);
}
View python-daemon example
#!/usr/bin/python
# -*- encoding: utf-8 -*-
#
# author: javi santana
import os
import logging
from daemon.runner import DaemonRunner
import myapp
View problem_django.py
### models.py
class UserKarma(models.Model):
DEFAULT_KARMA = 10.0
user = models.OneToOneField(User, primary_key=True, related_name='karma')
value = models.FloatField(default=DEFAULT_KARMA)
def change(self, qty, reason='no reason'):
v = self.value + qty
View fetch_test.py
#!/usr/bin/python
# coding: utf-8
import urllib
import urllib2
from multiprocessing import Pool
import Queue, threading
reg_nos = [16738, 17288, 18162, 18776, 18868, 19116, 19223, 19505];
pdf_url = 'http://www.mapa.es/agricultura/pags/fitos/registro/sustancias/pdf/%s.pdf'
View fetch_test_basic.py
#!/usr/bin/python
# coding: utf-8
import urllib
import urllib2
reg_nos = [16738, 17288, 18162, 18776, 18868, 19116, 19223, 19505];
pdf_url = 'http://www.mapa.es/agricultura/pags/fitos/registro/sustancias/pdf/%s.pdf'
def fetch_url(url):
@javisantana
javisantana / denuncia.py
Created Feb 7, 2011
ayuda a tus funcionarios a hacer más eficiente su trabajo!
View denuncia.py
#!/usr/bin/python
# -*- encoding: utf-8 -*-
#
# author: javi santana
import urllib2
from BeautifulSoup import BeautifulStoneSoup, BeautifulSoup
View gps.java
package hardware;
import java.util.ArrayList;
import android.app.Activity;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.location.LocationProvider;
View wsgi_simple.py
def application(environ, start_response):
status = '200 OK'
response_headers = [('Content-type', 'text/plain')]
start_response(status, response_headers)
return ['rambo']
@javisantana
javisantana / gol.html
Created May 8, 2011
game of life in javascript < 512b
View gol.html
<body bgcolor=0><canvas id=R width=64 height=64 style=width:2in;height:2in;background:#fff><script>K=R.getContext('2d');c=q2=(q=256)*q;t=[];t2=[];while(c--)t2[c]=t[c]=Math.random()<.1?1:0;ar=[[0,1],[-1,1],[-1,0],[-1,-1],[0,-1],[1,-1],[1,0],[1, 1]];setInterval("for(s=0,I=K.getImageData(0,0,q,q),c=q2;c--;tt=t2,t2=t,t=tt){for(s=0,a=8;a--;s+=(u=t[c+(x=ar[a])[0]+q*x[1]])==undefined?0:u);I.data[(p=4*c)+1]=q*(t2[c]=((t[c]&&(s>1&&s<4))||s==3)?1:0); I.data[p+3]=q;K.putImageData(I,0,0);}",q);</script></body>