Skip to content

Instantly share code, notes, and snippets.

View Alanaktion's full-sized avatar
:shipit:
Working on too many things.

Alan Hardman Alanaktion

:shipit:
Working on too many things.
View GitHub Profile
@Alanaktion
Alanaktion / autosetup.sh
Last active August 29, 2015 14:15
Auto-setup an Ubuntu machine
#!/bin/bash
# Sets up a new Ubuntu installation with good things
# Desktop and Server are supported
# Detect Ubuntu version
distro="server"
(dpkg -s "ubuntu-desktop" && distro="ubuntu") > /dev/null 2>&1
(dpkg -s "xubuntu-desktop" && distro="xubuntu") > /dev/null 2>&1
(dpkg -s "kubuntu-desktop" && distro="kubuntu") > /dev/null 2>&1
anonymous
anonymous / config.json
Created March 12, 2015 22:03
Bootstrap Customizer Config
{
"vars": {
"@gray-base": "#000",
"@gray-darker": "lighten(@gray-base, 13.5%)",
"@gray-dark": "lighten(@gray-base, 20%)",
"@gray": "lighten(@gray-base, 33.5%)",
"@gray-light": "lighten(@gray-base, 46.7%)",
"@gray-lighter": "lighten(@gray-base, 93.5%)",
"@brand-primary": "darken(#ffca2a, 6.5%)",
"@brand-success": "#5cb85c",
anonymous
anonymous / config.json
Created April 23, 2015 19:33
Bootstrap Customizer Config
{
"vars": {
"@gray-base": "#000",
"@gray-darker": "lighten(@gray-base, 13.5%)",
"@gray-dark": "lighten(@gray-base, 20%)",
"@gray": "lighten(@gray-base, 33.5%)",
"@gray-light": "lighten(@gray-base, 46.7%)",
"@gray-lighter": "lighten(@gray-base, 93.5%)",
"@brand-primary": "#e89b2f",
"@brand-success": "#5cb85c",
@FlorianWolters
FlorianWolters / DirectCallToMagicMethodConstruct.php
Last active April 27, 2016 14:17
Demonstrates a PHP bug: It is possible to directly call the magic method "__construct".
<?php
/**
* DirectCallToMagicMethodConstruct.php
*
* PHP 5.4.13 (cli) (built: Mar 15 2013 02:05:59)
* Copyright (c) 1997-2013 The PHP Group
* Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
* with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans
*/
@Alanaktion
Alanaktion / gpmdp.css
Created September 12, 2016 17:35
Google Play Music Theme
/* This is a hacky stylesheet for making GPM not so ugly. */
/* Fix GPMDB's playlist nav on dark themes */
#playlist-drawer paper-header-panel[at-top] paper-toolbar:not([style-scope]):not(.style-scope),
#playlist-drawer .autoplaylist-section,
#playlist-drawer #recent-playlists-container {
border-bottom-color: <<BACK_SECONDARY>>;
}
/* Remove Hero image */
@Alanaktion
Alanaktion / markov.php
Last active October 17, 2017 03:28
Generate pseudo-random phrases from Markov chains
#!/usr/bin/env php
<?php
if (empty($argv[1]) || $argv[1] == '-h') {
exit ("Usage: markov <input file> [words] [prefix] [minWords]\n");
}
$text = file_get_contents($argv[1]);
$map = map($text);
$words = $argv[2] ?? 20;
$minWords = $argv[4] ?? 10;
import random
def build_model(tokens, n):
"Builds a Markov model from the list of tokens, using n-grams of length n."
model = dict()
if len(tokens) < n:
return model
for i in range(len(tokens) - n):
gram = tuple(tokens[i:i+n])
next_token = tokens[i+n]
@ded
ded / domready.js
Created February 24, 2011 08:46
Smallest x-browser DOM Ready, ever
function r(f){/in/(document.readyState)?setTimeout(r,9,f):f()}
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document regexp("https?://([^:]+)(:[0-9]+)?/transmission/web/.*") {
* {
background-color: transparent !important;
color: inherit !important;
border-color: var(--border-color) !important;
}
body, div.dialog_container div.dialog_window, .inspector-tab, div#jqContextMenu ul, .ui-widget-content {
@coldnebo
coldnebo / Default (OSX).sublime-keymap -- User
Created February 3, 2012 16:21
Sublime Text 2 fix for OSX home/end keys
{ "keys": ["home"], "command": "move_to", "args": {"to": "bol"} },
{ "keys": ["end"], "command": "move_to", "args": {"to": "eol"} }