Skip to content

Instantly share code, notes, and snippets.

gmarik gmarik

Block or report user

Report or block gmarik

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@gmarik
gmarik / analyze.go
Created Nov 12, 2015 — forked from nf/analyze.go
'spent' script to log where time is spent
View analyze.go
package main
import (
"bufio"
"fmt"
"os"
"regexp"
"sort"
"strconv"
"strings"
View chat.go
package main
import (
"bufio"
"fmt"
"net"
)
type Client struct {
incoming chan string
@gmarik
gmarik / makeapp.sh
Created Aug 26, 2012 — forked from demonbane/makeapp.sh
Create a Fluid-style app launcher for single-window Chrome instances on OSX
View makeapp.sh
#!/bin/sh
echo "What should the Application be called (no spaces allowed e.g. GCal)?"
read inputline
name=$inputline
echo "What is the url (e.g. https://www.google.com/calendar/render)?"
read inputline
url=$inputline
View error_handling.md

#Clojure

wow, what a stack trace

$ time clj -e '(bar 1)'
Exception in thread "main" java.lang.RuntimeException: Unable to resolve symbol: bar in this context, compiling:(NO_SOURCE_PATH:1)
	at clojure.lang.Compiler.analyze(Compiler.java:6281)
	at clojure.lang.Compiler.analyze(Compiler.java:6223)
	at clojure.lang.Compiler$InvokeExpr.parse(Compiler.java:3497)
@gmarik
gmarik / gcombo.rb
Created May 13, 2012
group combinations
View gcombo.rb
# solution for problem 1.27 from https://sites.google.com/site/prologsite/prolog-problems/1
def gcombo(list, ns, acc, q = [], rest = list, qg = [])
if ns.sum != list.size && acc.empty?
raise ArgumentError, "Impossible to group #{list} into groups of #{ns} elements"
end
if ns.empty?
acc << qg
return
end
View combinations.rb
# get all combinations http://en.wikipedia.org/wiki/Combination
n = (ARGV[0] || 5).to_i
m = (ARGV[1] || 3).to_i
puts "#{n}/#{m}"
def comb(list, m, q, acc)
return if list.empty?
@gmarik
gmarik / game_of_life.rb
Created Mar 19, 2012
Conway's Game of life
View game_of_life.rb
require 'set'
cells = lambda do |world, (x, y)|
[
[-1,-1], [0, -1], [1, -1],
[-1, 0], [1, 0],
[-1, 1], [0, 1], [1, 1],
].map do |(dx, dy)|
[x+dx, y+dy]
end.partition { |_cell| world.include?(_cell) }
View Run_current_line.vim
" put this into your .vimrc
func! Run_current_line()
" get current line and run it as a system command
let content = system(getline('.'))
" open new window
silent pedit `=tempname()`
" change focus to the window
wincmd P
" append content
View composition_vs_inheritance.md

#include and #extend have same effect on instances as inheritance

Let's say we have this

module A; end
module B; end
class C; end
class D < C; end

Then we modify instance

@gmarik
gmarik / !README.md
Created Nov 21, 2011
Disable Gem deprecation spam
View !README.md

How to disable Gem deprecation warnings

Just copy content to corresponding files

You can’t perform that action at this time.