Skip to content

Instantly share code, notes, and snippets.

View avances123's full-sized avatar
🏠
Working from home

Fabio Rueda avances123

🏠
Working from home
View GitHub Profile
@avances123
avances123 / arraysum.py
Created April 16, 2014 18:15
Measure times in queries using plotly
import subprocess
import re
import math
import plotly
import os
import numpy as np
funcs = ['array_sum_sql','array_sum_py2','array_sum_py3','array_sum_js']
mydb = 'arraysum'
#!/usr/bin/env python2
# Quick and dirty demonstration of CVE-2014-0160 by Jared Stafford ([email protected])
# The author disclaims copyright to this source code.
import sys
import struct
import socket
import time
import select
@avances123
avances123 / dictinfo.py
Last active August 29, 2015 13:57
Script para probar los distintas funciones de hash en python
"""Routines that examine the internals of a CPython dictionary."""
from ctypes import Structure, c_ulong, POINTER, cast, py_object
from math import log
UMAX = 2 ** 32
def cbin(n):
"""Return `n` as a clean 32-bit binary number, without a leading '0b'."""
if n < 0:
<user-avatar id="my-ids" class="my-classes" user="userObject"></user-avatar>
fabio@fa-big:~/src/viajr (master) $ rackup ./faye/faye.ru -s thin -E production -D
/home/fabio/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- /home/fabio/src/config/initializers/faye_token.rb (LoadError)
from /home/fabio/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /home/fabio/src/viajr/faye/faye.ru:2:in `block in <main>'
from /home/fabio/.rvm/gems/ruby-1.9.3-p327@viajr/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
from /home/fabio/.rvm/gems/ruby-1.9.3-p327@viajr/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
from /home/fabio/src/viajr/faye/faye.ru:in `new'
from /home/fabio/src/viajr/faye/faye.ru:in `<main>'
from /home/fabio/.rvm/gems/ruby-1.9.3-p327@viajr/gems/rack-1.5.2/lib/rack/builder.rb:49:in `eval'
from /home/fabio/.rvm/gems/ruby-1.9.3-p327@viajr/gems/rack-1.5.2/lib/rack/builder.rb:49:in `new_from_string'
# On a Mac, use this script to generate secure deployment key
# To generate secure SSH deploy key for a github repo to be used from Travis
base64 --break=0 ~/.ssh/id_rsa_deploy > ~/.ssh/id_rsa_deploy_base64
ENCRYPTION_FILTER="echo \$(echo \"- secure: \")\$(travis encrypt \"\$FILE='\`cat $FILE\`'\" -r floydpink/harimenon.com)"
# If you don't have homebrew please install it from http://brew.sh/
brew install coreutils
gsplit --bytes=100 --numeric-suffixes --suffix-length=2 --filter="$ENCRYPTION_FILTER" ~/.ssh/id_rsa_deploy_base64 id_rsa_
# To reconstitute the private SSH key from within the Travis-CI build (typically from 'before_script')
class SwapViewSet(viewsets.ModelViewSet):
"""
Api REST de SwapSerializer
"""
queryset = Swap.objects.all()
serializer_class = SwapSerializer
permission_classes = (IsOwnerOrReadOnly,)
filter_fields = ('user1','user2') # Para ver los swaps de un usuario
@avances123
avances123 / gist.txt
Created February 3, 2014 15:09
python-gist gist
def pre_save(self, obje, created=False):
self.extradata = {}
obj = Swap.objects.get(id=obje.id)
items1_new = sorted(self.request.DATA['items1']) # Items enviados por el usuario
items1_old = sorted([x.id for x in obj.items1.all()]) # Items que hay en la db
added1 = list(set(items1_new) - set(items1_old))
if added1:
self.extradata['added1'] = added1
removed1 = list(set(items1_old) - set(items1_new))
if removed1:
@avances123
avances123 / gist.txt
Created February 3, 2014 09:53
python-gist gist
Feb 3 10:26:31 fabio-rueda rsyslogd: [origin software="rsyslogd" swVersion="5.8.6" x-pid="676" x-info="http://www.rsyslog.com"] rsyslogd was HUPed
Feb 3 10:26:31 fabio-rueda rsyslogd: [origin software="rsyslogd" swVersion="5.8.6" x-pid="676" x-info="http://www.rsyslog.com"] rsyslogd was HUPed
Feb 3 10:29:27 fabio-rueda anacron[1068]: Job `cron.daily' terminated
Feb 3 10:29:27 fabio-rueda anacron[1068]: Normal exit (1 job run)
Feb 3 10:34:52 fabio-rueda kernel: [ 1569.765154] type=1400 audit(1391420092.572:27): apparmor="DENIED" operation="capable" parent=1 profile="/usr/sbin/cupsd" pid=974 comm="cupsd" pid=974 comm="cupsd" capability=36 capname="block_suspend"
Feb 3 10:40:01 fabio-rueda CRON[3481]: (fabio) CMD (/bin/bash /home/fabio/src/dotfiles/bin/wallpaper.sh)
Feb 3 10:47:52 fabio-rueda kernel: [ 2348.402963] type=1400 audit(1391420872.976:28): apparmor="DENIED" operation="capable" parent=1 profile="/usr/sbin/cupsd" pid=974 comm="cupsd" pid=974 comm="cupsd" capability=36 capname="block_suspend"
{
"date" : { "$date" : 1385403640000 },
"name" : "Alice",
"value" : 13
},
{
"date" : { "$date" : 1385403640000 },
"name" : "Bob",
"value" : 7
},