Skip to content

Instantly share code, notes, and snippets.

@madx
madx / gifcast.sh
Created October 9, 2015 11:41
My screenshoting/screencasting utils (to be used with sharedrop)
#!/bin/bash
# -s for screen region, -w for window
MODE=${1:--s}
# Output file name
FILE="$HOME/Images/Captures/`date +%FT%T.gif`"
# Temporary files
TMPDIR="/tmp"
@madx
madx / screencast-to-gif.sh
Last active September 29, 2015 06:54
Quick GIF screencasts using bash + ffcast + ffmpeg + imagemagick + yad
#!/bin/bash
FILE="$HOME/Images/Captures/`date +%FT%T.gif`"
TMP_AVI=$(mktemp /tmp/outXXXXXXXXXX.avi)
(yad --notification --image media-playback-stop --command "bash -c 'echo q; quit'") |\
ffcast -s % ffmpeg -y -f x11grab -show_region 1 -framerate 15 \
-video_size %s -i %D+%c -codec:v huffyuv \
-vf crop="iw-mod(iw\\,2):ih-mod(ih\\,2)" $TMP_AVI \
@madx
madx / webpack.server.config.js
Created September 15, 2015 13:55
Webpack config for an Express app in Node.js
const path = require("path")
const fs = require("fs")
// -- Webpack configuration --
const config = {}
// Application entry point
config.entry = "./src/server/index.js"
@madx
madx / trace.js
Created September 1, 2015 14:30
JavaScript @trace decorator
function trace(target, name, descriptor) {
if (!DEBUG) {
return descriptor
}
const original = descriptor.value
const traced = function(...args) {
console.trace(`${this.constructor.name}#${name}`, args)
return original.call(this, ...args)
#!/bin/bash
msgid() {
FLAG=0
echo msgid '"'$*'"'
}
msgstr() {
if [ $FLAG -eq 0 ]; then
echo msgstr '"'$*'"'
@madx
madx / component.js
Last active August 29, 2015 14:19
Component class
import {isObject} from "./utils"
import Dispatcher from "./dispatcher"
export default class Component {
constructor() {
this.rootNode = null
this.props = {}
// Add dispatcher observers
if (this.constructor.observers) {
@madx
madx / base.js
Created January 27, 2015 13:57
A basic JS object system
var assign = require("object-assign")
var Base = {
create: function create(properties) {
var base = Object.create(this)
properties = properties || {}
properties.parent = this
assign(base, properties)
@madx
madx / previewer.sh
Created October 8, 2014 16:07
Quick and dirty markdown live previewer in bash using surf and xdotool
#!/bin/bash
render() {
marked source.md > output.html
}
cleanup() {
if [ -d /proc/$surf_pid/ ]; then
kill $surf_pid
fi
@madx
madx / mixin.js
Last active August 29, 2015 14:06
Event emitter mixin
// -- Emitter mixin
function Emitter(base) {
var _eventHandlers = []
function on(eventName, callback) {
var filter = makePattern(eventName)
_eventHandlers.push({
filter: filter,
callback: callback
ifeq ($(OS),Darwin)
install:
npm install -g
else
install:
sudo npm install -g
endif
OU