Skip to content

Instantly share code, notes, and snippets.

View ignacy's full-sized avatar
🦆
duck typing

Ignacy Moryc ignacy

🦆
duck typing
View GitHub Profile
{-# OPTIONS_GHC -Wall #-}
module LogAnalysis where
import Log
import Data.List (sortBy, isInfixOf)
parseMessage :: String -> MaybeLogMessage
parseMessage m = case lineHead of
"I" -> ValidLM (infoMessage lineRest)
"E" -> ValidLM (errorMessage lineRest)
"W" -> ValidLM (warnMessage lineRest)
@ignacy
ignacy / towersOfHanoi.hs
Created May 24, 2015 16:49
Towers of Hanoi in haskell
module TowersOfHanoi where
type Peg = String
type Move = (Peg, Peg)
hanoi :: Integer -> Peg -> Peg -> Peg -> [Move]
hanoi 0 _ _ _ = []
hanoi n a b c = (hanoi (n - 1) a c b) ++ [(a, b)] ++ (hanoi (n - 1) c b a)
@ignacy
ignacy / cc_validate.hs
Created May 24, 2015 16:30
Validate CC checksum
{-
Validate CC's checksum
-}
module HW01 where
lastDigit :: Integer -> Integer
lastDigit x = x `mod` 10
dropLastDigit :: Integer -> Integer
(defvar evil-packages '(evil evil-leader evil-surround evil-nerd-commenter evil-matchit))
(dolist (p evil-packages)
(when (not (package-installed-p p))
(package-install p)))
(require 'evil-leader)
(global-evil-leader-mode)
(evil-leader/set-leader ",")
#jruby hacks
jps -ml #show java processes running
jstack <pid> #get a jvm stack info
jruby -J-Djruby.reify.classes=true # a flag that tell jruby to compile ruby classes to real (matching) java classes
jvisualvm #great profiling tool
@ignacy
ignacy / app.rb
Last active August 29, 2015 14:13
# Test server for file upload in sinatra.
require 'sinatra'
post '/save_file' do
filename = params[:file][:filename]
file = params[:file][:tempfile]
File.open("./public/#{filename}", 'wb') do |f|
f.write(file.read)
### Keybase proof
I hereby claim:
* I am ignacy on github.
* I am ignacy (https://keybase.io/ignacy) on keybase.
* I have a public key whose fingerprint is 6333 D268 BC8D 4730 9367 5FF0 4567 A8C2 B0A3 5B16
To claim this, I am signing this object:
(require 'ido)
(defvar ebot-default-process-name "zsh"
"*Default name for the buffer to which we send the commands.*")
(defun ebot-line ()
(number-to-string (count-lines 1 (point))))
(defun ebot-file-name-and-position ()
(concat buffer-file-name ":" (ebot-line)))
(defun rails-api (query)
"search rails api"
(interactive
(list (read-from-minibuffer "Method/Class: "
(smart-symbol-at-pt 'beginning) nil nil nil)))
(browse-url (concat "http://apidock.com/rails/search?query=" query)))
@ignacy
ignacy / pr.md
Created May 13, 2013 08:45 — forked from piscisaureus/pr.md

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this: