Skip to content

Instantly share code, notes, and snippets.

Matías Herranz matiasherranz

Block or report user

Report or block matiasherranz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
lttlrck / gist:9628955
Created Mar 18, 2014
rename git branch locally and remotely
View gist:9628955
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
kerimdzhanov / random.js
Last active Nov 14, 2019
JavaScript: get a random number from a specific range
View random.js
* Get a random floating point number between `min` and `max`.
* @param {number} min - min number
* @param {number} max - max number
* @return {number} a random floating point number
function getRandomFloat(min, max) {
return Math.random() * (max - min) + min;
caniszczyk /
Created Oct 9, 2012
Clone all repos from a GitHub organization
curl -s | ruby -rubygems -e 'require "json"; JSON.load( { |repo| %x[git clone #{repo["ssh_url"]} ]}'
matiasherranz /
Created May 12, 2012
Date handling util functions
Some date handling util functions I coded for Python/Django.
import calendar
from datetime import datetime
from decimal import Decimal
from django.utils.datastructures import SortedDict
igniteflow /
Created Feb 20, 2012
A very simple implementation of a Redis producer-consumer messaging queue in Python
import redis
import time
import sys
def producer():
r = redis.Redis()
i = 0
while True:
r.rpush('queue', 'Message %d' % i)
bkimble / gist:1365005
Last active Oct 16, 2019
List local memcached keys using Ruby
View gist:1365005
#!/usr/bin/env ruby
# List all keys stored in memcache.
# Credit to Graham King at for the original article on how to get the data from memcache in the first place.
require 'net/telnet'
headings = %w(id expires bytes cache_key)
rows = []
jacobian /
Created Feb 15, 2011
An example of using many-to-many "through" to augment m2m relationships. See for context.
from django.db import models
class Person(models.Model):
name = models.CharField(max_length=200)
groups = models.ManyToManyField('Group', through='GroupMember', related_name='people')
class Meta:
ordering = ['name']
def __unicode__(self):
You can’t perform that action at this time.