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
@ignacy
ignacy / gist:811945
Created February 4, 2011 22:53
color-theme-im3.el
(defun colot-theme-im3 ()
(interactive)
(color-theme-install
'(color-theme-im3
((background-color . "#0f141a")
(background-mode . light)
(border-color . "#0f0d26")
(cursor-color . "#1016f9")
(foreground-color . "#ffffff")
(mouse-color . "black"))
@ignacy
ignacy / jrubytest.rb
Created April 6, 2011 17:38
Test java code with jruby
import org.example.Person
class PersonTests < Test::Unit::TestCase
def setup
@person = Person.new("Jan", "Kowalski")
end
def test_person_getter_although_we_shouldnt
assert_match /Kowalski/, @person.getSurname
end
@ignacy
ignacy / git-minutes.rb
Created May 15, 2011 10:19
Get git commit timmings
require 'time'
data = `git log | grep "^Date"`.split($/).
map { |line| Time.parse(line.split(' ')[4]) }.
group_by { |x| x.hour }
data.each { |k, v| data[k] = data[k].size }
total_commits = data.values.inject(0) { |sum, x| sum += x }
data = data.sort { |a, b| a[0] <=> b[0] }
@ignacy
ignacy / .Xdefaults
Created June 10, 2011 06:59
Setting 256 colors and other basic options for xterm
! ~/.Xdefaults - for X11/Cygwin running xterm
XTerm*termName: xterm-256color
xterm*scrollBar: false
xterm*vt100.scrollBar: false
xterm*vt100.font: Inconsolata-11
xterm*background: black
xterm*foreground: white
xterm*multiScroll: on
xterm*jumpScroll: on
private void handleStreamPlayback(RegisterAccess register) {
XletLogger.log("Handle stream playback");
discNavigator = new ProgresivePlaylistNavigator(this);
discNavigator.init();
guiContainer.setVisible(true);
guiContainer.requestFocus();
guiContainer.repaint();
int state = register.getGPR(0);
@ignacy
ignacy / gettersetter.yasnippet
Created October 3, 2011 09:35
yasnippet getter/setter method for java
# -*- mode: snippet -*-
# contributor: Ignacy Moryc <[email protected]>
# name: getAset
# key: gs
# --
private void set$1($1 ${1:$(downcase text)})) {
this.${1:$(downcase text)} = ${1:$(downcase text)};
}
@ignacy
ignacy / gist:1327470
Created October 31, 2011 13:18
poor man's autotest
while true; do spec spec/models/suggestion_spec.rb; sleep 5; done
@ignacy
ignacy / reek.el
Created February 4, 2012 19:34
reek on a buffer
(defun im/reek-on-buffer()
"Run reek on current buffer"
(interactive)
(get-buffer-create "reekOut")
(shell-command-on-region (point-min) (point-max) "reek"
;; output buffer
"reekOut" nil
"*reekErrors*" nil)
(split-window-horizontally)
(other-window 0)
(define (average a b)
(/ (+ a b) 2))
(define (close-enough? x y)
(< (abs (- x y)) 0.01))
(define (search f neg-point pos-point)
(let ((midpoint (average neg-point pos-point)))
(if (close-enough? neg-point pos-point)
midpoint
(defun welcome-page-handler (httpcon)
(elnode-http-start httpcon "200" '("Content-type" . "text/html"))
(elnode-http-return httpcon "<html><body><h1>Hello there!!</h1></body></html>"))
(elnode-start 'welcome-page-handler :port 8010 :host "localhost")