Skip to content

Instantly share code, notes, and snippets.

View tutuca's full-sized avatar

Matías Iturburu tutuca

View GitHub Profile
@rafen
rafen / test_views.py
Last active April 11, 2022 18:59
GitHub webhook django view + tests
from unittest.mock import patch
from django.urls import reverse
from django.tests import TestCase
class TestGitHubWebhookView(TestCase):
@patch('my_app.views.GitHubWebhookView.ping')
def test_view_ping_event(self, mock_ping):
#!/usr/bin/env python2.7
from __future__ import print_function
import commands
import os
import stat
from gitlab import Gitlab
def get_clone_commands(token, repo_root):
con = Gitlab("http://gitlab.your.domain", token)
@fisadev
fisadev / work
Created December 3, 2015 14:57
A python script to launch my tmux things at once
#!/usr/bin/env python
# coding: utf-8
from os import system
PROJECT_PATH = 'path_to_your_project'
ACTIVATE_VENV = '. path_to_your_virtualenv/bin/activate'
def tmux(command):
@mackbrowne
mackbrowne / gist:e119c025ebfc517950f5
Created June 27, 2014 15:50
Split json into multiple files using jq
cat data.json | jq -c -M '.data[]' | \
while read line; do echo $line > parts/$(date +%s%N).json; done
@vlasovskikh
vlasovskikh / tweetread.py
Created June 1, 2014 23:26
Actor-based CLI Twitter client example for using asyncio
# Copyright (c) 2014 Andrey Vlasovskikh
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
@jneight
jneight / fields.py
Last active December 18, 2015 01:29
Avoid doing extra database queries when resource uri of related field is built using models PK.
# coding=utf-8
from tastypie.bundle import Bundle
from tastypie import fields
from tastypie.exceptions import ApiFieldError
class OptimizedToOneField(fields.ToOneField):
def dehydrate(self, bundle, **kwargs):
"""
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active November 15, 2024 09:51
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@codeforkjeff
codeforkjeff / solarize.sh
Created November 27, 2011 06:43
shell script for setting gnome-terminal color palette to use Solarized theme
#!/bin/sh
#
# Shell script that configures gnome-terminal to use solarized theme
# colors. Written for Ubuntu 11.10, untested on anything else.
#
# Solarized theme: http://ethanschoonover.com/solarized
#
# Adapted from these sources:
# https://gist.github.com/1280177
# http://xorcode.com/guides/solarized-vim-eclipse-ubuntu/
@isaacs
isaacs / node-and-npm-in-30-seconds.sh
Last active November 2, 2024 12:56
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@tutuca
tutuca / fabfile.py
Last active November 15, 2016 13:26
#!/usr/bin/env python
# -- coding: utf-8 --
"""Deployment script.
This script is coded so it can make the deployments automagically in the
designed servers, it also works as a documentation of where are the programs
installed.
USE: fab <hosts>:<username> <action>
EX: fab staging:admin release