Skip to content

Instantly share code, notes, and snippets.

View mikedamage's full-sized avatar

Mike Green mikedamage

View GitHub Profile
@mikedamage
mikedamage / snip.html
Created February 17, 2015 14:26
Inline styles vs. classes and external stylesheets
<!-- This is bad for business: -->
<p style="margin: 15px;">
<strong style="color: #f00;">This is important!</strong>
<span style="color #ccc;">This isn't.</span>
</p>
<!-- Instead, define a class with a semantic, descriptive name, and style it in an external stylesheet: -->
<!-- in <head>: -->
<link rel="stylesheet" href="style.css">
@mikedamage
mikedamage / rescan.sh
Created February 24, 2015 02:33
Force a WiFi scan
#!/bin/bash
gksudo iwlist wlan0 scan
zenity --info --title="WiFi Scan" --text="WiFi scan complete!"
@mikedamage
mikedamage / gist.zsh
Created April 27, 2015 18:55
Quick and dirty time-based file removal
#!/usr/bin/env zsh
setopt NULL_GLOB EXTENDED_GLOB
# Files older than this will be deleted
KEEP_DAYS=30
files=($PWD/*(.Nmd+$KEEP_DAYS))
for f in $files; do
@mikedamage
mikedamage / jquery.transitions.js
Created April 28, 2015 16:06
jQuery CSS Transition Callbacks Plugin (ES6)
/**
* jQuery Transition Callbacks Module
* by Mike Green <mike@fifthroomcreative.com>
*/
/* jshint esnext: true, globalstrict: true, browser: true */
'use strict';
import $ from 'jquery';
@mikedamage
mikedamage / collatz.js
Created May 3, 2015 17:30
Collatz Conjecture in JS
#!/usr/bin/env node
'use strict'
function collatz(num) {
var result;
if (num % 2 === 0) {
result = num / 2;
} else {
@mikedamage
mikedamage / snippet.txt
Created December 29, 2008 16:00
Basic LaTeX Article Template
\documentclass[11pt]{article}
\usepackage{graphicx} % needed for including graphics e.g. EPS, PS
\topmargin -1.5cm % read Lamport p.163
\oddsidemargin -0.04cm % read Lamport p.163
\evensidemargin -0.04cm % same as oddsidemargin but for left-hand pages
\textwidth 16.59cm
\textheight 21.94cm
%\pagestyle{empty} % Uncomment if don't want page numbers
\parskip 7.2pt % sets spacing between paragraphs
%\renewcommand{\baselinestretch}{1.5} % Uncomment for 1.5 spacing between lines
@mikedamage
mikedamage / hello.b
Created December 29, 2008 16:10
"Hello World" in Brainfuck
++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.
$result = mysql_query("SELECT * FROM table ORDER BY column DESC");
// I hard-code the column names so I can capitalize, add spaces, etc.
$fields = '"User ID","Name","Email","Registration Date"'."\n";
// Iterate through the rows of data
while ($row = mysql_fetch_assoc($result))
{
$fields .= '"'.$row['id'].'","'.$row['name'].'","'.$row['email'].'","'.$row['registration_date'].'"'."\n";
}
if (window.sidebar) {
window.sidebar.addPanel(title, url,"");
}
require 'optparse'
app = Hash.new
options = OptionParser.new do |opts|
opts.on("-o", "--option [ARG]", "Option description") do |opt|
app['option'] = opt
end
end