Skip to content

Instantly share code, notes, and snippets.

@mhayes
mhayes / .tmux.conf
Created Oct 12, 2018
tmux configuration
View .tmux.conf
unbind C-b
set -g prefix C-s
unbind +
bind + new-window -d -n tmux-zoom 'clear && echo TMUX ZOOM && read' \; swap-pane -s tmux-zoom.0 \; select-window -t tmux-zoom
unbind -
bind - last-window \; swap-pane -s tmux-zoom.0 \; kill-window -t tmux-zoom
bind r source-file ~/.tmux.conf \; display "configuration file reloaded."
#set window numbering at 1
set -g base-index 1
@mhayes
mhayes / slack-sns.js
Created Apr 11, 2017
SNS to Slack via Lambda
View slack-sns.js
const https = require("https");
const util = require("util");
const SLACK_WEBHOOK_PATH = process.env.SLACK_WEBHOOK_PATH;
const SLACK_CHANNEL = process.env.SLACK_CHANNEL;
const SLACK_USERNAME = process.env.SLACK_USERNAME || "aws";
const SLACK_EMOJI = process.env.SLACK_EMOJI || ":aws:";
function noop (ret) {
if (ret) {
@mhayes
mhayes / inheritance.js
Last active Sep 15, 2015
Simple javascript inheritance (as i currently understand it)
View inheritance.js
var Mammal = function (name) {
this.name = name;
};
Mammal.prototype.sayHello = function () {
return "Hello, I'm a " + this.name;
}
var Cow = function (name) {
Mammal.apply(this, arguments);
@mhayes
mhayes / README.md
Last active Aug 29, 2015
Need quick way to rename files according to a sequence?
View README.md

quickstart

Let's assume you have OS X screenshots named like Screen Shot 2015-06-09 at 9.39.56 AM.png. You can use this script to rename them like so:

mark:screens mark$ ruby renamer.rb 
move ./Screen Shot 2015-06-09 at 9.39.56 AM.png to EXAMPLE_ONE_160x600_1.png
move ./Screen Shot 2015-06-09 at 9.39.57 AM.png to EXAMPLE_ONE_160x600_2.png
move ./Screen Shot 2015-06-09 at 9.39.58 AM.png to EXAMPLE_ONE_160x600_3.png
move ./Screen Shot 2015-06-09 at 9.40.00 AM.png to EXAMPLE_ONE_160x600_4.png
@mhayes
mhayes / index.php
Created Apr 8, 2015
Send an e-mail with PHP
View index.php
<?php
if(isset($_POST['email'])) {
$name = trim($_POST['name']);
$email = trim($_POST['email']);
$subject = trim($_POST['subject']);
$message = trim($_POST['message']);
if (preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i", $email)) {
$to = "me@example.com";
$email_subject = "Contact Form Submission | $name";
@mhayes
mhayes / setup.sh
Last active Aug 29, 2015
Setup Foundation
View setup.sh
#! /bin/sh
mkdir -p ~/Sites/zurb-foundation
cd ~/Sites/zurb-foundation
npm install bower grunt-cli -g
rc=$?
if [[ $rc != 0 ]] ; then
sudo npm install bower grunt-cli -g
fi
echo "[SUCCESS] Installed bower and grunt";
@mhayes
mhayes / setup.sh
Created Apr 29, 2014
Setup SassC + LibSass on MacOSX (tested on 10.9.2 only)
View setup.sh
#!/bin/bash
# # Allow us to compile from source
# https://github.com/hcatlin/libsass/archive/master.zip
# https://github.com/hcatlin/sassc/archive/master.zip
TMPFILE="libsass"
PWD=`pwd`
wget "https://github.com/hcatlin/libsass/archive/master.zip" -O $TMPFILE
unzip -d $PWD $TMPFILE
@mhayes
mhayes / SassMeister-input.scss
Created Feb 5, 2014
Generated by SassMeister.com.
View SassMeister-input.scss
// ----
// libsass (v0.7.0)
// ----
// works in libsass, not in ruby sass
$text-direction: ltr;
$text-direction: ltr !default;
@mhayes
mhayes / SassMeister-input-HTML.html
Created Jan 8, 2014
Generated by SassMeister.com.
View SassMeister-input-HTML.html
<div class="pie-timer deg-0"></div>
You can’t perform that action at this time.