Skip to content

Instantly share code, notes, and snippets.

@cmawhorter
cmawhorter / spc
Created March 10, 2013 01:03
Simple shell script to output a number of blank lines. Defaults to 30.
#!/usr/bin/env bash
# usage: `spc` or `spc [number of lines]`
lines=${1:-30}
for ((i=1; i<=$lines; i++))
do
echo
done
#!/bin/sh
#
# redis - this script starts and stops the redis-server daemon
#
# chkconfig: - 85 15
# description: Redis is a persistent key-value database
# processname: redis-server
# config: /etc/redis/redis.conf
# config: /etc/sysconfig/redis
# pidfile: /var/run/redis.pid
@cmawhorter
cmawhorter / redis.conf
Created June 7, 2013 00:16
default redis 2.6.10 conf with daemonize set to yes
# Redis configuration file example
# Note on units: when memory size is needed, it is possible to specify
# it in the usual form of 1k 5GB 4M and so forth:
#
# 1k => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb => 1024*1024 bytes
# 1g => 1000000000 bytes
<?php
// Stampr Mailing Hello World in PHP!
require 'vendor/autoload.php';
require 'src/Stampr/Stampr.php';
$stampr_login = "your.stampr.login@example.com";
$stampr_password = "your.stampr.password";
$endpoint = "https://stam.pr/api";
<?php
// Stampr API - Create a Batch for Testing
require 'vendor/autoload.php';
require 'src/Stampr/Stampr.php';
$stampr_login = "your.stampr.login@example.com";
$stampr_password = "your.stampr.password";
$endpoint = "https://stam.pr/api";
@cmawhorter
cmawhorter / fabricjs-thumbnail.js
Created June 26, 2014 04:54
The only way I could generate real-time thumbnails of a fabricjs canvas
// see mawhorter.net for full post
// Put this in an after:render event handler.
// Be warned: Ripped out of working code and renamed variables without testing.
var fabricMain = new fabric.Canvas('main')
, fabricThumb = new fabric.Canvas('screenshot')
, ctxThumbnail = $('canvas#thumbnail')[0].getContext('2d');
@cmawhorter
cmawhorter / proxy.js
Created June 26, 2014 05:36
Node script to forward all http requests to another server and return the response with an access-control-allow-origin header. Follows redirects.
// Simple proxy/forwarding server for when you don't want to have to add CORS during development.
// Usage: node proxy.js
// Open browser and navigate to http://localhost:9100/[url]
// Example: http://localhost:9100/http://www.google.com
// This is *NOT* for anything outside local development. It has zero error handling among other glaring problems.
// This started as code I grabbed from this SO question: http://stackoverflow.com/a/13472952/670023
@cmawhorter
cmawhorter / grunt-build.bat
Last active April 19, 2016 13:30
Script to build grunt/yeoman project from jenkins on windows 7
@echo off
REM You may need to add `cd %WORKSPACE%` in the jenkins project prior to
REM calling this script. I have it in mine and didn't test without.
REM Correct paths to respective applications as-needed
SET PATH=%PATH%;C:\Program Files (x86)\nodejs;C:\Program Files (x86)\Git\bin;%AppData%\npm;C:\Ruby200-x64\bin
echo Installing or updating bower...
@cmawhorter
cmawhorter / async-download.js
Created July 10, 2014 18:32
Downloads all files in an array 2 at a time
var fs = require('fs');
var path = require('path');
var async = require('async');
var request = require('request');
var tasks = {};
var json = { /* your records */ };
@cmawhorter
cmawhorter / convert-to-svg.bat
Last active August 29, 2015 14:03
Converts all (vector) files in a directory to svg using ps2pdf, uniconvertor and inkscape.
@echo off
REM This will fail with "the input line is too long" if you have a lot of files... maybe?
REM Don't know why, but I think the solution is breaking the body of the for () into a separate
REM batch. But... IDGAF.
echo Starting...
for %%i in (*.*) do (
echo Looking at... %%~di%%~pi%%~ni%%~xi