Skip to content

Instantly share code, notes, and snippets.

View fmartingr's full-sized avatar

Felipe Martin fmartingr

View GitHub Profile
### Keybase proof
I hereby claim:
* I am fmartingr on github.
* I am fmartingr (https://keybase.io/fmartingr) on keybase.
* I have a public key whose fingerprint is CDCC 52FA FE1A 5CC4 6809 E76E 7975 4701 665A 55CB
To claim this, I am signing this object:
#!/usr/bin/python
import smtplib
gmail_user = "your_email@gmail.com"
gmail_pwd = "your_password"
msg['From'] = gmail_user
msg['To'] = to
@fmartingr
fmartingr / codebase_clone.py
Created August 20, 2014 10:22
python script to clone all codebase repositories using codebase-api and fabric into a codebase exported data folder
# pip install codebase-api fabric
from codebase import CodebaseClient
from fabric.operations import local
CLIENT_ID = 'foo/bar'
CLIENT_KEY = 'key'
client = CodebaseClient(CLIENT_ID, CLIENT_KEY)
@fmartingr
fmartingr / initial_data.json
Last active October 6, 2015 05:37
django initial fixture file with admin user: admin/1234
[
{
"model": "auth.user",
"pk": 1,
"fields": {
"first_name": "John",
"last_name": "Doe",
"username": "admin",
"email": "email@mydevsite.com",
"password": "pbkdf2_sha256$10000$VVJjeNI4DX0Z$dI0w6zSkvvFO+B7s9+rxVS0sj6N2Tp/xVny3FokWQis=",
def pid_exists(pid):
"""Check whether pid exists in the current process table."""
if pid < 0:
return False
try:
os.kill(pid, 0)
except OSError, e:
return e.errno == errno.EPERM
else:
return True
@fmartingr
fmartingr / Rakefile
Created December 5, 2012 15:55 — forked from jarrettmeyer/Rakefile
Octopress publish drafts
require "rubygems"
require "date"
# Configuration
base_dir = Dir.pwd
blog_dir = "#{base_dir}/blog"
source_dir = "#{blog_dir}/source"
posts_dir = "#{source_dir}/_posts"
git_remote = "origin"
git_branch = "master"
@fmartingr
fmartingr / hash.php
Created January 14, 2013 16:08
Encryption types comparision in PHP
<?
$data = "Hash cheching!";
echo '<pre>';
printf("%-12s %6s %11s %s\n", "Hash name", "Lenght", "Time", "Hash");
foreach (hash_algos() as $hash_type) {
$start = microtime(true);
$hash = hash($hash_type, $data, false);
$end = microtime(true);
$elapsed = number_format($end - $start, 6);
printf("%-12s %6d %10fs %s\n", $hash_type, strlen($hash), $elapsed, $hash);
@fmartingr
fmartingr / dataset-models.py
Last active December 18, 2015 02:58
Little model objects using the dataset framework: https://dataset.readthedocs.org/en/latest/index.html
# Imports
import dataset
###
# CONFIG
###
DATABASE_URL = 'sqlite:///' # In memory database
###
# Orignal version taken from http://www.djangosnippets.org/snippets/186/
# Original author: udfalkso
# Modified by: Shwagroo Team and Gun.io
import sys
import os
import re
import hotshot, hotshot.stats
import tempfile
import StringIO
@fmartingr
fmartingr / form.coffee
Created August 21, 2013 14:03
Class to manage dynamic forms with coffeescript
class Form
###
Class to manage dynamic forms with javascript
> var form = Form('/destiny/path/', {'username':'fmartingr'})
> form.addField('password', 'aw8cnwn8t7x9my898wyf9mw67n')
> form.submit()
###
constructor: (action, params={}, method='post') ->