Skip to content

Instantly share code, notes, and snippets.

View j1n6's full-sized avatar
🎯
Focusing

Jing Dong j1n6

🎯
Focusing
View GitHub Profile
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
}
@j1n6
j1n6 / xvfb
Last active August 29, 2015 14:01 — forked from dloman/xvfb
### BEGIN INIT INFO
# Provides: Xvfb
# Required-Start: $local_fs $remote_fs
# Required-Stop:
# X-Start-Before:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Loads X Virtual Frame Buffer
### END INIT INFO
# To automatically run on startup use command:
worker: QUEUE=* bundle exec rake environment resque:work
scheduler: bundle exec rake environment resque:scheduler
@j1n6
j1n6 / gist:5cf15daab8b4bf739fd5
Created June 24, 2014 17:01
rkhunter check command
sudo rkhunter --quiet --checkall --no-mail-on-warning
@j1n6
j1n6 / shellshock.sh
Last active August 29, 2015 14:07
shellshock script ubuntu update
#!/bin/bash
# Check your release, none LTS need to apply this script
# lsb_release -a
cd /tmp && mkdir src && cd src
wget http://ftp.gnu.org/gnu/bash/bash-4.3.tar.gz
#download all patches
for i in $(seq -f "%03g" 0 27); do wget http://ftp.gnu.org/gnu/bash/bash-4.3-patches/bash43-$i; done
@j1n6
j1n6 / clear_osx_cache_example.sh
Last active August 29, 2015 14:08
disable osx cache
# Microsoft Windows
# (Win 7/Vista/XP/Win ME/Win 2000/Win 98)
# - Start -> Run -> type cmd
# At the command prompt, type:
ipconfig /flushdns
# Certain Linux distributions
# Restart the nscd daemon
/etc/rc.d/init.d/nscd restart