Skip to content

Instantly share code, notes, and snippets.

ifesdjeen / gist:1058853
Last active Sep 26, 2015
Zen and art of motorcycle maintenance quotes
View gist:1058853
I have kicked myself mentally a hundred times for that stupidity and don't think I'll ever really, finally get
over it. Evidently what I saw sloshing around was gas in the reserve tank which I had never turned on. I didn't
check it carefully because I assumed the rain had caused the engine failure. I didn't understand then how foolish
quick assumptions like that are. Now we are on a twenty-eight-horse machine and I take the maintenance of it very
I found the cause of the seizures a few weeks later, waiting to happen again. It was a little twenty-five-cent
pin in the internal oil-delivery system that had been sheared and was preventing oil from reaching the head at
high speeds.
ifesdjeen / gist:1240416
Created Sep 25, 2011
export your custom dictionary to iknow
View gist:1240416
# -*- coding: utf-8 -*-
require 'rubygems'
require 'capybara'
require 'capybara/dsl'
Capybara.run_server = false
Capybara.default_driver = :selenium
Capybara.app_host = ''
ifesdjeen / meta.rb
Created May 6, 2012
metaprogramming magic
View meta.rb
module SafeConstDefinition
extend ActiveSupport::Concern
module ClassMethods
def const_missing(name)
puts "Warning: #{name} was not defined, assuming further definition. Keep calm tho."
# Since Parent is defined after Child both in root and in SomeModule,
# i need to have a mechanism to define a future const, but simple:
ifesdjeen /
Created May 12, 2012
Capistrano deployment
export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
ifesdjeen / wrap_fn.clj
Created May 22, 2012
Wrapping functions in Clojure
View wrap_fn.clj
(defn wrap-fn
"Wrap or replace some function with your own function"
[qualifier wrapper]
(fn [original-fn]
(fn [& caller-arguments]
(wrapper caller-arguments original-fn)))))
;; Replace your function implementation:
HOST = # masked
USERNAME = ifesdjeen
createTunnel() {
/usr/bin/ssh -f -N -L$SOURCE_PORT:$HOST:$DESTINATION_PORT -L19922:HOST:22 ifesdjeen@$HOST
if [[ $? -eq 0 ]]; then
echo Tunnel to $HOST created successfully
ifesdjeen / global_catch_exception.clj
Created Jun 26, 2012
Global Exception catching
View global_catch_exception.clj
;; That will actually catch exception within inner thread, too. And within inner thread of inner thread. Etc.
(Thread/setDefaultUncaughtExceptionHandler (proxy [Thread$UncaughtExceptionHandler] []
(uncaughtException [t e]
;; Your fancy Exception logging here
(println "Throwable: " + (.getMessage e))
(println (.toString t)))))
(.start (Thread. (cast Runnable
(fn []
ifesdjeen / get_in.rb
Created Aug 14, 2012
Clojure get_in in ruby
View get_in.rb
# Returns value from hash based on the path
# @param hash [Hash] - hash to retrieve values from
# @param path [Array] - non-empty array representing recursive path
# @returns [Object] - an object located within an array on the given path
# Examples:
# get_in({:a => {:b => {:c => 2}}}, [:a, :b, :c]) # => 2
View reflection_warnings_with_thrush_operator.clj
(ns clojurewerkz.cassaforte.thrift.column
(:use [ :only [to-byte-buffer]]
[clojurewerkz.cassaforte.bytes :only [encode]])
(:import [org.apache.cassandra.thrift Column]))
(defn ^Column build-column
"Converts clojure map to column"
([^String key ^String value]
(build-column to-byte-buffer key value (System/currentTimeMillis)))
ifesdjeen / shunting_yard.clj
Created Nov 25, 2012
Check wether it's easier or harder to read the code that way
View shunting_yard.clj
;; Leaving defaccumulator/defcompound details aside, when you see following lines, is it clear what's going on?
;; Or is it easier to read a straightforward loop, without dispatcher-based magic?
;; As for me, advantage is that rules are completely decouple from each other. It's very easy to understand and
;; debug parts of the processing, rather than try to figure out how the complete algorithm works at once.
;; When reading algorithm description, you see clear definition of steps and rules, although when you see
;; the implementation it's all combined into one humongous function, that's doing everything, and dispatch rules
;; are wowed, which makes it even more complex.