Skip to content

Instantly share code, notes, and snippets.

View cbilson's full-sized avatar

Chris Bilson cbilson

View GitHub Profile
@cbilson
cbilson / gist:5910672
Created July 2, 2013 16:09
Getting aspell working on windows
(add-to-list 'exec-path "C:\\Program Files (x86)\\Aspell\\bin")
(setq ispell-program-name "aspell.exe")
(setq ispell-aspell-data-dir "C:\\Program Files (x86)\\Aspell\\data")
(setq ispell-aspell-dict-dir "C:\\Program Files (x86)\\Aspell\\dict")
(add-to-list 'ispell-local-dictionary-alist '("en_US" "[[:alpha:]]" "[^[:alpha:]]" "[']" nil
("-B")
nil iso-8859-1))
(setq ispell-personal-dictionary "C:/Users/bilsonc/.ispell")
(require 'ispell)
@cbilson
cbilson / nrepl-repeat-interactive-eval.el
Created May 24, 2013 15:24
Sometimes I want to repeat the last eval when I have moved on to another location. Maybe there is a better way to do this, but I wanted to try using advice (1st time.)
(defvar *nrepl-last-eval-form* nil)
(defadvice nrepl-interactive-eval (after nrepl-remember-last-expression-eval (&optional form))
"Save the last expression evaluated so we can run it again later if we want."
(setq *nrepl-last-eval-form* form))
(ad-activate 'nrepl-interactive-eval)
(defun nrepl-repeat-interactive-eval ()
public static class MyExperiment
{
public static void RegularMethod()
{
DoSomethingAsync();
Console.WriteLine("after starting async stuff");
Thread.Sleep(15000);
}
public async static void DoSomethingAsync()
@cbilson
cbilson / is-bom-file.ps1
Created August 10, 2012 22:07
BOM detector
function Is-BOM-File ($filename) {
$bytes = Get-Content -Encoding byte -TotalCount 4 $filename
$encoding = [Text.Encoding]::GetEncodings() `
| ForEach { $_.GetEncoding() } `
| Where-Object { -not $_.IsSingleByte } `
| Where-Object {
$preamble = $_.GetPreamble()
For ($i = 0; $i -lt $preamble.Length; $i++) {
if ($bytes[$i] -ne $preamble[$i]) {
return $false
@cbilson
cbilson / core.clj
Created April 27, 2012 13:38
My solution to Google Code Jam problem #3
(ns RecycledNumbers.core)
;; This is the version I _wish_ I had submitted. It took about 1 minute to
;; add a single high level pmap (see comment below) and I would have completed
;; the problem in time.
;; Luckily, I qualified anyway, so maybe this lesson will come in handy in tonight's
;; competition.
(defn cycles [n]
@cbilson
cbilson / hack.sh
Created April 5, 2012 09:51 — forked from makevoid/hack.sh
OSX For Hackers
#!/usr/bin/env sh
echo "Use current directory as default search scope in Finder"
defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"
echo "Show Path bar in Finder"
defaults write com.apple.finder ShowPathbar -bool true
echo "Disable the Ping sidebar in iTunes"
defaults write com.apple.iTunes disablePingSidebar -bool true
using MyApp.Models, MyApp.Util, MyApp.Widgets, (ctx) =>
class MyApp.Reports
@request: (...) =>
# given MyApp.Util has an `ajaxRequest` method, for example
ctx.ajaxRequest ...
@cbilson
cbilson / test_helpers.clj
Created March 2, 2012 03:15
My lame roughly macro for clojure.test. Sucks? Rocks?
(ns model-trainer.test.helpers
(:use [model-trainer.math :only [msum mabs msubtract rvec matrix]]
[clojure.test])
(:import [cern.colt.matrix DoubleMatrix2D DoubleMatrix1D]))
;; usage
#_(deftest computing-activations
;; this tests computing activation for a layer in a multi-layer perceptron,
;; basically: multiply rvec by matrix and apply the sigmoid activation function to
;; constrain the values to the 0 to 1 range. The result should be the first vector.
@cbilson
cbilson / New-CurryAlias.ps1
Created February 8, 2012 18:31
A function that creates aliases with arguments curried in
function global:New-CurryAlias($name, $value) {
$wrapperFunctionName = "Invoke-Curried-$name"
$wrapperFunctionPath = "function:global:$wrapperFunctionName"
Set-Item -Force -Path $wrapperFunctionPath `
-Value "Invoke-Expression -Command '$value $args'"
New-Alias -Force -Name $name -Value $wrapperFunctionName
}
@cbilson
cbilson / Foo.ps1
Created October 24, 2011 18:45
Was going to do this to recompile all our coffee scripts when they change, but found a better way
task Start-Coffee-Watcher -Description "when a coffee file changes recompile - for testing" {
Start-Job -Name "CoffeeWatcher" -ArgumentList "$srcDir\WebRole\scripts" -ScriptBlock {
param($scriptsFolder)
Write-Host "Watching $scriptsFolder"
$recompile = {
# TODO: Figure out how to recompile coffee scripts from command line with SassAndCoffee