Skip to content

Instantly share code, notes, and snippets.

int LibBLABLABLA_HayPeticionApagado( void )
{
int Respuesta;
if( VGTPeticionApagado == true )
{
Respuesta = true;
}
else
{
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);
}
#!/usr/bin/python
# -*- encoding: utf-8 -*-
#
# author: javi santana
import os
import logging
from daemon.runner import DaemonRunner
import myapp
@javisantana
javisantana / problem_django.py
Created May 11, 2010 18:42
django_problem.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
#!/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'
#!/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 February 7, 2011 16:03
ayuda a tus funcionarios a hacer más eficiente su trabajo!
#!/usr/bin/python
# -*- encoding: utf-8 -*-
#
# author: javi santana
import urllib2
from BeautifulSoup import BeautifulStoneSoup, BeautifulSoup
@javisantana
javisantana / gps.java
Created March 20, 2011 18:39
real/fake gps
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;
@javisantana
javisantana / wsgi_simple.py
Created April 23, 2011 08:42
simple wsgi
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 11:21
game of life in javascript < 512b
<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>