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
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
kerimdzhanov / random.js
Last active Sep 17, 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
caniszczyk / clone-all-twitter-github-repos.sh
Created Oct 9, 2012
Clone all repos from a GitHub organization
View clone-all-twitter-github-repos.sh
curl -s https://api.github.com/orgs/twitter/repos?per_page=200 | ruby -rubygems -e 'require "json"; JSON.load(STDIN.read).each { |repo| %x[git clone #{repo["ssh_url"]} ]}'
@matiasherranz
matiasherranz / date_periods_handler.py
Created May 12, 2012
Date handling util functions
View date_periods_handler.py
"""
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
igniteflow / redis-producer-consumer.py
Created Feb 20, 2012
A very simple implementation of a Redis producer-consumer messaging queue in Python
View redis-producer-consumer.py
import redis
import time
import sys
def producer():
r = redis.Redis()
i = 0
while True:
r.rpush('queue', 'Message %d' % i)
@bkimble
bkimble / gist:1365005
Last active Sep 6, 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 http://www.darkcoding.net/software/memcached-list-all-keys/ 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
jacobian / models.py
Created Feb 15, 2011
An example of using many-to-many "through" to augment m2m relationships. See http://www.quora.com/How-do-you-query-with-a-condition-on-a-ManyToMany-model-in-Django for context.
View models.py
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.