Skip to content

Instantly share code, notes, and snippets.

Michael Clayton mwcz

View GitHub Profile
@mwcz
mwcz / memlog.sh
Created Nov 8, 2016
A simple script to create graphs of memory usage of Linux processes.
View memlog.sh
#!/usr/bin/env bash
# usage: memlog.sh PID
# requires gnuplot and matplotlib (dnf install python2-matplotlib gnuplot)
PID=$1
LOG=./$PID.log
PNG=./$PID.log.png
echo recording memory usage for PID $PID
View index.html
<script src="typed.js"></script>
@mwcz
mwcz / gif.sh
Created Sep 27, 2016
gif command for recording animated gifs in Linux
View gif.sh
#!/bin/bash
# USAGE: gif SECONDS FILENAME
# example: gif 4 out.gif
# then drag a box :D
# Delay before starting
DELAY=0
# Duration and output file
@mwcz
mwcz / nth.js
Created Feb 11, 2016
nth function, execute a function every nth invocation
View nth.js
/**
* Wrap your function such that it will be executed every N times it's called.
* This is useful in a long-running loop such as the main loop in a game, where
* you want to execute certain functions every 10 frames, or similar, but don't
* want to manage a dozen separate "timers".
*
* @param {Function} f the function to wrap
* @param {Number} n execute the function every `n` times
*/
function nth(f, n) {
@mwcz
mwcz / godzilla.js
Last active Jan 22, 2016
Godzilla Rampage
View godzilla.js
// ==UserScript==
// @name Godzilla Rampage
// @namespace godzilla.substitution.fun
// @description Replaces 'God' with 'Godzilla'
// @version 1.0.0
// @grant none
// @include http://*
// @require https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// ==/UserScript==
View scrapbook.conf
# map the cp-local user hostnames to the remote environment hostnames
map $http_host $upstream_host {
~^dev-.*\.domain\.com$ real.domain.com;
}
# Listen on port 80, but redirect to https/443
server {
listen 80;
server_name ~^(dev|qa|stage|prod).*\.domain\.com$;
@mwcz
mwcz / SassMeister-input-HTML.html
Created Mar 21, 2015
Generated by SassMeister.com.
View SassMeister-input-HTML.html
<!DOCTYPE html>
<html>
<head>
<title>PearlHacks Sass!</title>
</head>
<body>
<header>
@mwcz
mwcz / SassMeister-input-HTML.html
Created Mar 21, 2015
Generated by SassMeister.com.
View SassMeister-input-HTML.html
<!DOCTYPE html>
<html>
<head>
<title>PearlHacks Sass!</title>
</head>
<body>
<header>PearlHacks Sass!</header>
<main>
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
@mwcz
mwcz / prefdep.js
Created Feb 12, 2015
prefdep: apply dependencies to all RequireJS modules sharing a common prefix, for example, make 'angular-cookies' and 'angular-translate' depend on 'angular' with `prefdep('angular-', 'angular')`
View prefdep.js
/* global define, require */
define(['lodash'], function(_) {
'use strict';
function prefdep(prefix, parent_module) {
// grab a convenient reference to the requirejs config
var rjsconf = require.s.contexts._.config;
You can’t perform that action at this time.