Skip to content

Instantly share code, notes, and snippets.

@firstclown
firstclown / move.rb
Created March 16, 2011 13:02
Ruby script to easily upload files to a test server from the command line
#!/usr/bin/env ruby
class MoverConfig
def initialize()
@movearray = Array.new
config = getConfigFile
if(! config) then
p ".move not found"
exit
end
@firstclown
firstclown / .bashrc
Created May 17, 2011 12:45
A bash-based unit test loop for Kohana based unit tests running in Linux. Runs every 25 seconds or so and pops up a message only on failure or when it switches from failure to success.
phptestloop () {
while true; do FOO=`/opt/lampp/bin/phpunit --bootstrap=modules/unittest/bootstrap.php application/tests`;
if [ $? -ne 0 ];
then
SUCCESS=0;
notify-send -i gtk-dialog-error 'Tests Failed' "$FOO" ;
else
if [ "$SUCCESS" = 0 ];
then
SUCCESS=1;
@firstclown
firstclown / fish_prompt.fish
Created December 5, 2013 00:53
My current fish prompt. Shows the current directory, who's logged in, current host (last two helpful for SSH sessions) and then a git status prompt displaying current branch and the branches status. Finally the actual prompt is on the next line, to keep lots of space for commands.
set -g __fish_git_prompt_show_informative_status 1
set -g __fish_git_prompt_hide_untrackedfiles 1
set -g __fish_git_prompt_color_branch magenta bold
set -g __fish_git_prompt_showupstream "informative"
set -g __fish_git_prompt_char_upstream_ahead "↑"
set -g __fish_git_prompt_char_upstream_behind "↓"
set -g __fish_git_prompt_char_upstream_prefix ""
set -g __fish_git_prompt_char_stagedstate "●"
var id = Math.random().toString(16).slice(2)
@firstclown
firstclown / fillin.rb
Created December 31, 2013 00:58
Wanted an easy way to take a directory, copy it, and then fill in all the files within it with custom values.
#!/usr/bin/env ruby
require 'optparse'
require 'securerandom'
require 'fileutils'
require 'erb'
params = {}
target_directory = "New"
# Parse args
@firstclown
firstclown / generate_book.fish
Created January 4, 2014 17:31
Take a markdown file in a blown out ePub and generate a .mobi and .epub ebook from it. ebook-convert is a Calibre command line app.
function generate_book
multimarkdown $argv[1].md -o story.html
kindlegen assembly.opf -o $argv[1].mobi
ebook-convert $argv[1].mobi $argv[1].epub --page-breaks-before=/
end
@firstclown
firstclown / sl.fish
Created January 4, 2014 19:39
Starts Sublime Text using the passed in file/folder or, if nothing is passed in, using the current folder.
function sl
if test (count $argv) -eq 0
set argv[1] '.'
end
subl -n $argv
end
@firstclown
firstclown / plainTextToHTML.js
Created January 15, 2014 15:28
Convert plain text in message variable to properly formatted HTML
message.replace(/\n([ \t]*\n)+/g, '</p><p>').replace(/\n/g, '<br />');
@firstclown
firstclown / insertAtCaret.js
Created January 15, 2014 15:32
Add a new jQuery function that will allow you to add text to the current caret position in textarea and text fields. Pulled from some Stack Overflow question.
jQuery.fn.extend({
insertAtCaret: function(myValue){
return this.each(function(i) {
if (document.selection) {
//For browsers like Internet Explorer
this.focus();
var sel = document.selection.createRange();
sel.text = myValue;
this.focus();
}
@firstclown
firstclown / plugin.php
Created January 21, 2014 13:45
YOURLS plugin to show user agent data on traffic location tab in admin.
<?php
/*
Plugin Name: User Agents
Plugin URI: https://gist.github.com/firstclown/
Description: Shows User Agents on the Traffic Location page
Version: 1.0
Author: firstclown
Author URI: http://www.jerickson.net/
*/