Skip to content

Instantly share code, notes, and snippets.

View WillsonSmith's full-sized avatar

Willson Smith WillsonSmith

View GitHub Profile
@WillsonSmith
WillsonSmith / HTMLTemplateSnippet.html
Last active December 16, 2015 22:09
A snippet for the basics of an HTML page.
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta charset="utf-8">
<link rel="stylesheet" href="css/style.css">
</head>
@WillsonSmith
WillsonSmith / FloatClearfix.css
Last active December 16, 2015 22:18
Small, effective way to clear floats in css
/* Apply the class "group" to your container element ie8+*/
.group:after {
content: "";
display: table;
clear: both;
}
@WillsonSmith
WillsonSmith / BlingSelect.js
Created May 2, 2013 21:18
Quick and small way to make a "bling" element selector. Avoid JQuery when it is not necessary.
var $ = document.querySelectorAll.bind(document);
Element.prototype.on = Element.prototype.addEventListener;
$('@cursor')[0].on('touchstart', handleTouch);
@WillsonSmith
WillsonSmith / tinygrid.css
Created May 14, 2013 18:49
tinygrid.scss (sass) compiled to css - could be optimized a little.
*, *:before, *:after {
box-sizing: border-box;
}
.grid-full {
width: 100%;
}
.grid-1-2 {
float: left;
@WillsonSmith
WillsonSmith / tinygrid.scss
Last active December 17, 2015 08:09
A nothing-fancy, tiny grid sass file.
@mixin breakpoint($point) {
@if $point == papa-bear {
@media (max-width: 1600px) { @content; }
}
@else if $point == mama-bear {
@media (max-width: 1250px) { @content; }
}
@else if $point == baby-bear {
@media (max-width: 650px) { @content; }
}
@WillsonSmith
WillsonSmith / Fisher-Yates-Shuffle.js
Created May 26, 2013 17:37
Fisher-Yates shuffle algorithm.
/*
* Add a shuffle function to Array object prototype
* Usage :
* var tmpArray = ["a", "b", "c", "d", "e"];
* tmpArray.shuffle();
*/
Array.prototype.shuffle = function (){
var i = this.length, j, temp;
if ( i == 0 ) return;
while ( --i ) {
@WillsonSmith
WillsonSmith / ScreenShot.rb
Created October 29, 2013 04:19
Move all screenshots (Mac) from desktop into a temporary (tmp) folder.
require 'fileutils'
files = Dir.glob "*.png"
files = files.map { |file| [file.count("?/"), file] }
files = files.sort.map { |file| file[1] }
files.each do |file|
rena = file.include? 'Screen Shot'
dchk = 'temp'
if rena
@WillsonSmith
WillsonSmith / shout.js
Last active January 24, 2016 01:28
implementations of some string stuff
(function() {
function compose(...funcs) {
return function (value) {
return funcs.reverse().reduce(function(previous, current) {
return previous.call(this, current(value));
});
};
}
function shout(string) {
@WillsonSmith
WillsonSmith / slackzoom.lua
Created December 1, 2016 20:45
a hammerspoon config to zoom slack on a larger monitor
function reloadConfig(files)
doReload = false
for _,file in pairs(files) do
if file:sub(-4) == ".lua" then
doReload = true
end
end
if doReload then
hs.reload()
end
-- window management
-- animation set 0 for instant sizing
hs.window.animationDuration = 0
function windowOrder()
local KEYBOARD_MODIFIER = {'cmd', 'alt', 'shift'}
function getPos()
local win = hs.window.focusedWindow()