Skip to content

Instantly share code, notes, and snippets.

View kastner's full-sized avatar
🕳️
actively choosing...

Erik Kastner kastner

🕳️
actively choosing...
View GitHub Profile
################################################################################
#
# Copyright 1993-2006 NVIDIA Corporation. All rights reserved.
#
# NOTICE TO USER:
#
# This source code is subject to NVIDIA ownership rights under U.S. and
# international Copyright laws.
#
# NVIDIA MAKES NO REPRESENTATION ABOUT THE SUITABILITY OF THIS SOURCE
@textarcana
textarcana / post-commit.bat
Created September 16, 2009 21:43
SVN Backup Post-Commit Hook
rem incremental backup for SVN
rem copies each commit to a network drive, as it happens
svnadmin dump --incremental -r %2 %1 > c:\repository\backup_system\dumpfiles\rev%2
cksum c:\repository\backup_system\dumpfiles\rev%2 > c:\repository\backup_system\dumpfiles\rev%2.sum
rem this strategy only works if you set up the Subversion Windows service,
rem to run with your credentials or admin credentials.
rem For details, see the great article on CodingHorror.com
@defunkt
defunkt / browser
Created March 1, 2010 10:01
pipe html to a browser
#!/bin/sh -e
#
# Usage: browser
# pipe html to a browser
# e.g.
# $ echo '<h1>hi mom!</h1>' | browser
# $ ron -5 man/rip.5.ron | browser
if [ -t 0 ]; then
if [ -n "$1" ]; then
@mnutt
mnutt / Instrument Anything in Rails 3.md
Created September 6, 2010 06:50
How to use Rails 3.0's new notification system to inject custom log events

Instrument Anything in Rails 3

With Rails 3.0 released a few weeks ago I've migrated a few apps and I'm constantly finding useful new improvements. One such improvement is the ability to log anything in the same way that Rails internally logs ActiveRecord and ActionView. By default Rails 3 logs look slightly spiffier than those produced by Rails 2.3: (notice the second line has been cleaned up)

Started GET "/" for 127.0.0.1 at Mon Sep 06 01:07:11 -0400 2010
  Processing by HomeController#index as HTML
  User Load (0.2ms)  SELECT `users`.* FROM `users` WHERE (`users`.`id` = 3) LIMIT 1
  CACHE (0.0ms)  SELECT `users`.* FROM `users` WHERE (`users`.`id` = 3) LIMIT 1

Rendered layouts/_nav.html.erb (363.4ms)

diff -ru a/webapp/content/js/composer_widgets.js b/webapp/content/js/composer_widgets.js
--- a/webapp/content/js/composer_widgets.js 2010-02-26 16:12:54.000000000 +0000
+++ b/webapp/content/js/composer_widgets.js 2010-09-15 07:03:56.000000000 +0000
@@ -531,6 +531,7 @@
{text: 'Line Width', handler: this.applyFuncToEachWithInput('lineWidth', 'Please enter a line width for this graph target')},
{text: 'Dashed Line', handler: this.applyFuncToEach('dashed')},
{text: 'Keep Last Value', handler: this.applyFuncToEach('keepLastValue')},
+ {text: 'Fill Value', handler: this.applyFuncToEachWithInput('fillValue', 'Please enter a value to fill. Leave blank for 0', true)},
{text: 'Substring', handler: this.applyFuncToEachWithInput('substr', 'Enter a starting position')}
]
#!/bin/bash
GIT_WORK_TREE=/tmp/dep
GIT_DIR=/home/ekastner/deployinator/.git
user_map_program=/tmp/usermap.sh
# if you need to test just a range of commits to debug
# for i in `git log --format=%h 83f7fec..265f9a7 | tac`
<!DOCTYPE HTML>
<html>
<head>
<!-- adapted from: http://iamchenghan.wordpress.com/2010/06/01/html5-canvas-jquery-cubic-bezier-drawing-tool/ -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>HTML5 Canvas, jQuery Cubic Bezier Drawing Tool</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
var canvas, context, ctrlpts = new Array();
$(function() {
@kentbrew
kentbrew / favicon-interceptor.js
Created January 3, 2011 19:32
How to short-circuit those annoying favicon requests in node.js
// early experiments with node had mysterious double requests
// turned out these were for the stoopid favicon
// here's how to short-circuit those requests
// and stop seeing 404 errors in your client console
var http = require('http');
http.createServer(function (q, r) {
// control for favicon
@cowboyd
cowboyd / allruby.rb
Created January 17, 2011 19:36
Proof of concept for making all ruby available to javascript.
require 'v8'
require 'openssl'
class Module
def [](name)
self.const_get(name)
end
end
@kastner
kastner / numberish.rb
Created January 27, 2011 18:01
numberish.rb
class Numberish
def self.convert(input)
if input.to_i > 0 && input.to_i.to_s == input
return input.to_i
else
return input
end
end
end