This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d=[-1,0,1] n=->(w,i,j){(d.product(d)-[[0,0]]).map{|x,y|w[[i+x,j+y]]}.count(true)} t=->(w){Hash[w.map{|k,v|c=n.(w,*k);[k,(v&&c==2)||c==3]}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def s(e) | |
c=e.scan(/\w{1}/).uniq | |
d=('0'..'9').to_a | |
d.permutation(c.size).each{|p|o=c.zip(p).inject(e){|e,d|e.gsub(*d)};return o if o !~/\b0/ && eval(o)} | |
end | |
puts s("SEND + MORE == MONEY") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
__author__ = "Deepak.G.R." | |
__credits__ = "Sumod Hajela" | |
__license__ = 'Public Domain' | |
""" | |
usage: | |
Go to command line and type |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[alias] | |
st = status | |
ci = commit | |
br = branch | |
co = checkout | |
df = diff | |
lg = log -p | |
rpull = pull --rebase | |
[user] | |
name = Sathish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
def car | |
first | |
end | |
def cdr | |
self[1..-1] | |
end | |
def method_missing(method_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}) |