Skip to content

Instantly share code, notes, and snippets.

@samertm
samertm / main.go
Created July 19, 2015 02:51
Surprising behavior for value types with pointer methods.
package main
import "fmt"
type T struct {
Thing string
}
func (t *T) Set(thing string) {
t.Thing = thing
@samertm
samertm / woodo
Last active August 29, 2015 14:10 — forked from ryanzabcik/woodo
if [ $EUID != 0 ]; then
echo "It's a weird tree."
else
echo ' _ __'
echo ' / `\ (~._ ./ )'
echo ' \__/ __`-_\__/ ./'
echo ' _ \ \/ \ \ |_ __'
echo ' ( ) \__/ -^ \ / \'
echo ' \_/ " \ | o o |.. / __'
echo " \\. --' ==== / || / \\ "
@samertm
samertm / .emacs
Last active March 31, 2019 16:21
Tricking Out Emacs for Go
;; from https://www.youtube.com/watch?v=r6j2W5DZRtA
;; get the following packages ("M-x package-list-packages"):
;; go-mode
;; go-eldoc
;; company-mode
;; company-go
;; get the following go programs (run each line in your shell):
;; go get golang.org/x/tools/cmd/godoc
;; go get golang.org/x/tools/cmd/goimports
;; go get github.com/rogpeppe/godef
@samertm
samertm / radiohead_essay.txt
Last active August 29, 2015 13:56
Radiohead Mini-essay (long version)
This might seem silly, but one of my favorite activities is analyzing my
musical taste and my favorite bands.
Radiohead is one of my absolute favorite bands, and I've been listening to them
since I was a Freshman in high school. Radiohead has an interesting record as a
rock band. They started out as a lite-grunge outfit, developed a more mature
style and released an album at their height that combined the noises of
Kraftwerk with their alternative rock roots. Then, as they were being hailed as
the saviors of rock, they shocked the world by releasing two electronica
albums. They returned to a guitar-based sound for their next two albums, and
@samertm
samertm / classes.el
Created February 20, 2014 21:35
Merge Sort in Elisp
;; Sort set of courses in decreasing order (latest date first)
;; Easiest way to evaluate: paste the code in an emacs buffer. Change the mode
;; to lisp-interaction-mode. Go to the end of "setq courses" and type C-x C-e
;; (eval-last-sexp), go to the end of "defun course-sort" and type C-x C-e,
;; and then go to the end of "course-sort courses" and type C-j. The sorted
;; list will print out below the command inside the buffer.
(setq courses '("16 Oct 2013 - Circuits 1: https://www.edx.org/course/mitx/mitx-6-002x-circuits-electronics-1130"
"7 Oct 2013 - 3d Graphics: https://www.edx.org/course/uc-berkeleyx/uc-berkeleyx-cs-184-1x-foundations-1003"
"7 Jan 2014 - Principles of Econ: https://www.edx.org/course/caltechx/caltechx-ec1011x-principles-economics-1286"
@samertm
samertm / users.ejs
Created February 2, 2012 01:27
trimph users
<html class="no-js">
<head>
<title>Users</title>
<link rel="stylesheet" type="text/css" href="stylesheets/base.css">
<link rel="stylesheet" type="text/css" href="stylesheets/home.css">
<link type="image/png" rel="SHORTCUT ICON" href="images/trophy.png">
<link href='http://fonts.googleapis.com/css?family=Ubuntu' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Bitter:700' rel='stylesheet' type='text/css'>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/modernizr/2.0.6/modernizr.min.js"></script>
@samertm
samertm / app.js
Created February 2, 2012 01:25
triumph app.js
/**
* Module dependencies.
*/
var express = require('express') // imports express
, routes = require('./routes') // imports routes
, mongoose = require('mongoose') // imports mongoose
, crypto = require('crypto') // imports crypto
@samertm
samertm / sqrt.scm
Created December 25, 2011 01:49
Square root in scheme
(define (sqrt x)
(define (average lhs rhs)
(/ (+ lhs rhs) 2))
(define (good-enough? guess)
(< (abs (- (square guess) x)) .0001))
(define (improve guess)
(average guess (/ x guess)))
(define (try guess)
(if (good-enough? guess)
guess