48000 did_you_mean/lib
48000 /GitHub/did_you_mean/lib/did_you_mean/jaro_winkler.rb
@preallocate = [] | |
500_000.times do | |
@preallocate << "" | |
end | |
def process_request | |
allocate = rand(80_000) + 20000 | |
req = [] |
# based on http://api.rubyonrails.org/classes/ActionController/RequestForgeryProtection.html | |
module Auth | |
extend ActiveSupport::Concern | |
included do | |
helpers do | |
def session | |
env['rack.session'] | |
end |
App configuration in environment variables: for and against | |
For (some of these as per the 12 factor principles) | |
1) they are are easy to change between deploys without changing any code | |
2) unlike config files, there is little chance of them being checked | |
into the code repo accidentally | |
3) unlike custom config files, or other config mechanisms such as Java |
// | |
// _oo0oo_ | |
// o8888888o | |
// 88" . "88 | |
// (| -_- |) | |
// 0\ = /0 | |
// ___/`---'\___ | |
// .' \\| |// '. | |
// / \\||| : |||// \ | |
// / _||||| -:- |||||- \ |
import telnetlib | |
import sys | |
import Account #My file. It contains Account.id, Account.password | |
import time | |
tn = telnetlib.Telnet('ptt.cc') | |
time.sleep(1) | |
content = tn.read_very_eager().decode('big5','ignore') | |
print("首頁顯示...") | |
if "請輸入代號" in content: | |
print("輸入帳號...") |
# gem 'mini_magick' 5217dfe | |
# GraphicsMagick 1.3.17 | |
# ImageMagick 6.7.0-10 | |
# Resize to fill (old method) | |
# http://www.imagemagick.org/Usage/resize/#space_fill | |
# | |
# works with ImageMagick as expected | |
# fails to work with GraphicsMagick as expected |
# from i8ramin - http://getintothis.com/blog/2012/04/02/git-grep-and-blame-bash-function/ | |
# runs git grep on a pattern, and then uses git blame to who did it | |
ggb() { | |
git grep -n $1 | while IFS=: read i j k; do git blame -L $j,$j $i | cat; done | |
} | |
# small modification for git egrep bash | |
geb() { | |
git grep -E -n $1 | while IFS=: read i j k; do git blame -L $j,$j $i | cat; done | |
} |
# coding: utf-8 | |
require 'sinatra' | |
set server: 'thin', connections: [] | |
get '/' do | |
halt erb(:login) unless params[:user] | |
erb :chat, locals: { user: params[:user].gsub(/\W/, '') } | |
end | |
get '/stream', provides: 'text/event-stream' do |