Skip to content

Instantly share code, notes, and snippets.

View DamnWidget's full-sized avatar

Oscar Campos DamnWidget

View GitHub Profile
@DamnWidget
DamnWidget / gist:4286617
Created December 14, 2012 16:18
old and unrefactored code
def get_bet_adjustments(cursor, position_id, is_each_way,
is_starting_price, bet_stake, bet_price):
"""
Calculates the overall effect of this bet on to exposures & stakes
"""
## Explicitly convert inbound web service arguments to Decimals
bet_stake = Decimal(str(bet_stake))
bet_price = Decimal(str(bet_price))
adjustments = dict()
@DamnWidget
DamnWidget / gist:4190953
Created December 2, 2012 20:36
Using SublimeREPL to run Twisted trial for TDD using regular Sublime Shortcuts
// Using SublimeREPL to use Twisted Trial in the project. Note that the
// main testing entry point should be called as the project itself
{
"keys": [ "alt+r", "alt+t"],
"command": "repl_open",
"args":
{
"type": "subprocess",
"encoding": "utf8",
"cmd": ["trial", "$project_base_name"],
@DamnWidget
DamnWidget / DamnWidget.colorscheme
Created November 20, 2012 10:52
Konsole mate-terminal color scheme like
[Background]
Color=0,0,0
[BackgroundIntense]
Color=85,87,83
[Color0]
Color=0,0,0
[Color0Intense]
@DamnWidget
DamnWidget / galmazor.py
Created August 2, 2012 16:03
@ggalmazor SHELL Script to Python
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
from __future__ import with_statement
import subprocess
import json
import sys
import os
Apple80211 = '/System/Library/PrivateFrameworks/Apple80211.framework'
airpath = '{0}/Versions/A/Resources/airport'.format(Apple80211)
@DamnWidget
DamnWidget / ExampleThread.py
Created June 13, 2012 20:36
Ejemplo general de control de threads por eventos en Python
class ThreadHandler(object):
"""
Threads Handler
"""
def __init__(self):
self.check_threads()
def check_port_threads(self):
"""Do some login for the application"""
#include <stdio.h>
#define SET_BIT(var, bit) ((var) |= (bit))
#define BV (1 << 24)
void check_bits(int flags)
{
if (flags & BV)
printf("Ok\n");
@DamnWidget
DamnWidget / code.asm
Created August 21, 2011 15:50
Ensamblador
function check_bits:
0x00000000004005a0 <+0>: and $0x1000000,%edi
0x00000000004005a6 <+6>: jne 0x4005b0 <check_bits+16>
0x00000000004005a8 <+8>: repz retq
0x00000000004005aa <+10>: nopw 0x0(%rax,%rax,1)
0x00000000004005b0 <+16>: mov $0x4006dc,%esi
0x00000000004005b5 <+21>: mov $0x1,%edi
0x00000000004005ba <+26>: xor %eax,%eax
0x00000000004005bc <+28>: jmpq 0x400458 <__printf_chk@plt>
@DamnWidget
DamnWidget / configure.patch
Created August 4, 2011 13:00
Parche para Zlib
--- configure.orig 2011-08-04 14:14:22.680047501 +0200
+++ configure 2011-08-04 14:14:57.000047642 +0200
@@ -105,8 +105,8 @@
if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then
CC="$cc"
- SFLAGS="${CFLAGS--O3} -fPIC"
- CFLAGS="${CFLAGS--O3}"
+ SFLAGS="${CFLAGS--O3} -fPIC -m32"
+ CFLAGS="${CFLAGS--O3} -m32"
@DamnWidget
DamnWidget / intro_css3_media.html
Created July 3, 2011 18:56
Introducción a media queries Genbeta Dev
<!DOCTYPE html>
<html lang="es">
<head>
<meta http-equiv="Content-Type" content="text/html" charset="UTF-8">
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<title>El Señor de los Poyaques</title>
<link rel="stylesheet" media="all" href="/css/default.css">
<link rel="stylesheet" media="print" href="/css/print.css">
<link rel="stylesheet" media="screen and (max-device-width: 480px) and (min-device-width: 320px;)" href="iphone.css">
</head>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />