Skip to content

Instantly share code, notes, and snippets.

@blakesmith
blakesmith / gist:3051547
Created July 5, 2012 05:27
Go Tour: Exercise: Exercise: Slices - My solution
package main
import "code.google.com/p/go-tour/pic"
func imageFun(x, y int) uint8 {
return uint8(x) ^ uint8(y)
}
func Pic(dx, dy int) [][]uint8 {
image := make([][]uint8, dx)
@blakesmith
blakesmith / gist:3049269
Created July 4, 2012 20:04
Go Tour: Exercise: Exercise: Maps - My solution
package main
import (
"code.google.com/p/go-tour/wc"
"strings"
)
func WordCount(s string) map[string]int {
counts := make(map[string]int)
splitStrings := strings.Split(s, " ")
@blakesmith
blakesmith / gist:3049248
Created July 4, 2012 19:55
Go Tour: Exercise: Loops and Functions - My solution
package main
import (
"fmt"
"math"
)
func newtAppx(x float64, appx float64) float64 {
return appx - ((math.Pow(appx, 2.0) - x) / (2 * appx))
}
@blakesmith
blakesmith / fr.sh
Created April 24, 2012 15:46
Rails global find/replace
export search="Find string"
export replace="Replace string"
grep -l -R $search app spec lib | xargs sed -i -e "s/$search/$replace/g"
find . -name "*-e" | xargs rm
@blakesmith
blakesmith / lein.clj
Created April 23, 2012 21:05
Leiningen install crate
(ns pallet.crate.lein
(:require [pallet.action.remote-file :as remote-file]))
(def default-install-path "/usr/local/bin")
(def script-url "https://raw.github.com/technomancy/leiningen/stable/bin/lein")
(defn- install-script
[session install-path]
(-> session
(remote-file/remote-file
(def cassandra-conf "conf/cassandra/cassandra.yaml")
(def cassandra-yaml-defaults
{:cluster-name "My Cluster"
:initial-token "0"
:partitioner :random
:data-file-directories ["/var/lib/cassandra/data"]
:commit-log-dir "/var/lib/cassandra/commitlog"
:saved-caches-dir "/var/lib/cassandra/saved_caches"
:seeds ["127.0.0.1"]
09:25:54.391 [clojure-agent-send-off-pool-0] INFO pallet.execute - Output: 192.168.56.106
- retrieves files from the web
i whiptail - Displays user-friendly dialog boxes from s
i whois - an intelligent whois client
i A x-ttcidfont-conf - TrueType and CID fonts configuration for X
i A x11-common - X Window System (X.Org) infrastructure
i A x11proto-core-dev - X11 core wire protocol and auxiliary heade
i A x11proto-input-dev - X11 Input extension wire protocol
i A x11proto-kb-dev - X11 XKB extension wire protocol
i A xauth - X authentication utility
remote-file tmp-dir/nginx-0.7.65.tar.gz...
md5sum: tmp-dir/nginx-0.7.65.tar.gz: No such file or directory
tmp-dir/nginx-0.7.65.tar.gz.new: No such file or directory
mv: cannot stat `tmp-dir/nginx-0.7.65.tar.gz.new': No such file or directory
mv: cannot stat `tmp-dir/nginx-0.7.65.tar.gz.new': No such file or directory
require 'rubygems'
require 'wirble'
#require 'interactive_editor'
Wirble.init
Wirble.colorize
if ENV.include?('RAILS_ENV') && !Object.const_defined?('RAILS_DEFAULT_LOGGER')
require 'logger'
RAILS_DEFAULT_LOGGER = Logger.new(STDOUT)
end
user@192.168.56.105's password:
Linux ubuntu 2.6.35-22-server #35-Ubuntu SMP Sat Oct 16 22:02:33 UTC 2010 x86_64 GNU/Linux
Ubuntu 10.10
Welcome to the Ubuntu Server!
* Documentation: http://www.ubuntu.com/server/doc
System information as of Sat Mar 31 10:59:28 PDT 2012
System load: 0.0 Processes: 71