Skip to content

Instantly share code, notes, and snippets.

View j1n6's full-sized avatar
🎯
Focusing

Jing Dong j1n6

🎯
Focusing
View GitHub Profile
@j1n6
j1n6 / gist:5852036
Last active December 18, 2015 22:08
Apache Bench requests
# ulimit -n 1000
ab -n 1000 -c 1000 -p request.json -T "application/json; charset=utf-8" http://localhost:3004/

Add to brew tap

brew tap petere/postgresql

Install 9.3

brew install postgresql-9.3
@j1n6
j1n6 / multiple_io.rb
Created January 3, 2014 12:55
Ruby Multiple IO
class MultipleIO
def initialize(*targets)
@targets = targets
end
def write(*args)
@targets.each { |t| t.write(*args) }
end
def close
@j1n6
j1n6 / inspektr_mysql.sql
Created January 7, 2014 16:38
inspektr required table for MySql
CREATE TABLE `COM_AUDIT_TRAIL` (
`AUD_USER` varchar(100) NOT NULL ,
`AUD_CLIENT_IP` VARCHAR(15) NOT NULL ,
`AUD_SERVER_IP` VARCHAR(15) NOT NULL ,
`AUD_RESOURCE` varchar(100) NOT NULL ,
`AUD_ACTION` varchar(100) NOT NULL ,
`APPLIC_CD` varchar(5) NOT NULL ,
`AUD_DATE` TIMESTAMP NOT NULL
);
ALTER TABLE `COM_AUDIT_TRAIL`
@j1n6
j1n6 / rbenv_install.sh
Created January 15, 2014 08:09
Rbenv install steps
cd
git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL
def multi_db_commit(tx_id, dbs)
prepared = []
dbs.each do |db, pr|
db.transaction(:prepare=>tx_id, &pr)
prepared << db
end
rescue
prepared.each do |db|
begin
require "watir-webdriver"
caps = Selenium::WebDriver::Remote::Capabilities.firefox
caps.platform = :LINUX
caps[:name] = "WebDriver"
browser = Watir::Browser.new(:remote, url: "http://192.168.119.118:4444/wd/hub", desired_capabilities: caps)
browser.goto "http://www.google.com"
browser.quit
var extend = function(child) {
var base = this;
if(child) {
for(var prop in child) {
base[prop] = child[prop];
}
for(var prop in child) {
base.prototype[prop] = child[prop];
@j1n6
j1n6 / gist:5fdf2d1bf2b4e7659be3
Last active August 29, 2015 14:00
pwd regex
email
{ with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i }
pwd
{ with: /\A(?=.*[a-zA-Z])(?=.*[0-9]).{6,}\z/ }
config.action_mailer.perform_deliveries = true
config.action_mailer.smtp_settings = {
address: ENV['SMTP_SERVER'],
authentication: :login,
domain: 'example.com',
port: 25,
password: ENV['SMTP_PASSWORD'],
user_name: ENV['SMTP_USERNAME'],
enable_starttls_auto: true
}