Skip to content

Instantly share code, notes, and snippets.

View gerhc's full-sized avatar

German Hoffman gerhc

  • Tryolabs
  • Montevideo
View GitHub Profile
@gerhc
gerhc / repo_bundler.py
Last active May 15, 2019 20:37
script to clone, bundle and backup git repositories
import sh
organization = "gerhc"
repos = []
DESTINATION_FOLDER = "./repo_bundles"
for repo in repos:
print(f"Bundling {repo}")
sh.git("clone", f"git@github.com:{organization}/{repo}.git")
@gerhc
gerhc / rn171connect.py
Created December 16, 2015 14:59
a piece of code found at https://www.microchip.com/forums/m758342.aspx that shows how to connect to an AP using python and RN171
import serial
import os
import sys
import time
chunk_size = 5000
os.chdir("D:\govind\Python\RN-wifly")
print "Starting WiFly Comm"
# To change baudrate -> set uart baudrate 115200, then save <CR>, then reboot
@gerhc
gerhc / description.py
Last active December 2, 2015 15:20
fetch and clean descriptions
import hashlib
import justext
import re
import redis
import requests
from queue import Queue as ThreadQueue
from threading import Thread
from multiprocessing import Process, Queue
### Keybase proof
I hereby claim:
* I am gerhc on github.
* I am gerhc (https://keybase.io/gerhc) on keybase.
* I have a public key whose fingerprint is D6D3 BEFB 0A4B 2796 E071 327C D9D0 D829 D1C6 9953
To claim this, I am signing this object:
// add the filter to your application module
angular.module('yourAppName', ['filters']);
/**
* Truncate Filter
* @Param string
* @Param int, default = 10
* @Param string, default = "..."
* @return string
*/
@gerhc
gerhc / pip install behind firewall
Created November 11, 2012 15:40
Give a base url for pip install (in case you're behind some nasty firewall)
pip install django-social-auth -i https://pypi.python.org/simple/
@gerhc
gerhc / b64field.py
Created October 15, 2012 12:28 — forked from klipstein/b64field.py
Base64 file handling for django-tastypie
import base64
import os
from tastypie.fields import FileField
from django.core.files.uploadedfile import SimpleUploadedFile
class Base64FileField(FileField):
"""
A django-tastypie field for handling file-uploads through raw post data.
It uses base64 for en-/decoding the contents of the file.
Usage:
@gerhc
gerhc / Django UUID field
Created August 14, 2012 13:21
Django UUID field
from django.db import models
import uuid
class UUIDField(models.CharField) :
def __init__(self, *args, **kwargs):
kwargs['max_length'] = kwargs.get('max_length', 64 )
kwargs['blank'] = True
models.CharField.__init__(self, *args, **kwargs)
@gerhc
gerhc / django POST
Created August 9, 2012 13:46
AJAX POST
xhr = new XMLHttpRequest();
xhr.open("POST", "add_specs/", false);
xhr.setRequestHeader("Cache-Control", "no-cache");
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken'));
data = JSON.stringify(spec_rows);
xhr.send(data);
#!/bin/sh
/home/omab/x.py &
LASTPID=$!
sleep 1m
kill $LASTPID