Skip to content

Instantly share code, notes, and snippets.

#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
@sperlic
sperlic / fabfile.py
Created May 13, 2012 10:01 — forked from whiteinge/fabfile.py
Example fabric script with VirtualBox automation
# -*- coding: utf-8 -*-
"""MyCompany Fabric script.
* Deploy code
* Set up a local development environment
There are two ways to deploy the myrepo code:
1. :func:`deploy` will do a full virtualenv installation/update and expand a
tarball of the specified git revision (defaults to HEAD) to a timestamped
@sperlic
sperlic / fpm-x-status
Created July 31, 2014 09:22
fpm-x-status
pool: www
process manager: dynamic
start time: 09/Jul/2014:21:09:41 -0400
start since: 1843802
accepted conn: 436469
listen queue: 0
max listen queue: 2
listen queue len: 0
idle processes: 598
active processes: 2
- name: create postgres root user
postgresql_user: db=postgres
name={{ postgres_root_user }}
password={{ postgres_root_pass }}
role_attr_flags=SUPERUSER,LOGIN,CREATEDB,CREATEROLE,REPLICATION
when: datadir_path.stat.exists == false
- name: check postgres root user
postgresql_user: db=postgres
login_user={{ postgres_root_user }}
@sperlic
sperlic / gist:4f7b294dffbad813b2b1
Created September 7, 2014 19:00
Various Artists
z10n@tower Various Artists % tree -L 1
.
├── 1992 - Macedonian Jazz
├── 1993 - Volume Eight - Volume [V08CD]
├── 1994 - Café del Mar - React [REACT CD 041]
├── 1994 - Jazz Legends - Verve [3145198242]
├── 1995 - Café del Mar, volumen dos - React [REACT CD 062]
├── 1995 - Jazz Legends - Giant Records [710457-1]
├── 1995 - Mind the Gap, Volume 5 - Gonzo Circus [GC011]
├── 1996 - Café del Mar, volumen tres - React [REACT CD 084]
@sperlic
sperlic / Sorted
Created September 7, 2014 19:30
Ma muzic collection
z10n@tower sorted % tree -L 3
.
├── 1-9
│   ├── 10,000 Maniacs
│   │   ├── 1989 - In My Tribe - Elektra [9 60738-2]
│   │   ├── 1993 - MTV Unplugged - Elektra Entertainment [61569-2]
│   │   └── 2004 - Campfire Songs The Popular, Obscure & Unknown Recordings (disc 1) - Elektra [R2 73900]
│   ├── 2 Many DJ's
│   │   └── 2002 - As Heard on Radio Soulwax, Part 2 - Play It Again Sam [PIAS] [PIASB 065 CD]
│   └── 4hero
require "cjson"
-- Generic decoder for JSON logs. This will extract all JSON
-- keys and add them to the `Fields` variable of the created
-- Heka message.
--
-- Example use:
--
-- [NginxJsonLogDecoder]
-- type = "SandboxDecoder"
[root@ad-main ~]# systemctl status channels
channels.service - channels
Loaded: loaded (/etc/systemd/system/channels.service; enabled)
Active: failed (Result: exit-code) since Wed 2014-10-01 11:18:28 EDT; 1 weeks 1 days ago
Process: 11352 ExecStart=/usr/local/bin/channels (code=exited, status=2)
Main PID: 11352 (code=exited, status=2)
CGroup: /system.slice/channels.service
Oct 01 11:18:06 ad-main channels[11352]: TARG-IGNORE-PREF: !tube_sponsor
Oct 01 11:18:06 ad-main channels[11352]: [33 52 50 54 124 49 49 48 48 124 57 50 48 57 54 57 124 54 56 51 13 10 13 10 109 82 65 142 219 48 12 124 75 15 241 197 216 69 28 111 55 221 131 14... 98 230 69 29
[root@um-1913 ~]# mdadm -D /dev/md2
/dev/md2:
Version : 1.2
Creation Time : Sat Oct 11 00:53:24 2014
Raid Level : raid6
Array Size : 19386378240 (18488.29 GiB 19851.65 GB)
Used Dev Size : 1938637824 (1848.83 GiB 1985.17 GB)
Raid Devices : 12
Total Devices : 12
Persistence : Superblock is persistent
@sperlic
sperlic / abuse.lua
Last active August 29, 2015 14:07 — forked from dannycoates/abuse.lua
-- This Source Code Form is subject to the terms of the Mozilla Public
-- License, v. 2.0. If a copy of the MPL was not distributed with this
-- file, You can obtain one at http://mozilla.org/MPL/2.0/.
require "math"
require "string"
local alert = require "alert"
local message_variable = read_config("message_variable") or error("must specify a 'message_variable'")
local max_items = read_config("max_items") or 25000