Skip to content

Instantly share code, notes, and snippets.

View nemesifier's full-sized avatar
🎯
Focusing on @openwisp full time!

Federico Capoano nemesifier

🎯
Focusing on @openwisp full time!
View GitHub Profile
@asfaltboy
asfaltboy / responses-mixin.py
Last active February 22, 2019 14:24
A responses TestCase Mixin
"""
A unittest.TestCase mixin that allows using the
responses (https://pypi.python.org/pypi/responses/) package in tests.
Usage
-----
Install responses with `pip install responses`.
Add `ResponsesMixin` to your `TestCase` parent classes instead of using
@alces
alces / ansible_local_playbooks.md
Last active June 13, 2024 02:02
How to run an Ansible playbook locally
  • using Ansible command line:
ansible-playbook --connection=local 127.0.0.1 playbook.yml
  • using inventory:
127.0.0.1 ansible_connection=local
@haggen
haggen / string.random.lua
Last active June 30, 2024 02:30
Random strings in Lua
math.randomseed(os.time())
local charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
function string.random(length)
if length > 0 then
return string.random(length - 1) .. charset:sub(math.random(1, #charset), 1)
else
return ""
end
@kostko
kostko / gist:9b6eb44f373e17891d65
Last active August 29, 2015 14:08
Example JSON serialization of nodewatcher v3 schema
{
"uuid": "64840ad9-aac1-4494-b4d1-9de5d8cbedd9",
"general": {
"name": "node-1",
"device": "tp-wr743ndv1",
"build_channel": "stable",
"version": null
},
"location": {
"address": "Foo Street 17",
@vinitkumar
vinitkumar / architecture.md
Last active January 23, 2022 04:36
Pragmatic programmer checklists in form of Gists.

Architectural Questions

  • Are responsibilities well defined?
  • Are the collaborations well defined?
  • Is coupling minimized?
  • Can you identify potential duplication?
  • Are interface definitions and constraints acceptable?
  • Can modules access needed data—when needed?
@mattseymour
mattseymour / django-secret-keygen.py
Last active September 8, 2022 23:47
Django secret key generator
"""
Pseudo-random django secret key generator.
- Does print SECRET key to terminal which can be seen as unsafe.
"""
import string
import random
from __future__ import print_function
@relaxdiego
relaxdiego / graphite.md
Last active January 5, 2022 09:07 — forked from surjikal/graphite.md
Installing Graphite in OS X Mavericks

Follow these steps to install graphite on OS X Mavericks.

Prerequisites

  • Homebrew
  • Python 2.7
  • Git

Install dependencies

Install Cairo and friends

from django import http
from django.conf import settings
"""
Put this file in a directory called, eg, 'middleware,' inside your django
project. Make sure to create an __init__.py file in the directory so it can
be included as a module.
Set the values for
XS_SHARING_ALLOWED_ORIGINS
XS_SHARING_ALLOWED_METHODS
@jterrace
jterrace / xvfb
Created June 11, 2012 18:46
xvfb init script for Ubuntu
XVFB=/usr/bin/Xvfb
XVFBARGS=":1 -screen 0 1024x768x24 -ac +extension GLX +render -noreset"
PIDFILE=/var/run/xvfb.pid
case "$1" in
start)
echo -n "Starting virtual X frame buffer: Xvfb"
start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile --background --exec $XVFB -- $XVFBARGS
echo "."
;;
stop)
@toekneestuck
toekneestuck / underscore.nl2br
Created February 21, 2012 20:29
A port of nl2br to Underscore
_.mixin({
nl2br : function(str, is_xhtml){
var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '<br />' : '<br>';
return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1' + breakTag + '$2');
}
});