Skip to content

Instantly share code, notes, and snippets.

@genewoo
genewoo / webtail.py
Created August 19, 2012 00:49 — forked from maximebf/webtail.py
Web tail / tail -f as a webpage using websocket
#!/usr/bin/python
# Equivalent of "tail -f" as a webpage using websocket
# Usage: webtail.py PORT FILENAME
# Tested with tornado 2.1
# Thanks to Thomas Pelletier for it's great introduction to tornado+websocket
# http://thomas.pelletier.im/2010/08/websocket-tornado-redis/
import tornado.httpserver
@genewoo
genewoo / ruby_exceptions.rb
Created September 30, 2015 02:50
List all ruby exceptions (loaded)
exceptions = []
tree = {}
ObjectSpace.each_object(Class) do |cls|
next unless cls.ancestors.include? Exception
next if exceptions.include? cls
next if cls.superclass == SystemCallError # avoid dumping Errno's
exceptions << cls
cls.ancestors.delete_if {|e| [Object, Kernel].include? e }.reverse.inject(tree) {|memo,cls| memo[cls] ||= {}}
end
@genewoo
genewoo / folder_helper.rb
Created December 29, 2011 15:11
My Folder helper
def folder_exists!(folder)
folder = File.expand_path(folder)
target = ""
folder.split(File::SEPARATOR).each{ |path|
target = "/" if target.empty? && path.empty? #Unix environment
target = File.join(target, path).to_s
create_folder(target) if path.empty?
}
target
end
@genewoo
genewoo / tessdata.sh
Last active September 17, 2015 01:13
Download Tesseract Data by Script
#!/bin/bash
if [ $# -eq 0 ]
then
echo "tessdata.sh LANG [TAG]"
echo "check LANG and TAG from https://github.com/tesseract-ocr/tessdata/"
fi
BRANCH=master
if [ $# -eq 2 ]
then
@genewoo
genewoo / sbt_china_mirror
Last active August 29, 2015 14:28 — forked from manuzhang/sbt_china_mirror
sbt China mirror
[repositories]
local
oschina: http://maven.oschina.net/content/groups/public/
oschina-ivy: http://maven.oschina.net/content/groups/public/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
typesafe: http://repo.typesafe.com/typesafe/ivy-releases/, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext], bootOnly
#sonatype-oss-releases
#maven-central
#sonatype-oss-snapshots
@genewoo
genewoo / application_controller.rb
Last active August 26, 2015 09:54 — forked from scottwb/application_controller.rb
Get a list of all the filters on a given Rails 3 controller.
# Add these methods to your ApplicationController. Then, any controller
# that inherits from it will have these methods and can programmatically
# determine what filters it has set.
class ApplicationController < ActionController::Base
def self.filters(kind = nil)
all_filters = _process_action_callbacks
all_filters = all_filters.select{|f| f.kind == kind} if kind
all_filters.map(&:filter)
end