This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Base | |
def self.method_added(name) | |
if /hook/.match(name.to_s) or method_defined?("#{name}_without_hook") | |
return | |
end | |
hook = "def #{name}_hook\n p 'Method #{name} has been called'\n #{name}_without_hook\nend" | |
self.class_eval(hook) | |
a1 = "alias #{name}_without_hook #{name}" | |
self.class_eval(a1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(tuple_util). | |
-export([is_element_of_tuple/2]). | |
is_element_of_tuple(Tuple, Element) -> | |
lists:member(Element, tuple_to_list(Tuple)). | |
% or like this: | |
is_element_of_tuple(E, Tuple) -> | |
is_element_of_tuple(E, Tuple, 1, tuple_size(Tuple)). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% concat, binary | |
B1= <<1,2>>. | |
B2= <<3,4>>. | |
B3= <<B1/binary, B2/binary>>. | |
% <<1,2,3,4>> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for_each_line_in_file(Name, Proc, Mode, Accum0) -> | |
{ok, Device} = file:open(Name, Mode), | |
for_each_line(Device, Proc, Accum0). | |
for_each_line(Device, Proc, Accum) -> | |
case io:get_line(Device, "") of | |
eof -> file:close(Device), Accum; | |
Line -> NewAccum = Proc(Line, Accum), | |
for_each_line(Device, Proc, NewAccum) | |
end. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns oceanus.anduin.clj.consumer | |
(:gen-class) | |
(:import [kafka.consumer ConsumerConfig Consumer KafkaStream] | |
[kafka.javaapi.consumer ConsumerConnector] | |
[java.util Properties])) | |
(defn make-props | |
"convert a clojure map into a Properties object." | |
[m] | |
(let [props (Properties.)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns storm.starter.clj.word-count2 | |
(:import [backtype.storm StormSubmitter LocalCluster]) | |
(:use [backtype.storm clojure config log]) | |
(:gen-class)) | |
(def id-count (atom 0)) ;; tuple counter for debugging -- something to make ids out of | |
(defspout sentence-spout ["sentence"] | |
[conf context collector] | |
(let [sentences ["a little brown dog" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Find and then delete all files under current directory (.) that: | |
# 1. contains cmake (case-&insensitive) in it's path (wholename) | |
# 2. name is not CMakeLists.txt | |
find . -iwholename '*cmake*' -not -name CMakeLists.txt -delete |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set pastetoggle=<F3> | |
set nu | |
"""""""""""""""""c/cpp/cu settings"""""""""""""""""""""""""""""""""" | |
" check cpp code applying c++11 standard | |
let g:syntastic_cpp_compiler = 'clang++' | |
let g:syntastic_cpp_compiler_options = '-std=c++14 -stdlib=libc++' | |
" on some system: | |
" let g:syntastic_cpp_compiler = 'g++' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# System-wide crontab file and cron job directory. Change these for your system. | |
CRONTAB='/etc/crontab' | |
CRONDIR='/etc/cron.d' | |
# Single tab character. Annoyingly necessary. | |
tab=$(echo -en "\t") | |
# Given a stream of crontab lines, exclude non-cron job lines, replace |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--colors=line:fg:yellow | |
--colors=line:style:bold | |
--colors=path:fg:green | |
--colors=path:style:bold | |
--colors=match:fg:black | |
--colors=match:bg:yellow | |
--colors=match:style:nobold | |
--smart-case |
OlderNewer