Skip to content

Instantly share code, notes, and snippets.

View phred's full-sized avatar
🌴
On vacation

Fred Alger phred

🌴
On vacation
View GitHub Profile
@phred
phred / app.py
Created February 18, 2013 20:05
Piece of crap web service for putting stuff on the clipboard. Hit /crap for some random Hipster Ipsum! Crap is a fun word. Oh yeah, and don't forget to pip install xerox (and flask)
import xerox, random
from flask import Flask, request
app = Flask(__name__)
@app.route("/crap")
def crap():
xerox.copy(random.choice(app.bucket))
return "Copying some randomly chosen crap to your clipboard!"
@app.route("/")
FUCKING HELL
This shit is fucking broke!
_________________________
I am:
_ indifferent _ homicidal _ FUCKED
<?xml version="1.0" encoding="UTF-8"?>
<nil-classes type="array"/>
@phred
phred / ConfigParser.php
Created November 16, 2012 20:45
Simple PHP class wrapper for reading configuration from ini files
<?php
class ConfigParser {
function __construct($ini_file) {
$this->data = parse_ini_file($ini_file, true);
if ($this->data === FALSE) {
throw new Exception("Error reading file {$ini_file}");
}
}
function sections() {
@phred
phred / extract_vulns.py
Created November 1, 2012 18:10
Extract Ubuntu Vulnerabilities into a easy to copy/paste text form
#!/usr/bin/env python
# Usage: python extract_vulns.py <url>
# Bog-simple screen scraping, will fail unless URL is something like this:
# http://www.ubuntu.com/usn/lucid/
# http://www.ubuntu.com/usn/lucid/?page=3
#
from BeautifulSoup import BeautifulSoup
import requests, time, sys
@phred
phred / config.fish
Created October 23, 2012 18:06
phred's config.fish
if status --is-login
# Use universal variables to replace globals, this lets set -Ux change PATH and LANG forever
set -ge PATH
set -gx PATH $PATH
set -ge LANG
set -gx LANG $LANG
function e
emacsclient -n $argv
@phred
phred / tiny.markdown
Created October 14, 2012 12:30
Solving Embarrasingly Simple Problems in Factor

Solving Embarrasingly Simple Problems in Factor

This Article has struck a chord with me. I'm not an Erlang-er, but the style he describes of "writing many tiny functions" strongly reminds me of why I've come to love Factor.

Drink Beer when Delicious

@phred
phred / discounts.factor
Last active October 11, 2015 08:08
EBNF for FoxyCart discount strings
USE: peg.ebnf
#! throw this in the listener to see the example parse tree
"discount_quantity_amount=Discount_Name{repeat|1-5.42|2-5|6-0}"
[EBNF
number = [0-9]+ => [[ string>number ]]
amount = number ("." number)?
type = "allunits" | "incremental" | "repeat" | "single"
@phred
phred / pedantically_commented_playbook.yml
Last active February 26, 2025 14:19
Very complete Ansible playbook, showing off all the options
---
####
#### THIS IS OLD AND OUTDATED
#### LIKE, ANSIBLE 1.0 OLD.
####
#### PROBABLY HIT UP https://docs.ansible.com MY DUDES
####
#### IF IT BREAKS I'M JUST SOME GUY WITH
#### A DOG, OK, SORRY
####
@phred
phred / trees.lua
Created November 13, 2011 00:56 — forked from npryce/trees.lua
Random Trees for Codea
-- Use this function to perform your initial setup
function setup()
   seed = 1
    iparameter("depth", 1, 15)
    depth = 10
    parameter("length", 0, 300)
    length = 120
    parameter("angle", 1, 90)