Skip to content

Instantly share code, notes, and snippets.

@sathish316
sathish316 / ycombinator.ss
Created Jan 23, 2012
Y combinator (Little Schemer)
View ycombinator.ss
; function to find the length of a list
(define length
(lambda (l)
(cond
((null? l) 0)
(else (+ 1 (length (cdr l)))))))
; function that recurs infinitely
(define eternity
(lambda (l)
@sathish316
sathish316 / ai-class.py
Created Dec 7, 2011 — forked from sumodx/ai-class.py
Download lecture videos of ai-class, with basic resume support
View ai-class.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = "Deepak.G.R."
__credits__ = "Sumod Hajela"
__license__ = 'Public Domain'
"""
usage:
Go to command line and type
View .gitconfig
[alias]
st = status
ci = commit
br = branch
co = checkout
df = diff
lg = log -p
rpull = pull --rebase
[user]
name = Sathish
View emacscheatsheet
emacs shortcuts
C-x C-c quit
C-v next screen
M-v previous screen
C-l move cursor to center
C-f forward char
C-b backward char
C-p previous line
C-n next line
View gist:722109
class Array
def car
first
end
def cdr
self[1..-1]
end
def method_missing(method_id)
@sathish316
sathish316 / guess_my_number
Created Nov 29, 2010
Binary search guessing game from Land of Lisp book
View guess_my_number
(defparameter *small* 1)
(defparameter *big* 100)
(defun guess-my-number ()
(ash (+ *small* *big*) -1))
(defun smaller ()
(setf *big* (1- (guess-my-number)))
(guess-my-number))
@sathish316
sathish316 / oneplus.scala
Last active Sep 20, 2015
Generate email ids for oneplus registration based on an amazon review (http://www.amazon.in/review/REA7WFX7PV3KO)
View oneplus.scala
object OnePlus {
def main(args: Array[String]) {
generate_aliases("typeyouremailhere@gmail.com").foreach(println)
}
def generate_aliases(email:String) = {
val email_pattern = """(\w+)@([\w\.]+)""".r
email match {
case email_pattern(address, domain) => {
interleave_all_with(address, '.').map {case address => s"$address@$domain"}
@sathish316
sathish316 / snakes_and_ladders.ex
Last active Sep 14, 2015
Snakes and Ladder - Elixir Game server
View snakes_and_ladders.ex
defmodule GameServer do
use GenServer
def start do
initial_state = {:players, [], :positions, Map.new, :snakes_and_ladders, [
{:ladder, 5, 15}, {:ladder, 10, 22}, {:ladder, 25, 45}, {:snake, 35, 15}, {:snake, 65, 55}]}
GenServer.start_link(__MODULE__, initial_state, name: __MODULE__)
end
def join(player), do: GenServer.cast(__MODULE__, {:join, player})
View init-scala.sh
#!/bin/bash
PROJECT_NAME="$1"
SCALA_VERSION="2.10.3"
SCALATEST_VERSION="2.2.1"
MOCKITO_VERSION="1.8.5"
mkdir $PROJECT_NAME
cd $PROJECT_NAME