Skip to content

Instantly share code, notes, and snippets.

View samos123's full-sized avatar
🎯
Focusing

Sam Stoelinga samos123

🎯
Focusing
View GitHub Profile
@devver
devver / terms_of_service.markdown
Last active July 22, 2024 15:34
A general Terms of Service under the Creative Commons License

Terms of Service

Last revised on [DATE]

The Gist

[COMPANY] operates the [SERVICE] service, which we hope you use. If you use it, please use it responsibly. If you don't, we'll have to terminate your account.

For paid accounts, you'll be charged on a monthly basis. You can cancel anytime, but there are no refunds.

@treyhunner
treyhunner / models.py
Created December 10, 2010 06:16
Encrypt and decrypt Django model primary key values (useful for publicly viewable unique identifiers)
# This code is under the MIT license.
# Inspired by this StackOverflow question:
http://stackoverflow.com/questions/3295405/creating-django-objects-with-a-random-primary-key
import struct
from Crypto.Cipher import DES
from django.db import models
def base36encode(number):
@hrldcpr
hrldcpr / tree.md
Last active June 8, 2024 18:11
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@marktheunissen
marktheunissen / pedantically_commented_playbook.yml
Last active June 5, 2024 22:16 — forked from phred/pedantically_commented_playbook.yml
Insanely complete Ansible playbook, showing off all the options
This playbook has been removed as it is now very outdated.
@andredublin
andredublin / Enlightenment.md
Last active December 10, 2015 04:48
Software development enlightenment that I have achieved over time.

#Testing

  • Isolate the object under test, don’t test multiple objects under one test case, this creates unneeded code and technical debt.
  • Unit test behavior, not methods. We need to know how to use the class to achieve a goal, not how to exercise all the paths through its code.
  • Don't test active record, it isn't a special behavior that the system is performing.
  • You don't need 100% test coverage all the time.
  • Don’t test query messages ( messages that do not modify another object ).
  • Do test command messages ( messages that do modify another object ).
  • Test the public interface of an object, private methods are always changing and add technical debt to the test and code.
  • Mock objects that are outside of the current object test scope (roles, interfaces, other objects)
@mekza
mekza / countries.py
Last active December 23, 2022 23:04
WTForms Select Field for country
from wtforms import SelectField
import pycountry
class CountrySelectField(SelectField):
def __init__(self, *args, **kwargs):
super(CountrySelectField, self).__init__(*args, **kwargs)
self.choices = [(country.alpha_2, country.name) for country in pycountry.countries]
@JustinCarmony
JustinCarmony / example_output.txt
Created July 30, 2014 20:24
Summary Salt Highstate Outputter
root@deployServer:~# salt \* state.highstate --output=summary_highstate
web-server01.example.com ------------------ Success: 20 Changed: 0 Errors: 0
web-server02.example.com ------------------ Success: 71 Changed: 1 Errors: 0
db-server03.example.com ------------------- Success: 73 Changed: 1 Errors: 0
mongo-server04.example.com ---------------- Success: 74 Changed: 1 Errors: 0
mongo-server05.example.com ---------------- Success: 74 Changed: 1 Errors: 0
memcache-server06.example.com ------------- Success: 74 Changed: 1 Errors: 0
mysql-server07.example.com ---------------- Success: 74 Changed: 1 Errors: 0
logs-server08.example.com ----------------- Success: 20 Changed: 0 Errors: 0
redis-server09.example.com ---------------- Success: 27 Changed: 0 Errors: 0
@jin3110
jin3110 / tmux.sh
Last active January 8, 2024 12:33
How to install tmux in CoreOS toolbox
#!/bin/bash
# Usage
# =====
# ~~~
# /opt/bin/tmux.sh [tmux args...]
# ~~~
#
# How to install tmux in CoreOS toolbox
# =====================================
This document describes about installation and configuration of IPMI simulator.
We need: qemu-kvm, OpenIPMI, OpenIPMI-tools
1) Install the qemu-kvm. We need the qemu, which have the IPMI pacthes.
Use the source https://github.com/cminyard/qemu/tree/stable-2.2-ipmi
./configure, make and make install
2) Download the OpenIPMI libraries, from http://sourceforge.net/projects/openipmi/
Follow the process documented in lanserv/README.vm
./configure --prefix=/opt/openipmi/usr --sysconfdir=/opt/openipmi/etc \
--with-perlinstall=/opt/openipmi/usr/lib/perl \
@ArthurX
ArthurX / copy_recording_to_storage.py
Created April 29, 2016 10:58
Small script to copy audio recording files made with non-timeline to a new date named directory and create a new empty setup to start
#!/usr/bin/python -tt
# Small script to copy audio recording files made with non-timeline to a new date named directory and create a new empty setup to start. You can change the recorded file size limit.
# You need to create the working and preset directories before.
# I use rename() because that is way quicker than really copying.
import sys
import re
import os
import shutil