Skip to content

Instantly share code, notes, and snippets.

View sunaku's full-sized avatar

Suraj N. Kurapati sunaku

View GitHub Profile
@sunaku
sunaku / XTerm
Created December 28, 2009 21:53
! The Desert color scheme, ported to PuTTY from Vim by igvita:
! http://www.igvita.com/2008/04/14/custom-putty-color-themes/
XTerm*vt100.foreground : rgb:ff/ff/ff
XTerm*vt100.background : rgb:33/33/33
XTerm*vt100.cursorColor : rgb:00/ff/00
XTerm*vt100.color0 : rgb:4d/4d/4d
XTerm*vt100.color1 : rgb:55/55/55
XTerm*vt100.color2 : rgb:ff/2b/2b
XTerm*vt100.color3 : rgb:ff/55/55
XTerm*vt100.color4 : rgb:98/fb/98
require 'ember'
module ActionView
module TemplateHandlers
##
# @example Pass template processing options to Ember
#
# ActionView::TemplateHandlers::Ember.options = {
# :unindent => true,
# :shorthand => true,
@sunaku
sunaku / gist:574080
Created September 10, 2010 17:58 — forked from mikz/gist:574015
def quoted_date(value)
base = value.respond_to?(:getutc) ? value.getutc.to_s(:db) : super
usec = sprintf(".%06d", value.usec) if value.respond_to?(:usec)
zone = " #{value.formatted_offset}" if value.respond_to?(:formatted_offset)
"#{base}#{usec}#{zone}"
end
@sunaku
sunaku / testr-spin
Created November 9, 2011 18:32
Simple script to emulate Spin using TestR.
#!/usr/bin/env ruby
# This script emulates [Spin] using [TestR].
#
# Usage: testr-spin serve [-I<LOAD_PATH>]... <OVERHEAD_FILE>...
# Usage: testr-spin push <TEST_FILE> [<TEST_NAME>]...
#
# [Spin]: https://github.com/jstorimer/spin
# [TestR]: https://github.com/sunaku/testr
require 'json'
def self.valid_time?(time)
(0 .. 2359).include? Integer(time)
rescue ArgumentError # invalid integer
false
end
@sunaku
sunaku / STDOUT
Last active May 25, 2018 20:48 — forked from courtenay/STDOUT
Further refinement of @jcemer's modifications at <https://gist.github.com/courtenay/5454972#comment-912976> Strictly speaking, we're generating [URI fragments](http://en.wikipedia.org/wiki/Fragment_identifier), not permalinks.
$ irb
## ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]
>> require './github_style_titles.rb'
true
>> gh = Redcarpet::Render::GithubStyleTitles.new
#<Redcarpet::Render::GithubStyleTitles:0x00000001cc3a48>
>> puts Redcarpet::Markdown.new(gh).render "test\n\n# test 1\n\n# test 2\n\n# test 1\n\n# test 1"
<a name="test-1" href="#test-1" class="anchor"><span class="anchor-icon"></span></a><h1 id="test-1">test 1</h1>
@sunaku
sunaku / racket-tester
Last active December 26, 2015 16:09
Event-driven test runners for Coursera Programming Languages class - https://class.coursera.org/proglang-002
#!/bin/sh
# When *.rkt files in the current directory are modified, this script runs
# their corresponding *test.rkt files and prints any errors or test fails.
inotifywait -qme close_write --format '%w%f' . | while read file; do
# only process *.rkt files - ignore all other files
test "${file%.rkt}" = "$file" && continue
# map the *.rkt file to its corresponding *test.rkt
# file, unless it already _is_ that *test.rkt file!
@sunaku
sunaku / set-option
Created October 31, 2013 04:19
Listing of all tmux 1.8 options vs. window options.
set-option [-agoqsuw] [-t target-session | target-window] option value
buffer-limit number
escape-time time
exit-unattached [on | off]
quiet [on | off]
set-clipboard [on | off]
Available session options are:
assume-paste-time milliseconds
base-index index
bell-action [any | none | current]
@sunaku
sunaku / section8.rb
Last active December 29, 2015 11:19
Example of the functional approach to problem decomposition in Ruby. https://class.coursera.org/proglang-002/forum/thread?thread_id=1962
BadResult = Class.new Exception
Int = Struct.new :i
Negate = Struct.new :e1
Add = Struct.new :e1, :e2
def eval e
case e
when Int then e
when Negate then case v1 = (eval e.e1)
@sunaku
sunaku / chromeos-vpn
Created April 9, 2014 16:03
chromeos-scripts
#!/bin/bash
#
# Connects to the VPN specified by the given vpnc(1) configuration file and
# then waits for you to interrupt or kill this process, at which time it
# disconnects the VPN. See https://github.com/dnschneid/crouton/wiki/VPNC
#
# Usage: chromeos-vpn VPNC_CONFIGURATION_FILE [OPTIONS_FOR_VPNC...]
#
# Setup: apt-get install vpnc wireless-tools
#