Skip to content

Instantly share code, notes, and snippets.

" 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
@gmarik
gmarik / game_of_life.rb
Created March 19, 2012 17:02
Conway's Game of life
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) }
# 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 / gcombo.rb
Created May 13, 2012 03:26
group combinations
# 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
@gmarik
gmarik / error_handling.md
Created August 17, 2012 17:34
Error handling

#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 / makeapp.sh
Created August 26, 2012 22:50 — forked from demonbane/makeapp.sh
Create a Fluid-style app launcher for single-window Chrome instances on OSX
#!/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
package main
import (
"bufio"
"fmt"
"net"
)
type Client struct {
incoming chan string
@gmarik
gmarik / analyze.go
Created November 12, 2015 19:26 — forked from nf/analyze.go
'spent' script to log where time is spent
package main
import (
"bufio"
"fmt"
"os"
"regexp"
"sort"
"strconv"
"strings"
@gmarik
gmarik / Dockerfile
Created September 29, 2019 06:37 — forked from Irio/Dockerfile
GCP Serverless scrapers
FROM golang:1.12 as build
WORKDIR $GOPATH/src/github.com/Irio/wohnung
COPY scraper scraper
COPY main.go .
RUN go get -d -v ./...
RUN go install
FROM gcr.io/distroless/base
@gmarik
gmarik / google-apps-script.md
Last active June 23, 2020 05:56 — forked from labnol/google-apps-script.md
How to Learn Google Apps Script - The best resources for learning Google Apps Script, the glue that connects GSuite services including Gmail, Google Drive, Calendar, Maps, Analytics and more.

Learning Google Apps Script

The best place to learn more about Google Script is the official documentation available at developers.google.com. Here are other places that will help you get up to speed.

  1. MAKING A GMAIL BOT WITH APPS SCRIPT AND TYPESCRIPT
  2. Google Apps Scripts - Snippets by +Amit Agarwal
  3. Apps Script Starter - Create Google Apps Script projects locally inside VS Code.
  4. Digital Inspiration by +Amit Agarwal - Google Addons
  5. Awesome Google Scripts by +Amit Agarwal
  6. Build with Google Apps Script - Setup a local development environment for Apps Script