Skip to content

Instantly share code, notes, and snippets.

require 'set'
file = File.new("data")
storage = Hash.new {}
file.each_line do |line|
date, key, value = line.split(';')
storage[date][key] = value
end
@zarkzork
zarkzork / gist:1208164
Created September 10, 2011 10:05
aliases for diffing list of files before commit
alias last_change='git diff $(git status | sed -ne "/Changed/,/Untrack/ p" | grep modified | cut -d: -f2 | head -1)'
alias add_last_change='git add $(git status | sed -ne "/Changed/,/Untrack/ p" | grep modified | cut -d: -f2 | head -1)'
alias edit_last_change='$EDITOR $(git status | sed -ne "/Changed/,/Untrack/ p" | grep modified | cut -d: -f2 | head -1)'
(start-process "ls" nil "ls")
(defun keep-output (process output)
(setq kept (cons output kept)))
(setq kept nil)
(set-process-filter (get-process "ls") 'keep-output)
class Server
def parse_command
line = $stdin.readline.chomp
command, arguments = line.split(' ', 2)
if commands.include?(command)
self.send(command, arguments)
else
@zarkzork
zarkzork / gist:3332000
Created August 12, 2012 14:04
some shit
(defun next-same-indentation ()
(interactive)
(let ((target-indentation (current-indentation)))
(while (progn
(next-line)
(/= target-indentation (current-indentation))))))
(defun previous-same-indentation ()
(interactive)
@zarkzork
zarkzork / search.hs
Last active December 17, 2015 15:59
simple haskell indexed search for files.
import Data.List
import Data.Map
import System.Environment
import Control.Monad
import System.IO
-- returns triagrams for given string
splitIntoTrigrams :: String -> [String]
splitIntoTrigrams (a : b : c : ls) = (a : b : c : []) : splitIntoTrigrams (b : c : ls)
splitIntoTrigrams (b : c : []) = []
@zarkzork
zarkzork / search.rb
Created May 23, 2013 11:04
Simple file search in Ruby
class String
def triads()
string = self.clone
Enumerator.new do |y|
while string.size > 2
y << string.slice(0, 3)
string.slice!(0)
end
end
end
@zarkzork
zarkzork / main.rb
Created February 22, 2014 14:25
single pass converter semi-automatic converter from erb to dust
require 'strscan'
# single pass converter semi-automatic converter from erb to dust
input_stream = $stdin.read
# Class to parse ruby line and detect its type, filling symbol table
# with references.
class RubyLine
@zarkzork
zarkzork / gist:f4f4c30f5f6009697e53
Created December 1, 2014 09:41
sample schema for typtypio
(* schema *)
module type Schema = sig
type t
end
module Schema = struct
type t
type value_type =
### Keybase proof
I hereby claim:
* I am zarkzork on github.
* I am zarkzork (https://keybase.io/zarkzork) on keybase.
* I have a public key whose fingerprint is 5E00 F5A2 F97F 8682 856C 8800 9D18 BF0C 7B3B FBE2
To claim this, I am signing this object: