Skip to content

Instantly share code, notes, and snippets.

View reyesyang's full-sized avatar

Yang Hailong reyesyang

View GitHub Profile
@huacnlee
huacnlee / grape_runtime_log.rb
Last active July 3, 2016 09:56
Output request time spend and parameters in log for Grape
require 'grape'
class API < Grape::API
before do
@log_start_t = Time.now
Rails.logger.info " Parameters: #{params.to_hash.except("route_info")}"
end
after do
@log_end_t = Time.now
# 單純用來決定該有哪些 interface 和一些是在我們這邊處理的邏輯
class PaymentGateway
attr_reader :email
SUBSCRIPTION_AMOUNT = 10.to_money
def initialize(user)
@email = user.email
end
@tovodeverett
tovodeverett / database_cleaner.rb
Created June 19, 2013 19:40
Modified version of Avdi Grimm's solution for configuring RSpec and Capybara to use DatabaseCleaner
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
end
config.before(:each) do
DatabaseCleaner.strategy = Capybara.current_driver == :rack_test ? :transaction : :truncation
DatabaseCleaner.start
end
@willurd
willurd / web-servers.md
Last active April 25, 2024 01:54
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@hjue
hjue / my_tmux
Last active December 16, 2015 17:41
my tmux shell
#!/bin/sh
#
cmd=$(which tmux)
session=hjue
if [ -z $cmd ]; then
echo "You need to install tmux."
exit 1
fi
@ikawka
ikawka / gist:4174481
Created November 30, 2012 08:16
gitlab centos 5.8 86_64
su -
#dependcies
#centos 6.2 | http://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/epel-release-6-7.noarch.rpm
rpm -Uvh http://mirrors.ustc.edu.cn/fedora/epel/5/x86_64/epel-release-5-4.noarch.rpm
yum -y groupinstall 'Development Tools' 'Additional Development'
yum -y install readline readline-devel ncurses-devel gdbm-devel glibc-devel tcl-devel openssl-devel curl-devel expat-devel db4-devel byacc sqlite-devel gcc-c++ libyaml libyaml-devel libffi libffi-devel libxml2 libxml2-devel libxslt libxslt-devel libicu libicu-devel system-config-firewall-tui python-devel redis
@andrioli
andrioli / .gtkrc-eclipse
Last active August 3, 2023 14:18
Config to make Eclipse Juno icons and tabs look small and nice in Linux
# Create a new file in your home directory called .gtkrc-eclipse
# call eclipse with this command:
# Gtk2 forced:
# export SWT_GTK3=0
# env GTK2_RC_FILES=/usr/share/themes/<YourTheme>/gtk-2.0/gtkrc:/home/<YourUser>/.gtkrc-eclipse '/path_to_eclipse/eclipse'
# In your Eclipse directory find the file 'e4_default_gtk.css'
# In this file there's a CSS class:
@psychocandy
psychocandy / URI-monkey-patch.rb
Created July 17, 2012 16:11
Fix ArgumentError invalid %-encoding for malformed URLs
# The following should prevent an ArgumentError "invalid %-encoding (...%)" exception from being raised for malformed URLs.
# To use this code simply drop this in your rails app initializers.
# See: https://github.com/rack/rack/issues/337
# Taken from: http://stackoverflow.com/a/11162317/1075006
module URI
major, minor, patch = RUBY_VERSION.split('.').map { |v| v.to_i }
@aleksandara
aleksandara / fontfix.patch
Created June 21, 2012 03:27 — forked from trustin/fontfix.patch
OpenJDK 7 font rendering patch for Linux (cd openjdk/jdk; patch -p1 < fontfix.patch)
diff -r 96a023de3ddf make/sun/font/Makefile
--- a/make/sun/font/Makefile Wed Jun 06 18:39:46 2012 -0700
+++ b/make/sun/font/Makefile Fri Jun 08 12:52:01 2012 +0900
@@ -128,7 +128,7 @@
ifeq ($(USING_SYSTEM_FT_LIB), false)
FREETYPE_LIB = $(LIB_LOCATION)/$(LIB_PREFIX)freetype.$(LIBRARY_SUFFIX).6
endif
- OTHER_LDLIBS += -L$(FREETYPE_LIB_PATH) -lfreetype
+ OTHER_LDLIBS += -L$(FREETYPE_LIB_PATH) -lfreetype -lfontconfig
endif
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active April 24, 2024 12:19
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname