Skip to content

Instantly share code, notes, and snippets.

View kogent's full-sized avatar

Mark Carey kogent

View GitHub Profile
@kogent
kogent / 0_reuse_code.js
Created March 11, 2016 22:57
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
# HG changeset patch
# User Sean Farley <sean.michael.farley@gmail.com>
# Date 1382624667 -28800
# Thu Oct 24 22:24:27 2013 +0800
# Node ID dd6d51b7e12be5fab94a8779e890c5558e4d4001
# Parent 86a3bc5c8ff689a291e86950a3d8fd327f42b870
partial import
wiggled scp
@kogent
kogent / giftube.rb
Last active March 11, 2016 23:25 — forked from marcel/gist:2100703
giftube – Generates an animated gif from a YouTube url.
#!/usr/bin/env ruby
# giftube – Generates an animated gif from a YouTube url.
#
# Usage:
#
# giftube [youtube url] [minute:second] [duration]
#
# ex.
#
@kogent
kogent / TextMate gemspec snippet.png
Created April 5, 2010 19:21 — forked from mislav/TextMate gemspec snippet.png
TextMate snippet to quickly populate a fresh gemspec
TextMate gemspec snippet.png
@kogent
kogent / url_dsl.rb
Created February 24, 2010 19:40 — forked from defunkt/url_dsl.rb
require 'open-uri'
# url dsl -- the ultimate url dsl!
#
# You just can't beat this:
#
# $ irb -r url_dsl
# >> include URLDSL
# => Object
# >> http://github.com/defunkt.json
@kogent
kogent / mini.rb
Created February 24, 2010 19:19 — forked from defunkt/mini.rb
##
# test/spec/mini 5
# http://gist.github.com/307649
# chris@ozmm.org
#
def context(*args, &block)
return super unless (name = args.first) && block
require 'test/unit'
klass = Class.new(defined?(ActiveSupport::TestCase) ? ActiveSupport::TestCase : Test::Unit::TestCase) do
def self.test(name, &block)
@kogent
kogent / debug.rb
Created December 8, 2009 20:33 — forked from tmm1/debug.rb
# collect information about a running process
# ruby debug.rb <pid>
begin
raise ArgumentError unless pid = ARGV[0]
pid = pid.to_i
raise ArgumentError unless pid > 0
Process.kill(0,pid)
rescue TypeError, ArgumentError
raise 'pid required'
@kogent
kogent / 0what.md
Created August 24, 2009 03:55 — forked from defunkt/0what.md

Poor Man's Deploy

  • Start a Sinatra server on port 4000
  • GET / to that server triggers a git pull and mod_rails restart
  • Hit port 4000 locally after pushing

Why?

@kogent
kogent / bench.rb
Created July 2, 2009 04:45 — forked from lifo/bench.rb
require 'rubygems'
require 'curb'
require "net/http"
require 'benchmark'
# http://0.0.0.0:8080
#
# class HomeController < ApplicationController
# def index
# sleep 3
# This is a useful little pattern for working with gems without
# explicitly requiring rubygems in your code.
#
# The approach taken is to require a library and catch any LoadError
# that might get thrown. In the rescue clause we require rubygems.
#
# The require method is nice in that it will return true if the code
# was loaded, and it returns false if the code was _already_ loaded.
# If the require of rubygems returns true, we will retry our original
# require. It will either succeed this time (since we now have rubygems