VI bindings in iex:
brew install rlwrap # on OSX
echo "alias iex='rlwrap -a foo iex'" >> ~/.bash_profile
echo "set editing-mode vi" >> ~/.inputrc
source ~/.bash_profile
\iex
#!/usr/bin/ruby | |
source_path = ARGV[0] | |
target_path = ARGV[1] | |
puts "going to process file: #{source_path}" | |
puts "going to create file: #{target_path}" | |
fail "source file non edist" unless File.exist?(source_path) | |
fail "target file already edist" if File.exist?(target_path) |
// in item order page | |
deliveryInfo = document.querySelector("#appOrders > div > table > tbody > tr > td > ul > li > div") | |
deliveryCompany = deliveryInfo.querySelector("span:nth-child(2)").innerText | |
deliveryID = deliveryInfo.querySelector("span:nth-child(4)").innerText | |
itemName = document.querySelector("#appOrders > div > table > tbody > tr > td > ul > li > table > tbody > tr > td.header-item.order-item-info > div > div.item-meta > a").innerText | |
totalPrice = document.querySelector("#appAmount > div > table > tbody > tr > td.total-count > div:nth-child(1) > div:nth-child(4) > table > tbody > tr > td > span > div").innerText.split('¥')[1] | |
console.log(`${itemName}\t${deliveryCompany}\t${deliveryID}\t\t\t\t${totalPrice}`) |
// This would get GeekTime Article in the format of: "title \t date \t links" | |
s = "" | |
document | |
.querySelectorAll(".article-item") | |
.forEach(function(n){ | |
s += ( | |
n.querySelector(".article-item-title").textContent + "\t" + | |
n.querySelector(".article-item-time").textContent + "\t" + |
# Put this file in your home foler | |
-d postgresql | |
-T |
module Logger | |
extend self | |
attr_accessor :output, :log_actions | |
def log(&event) | |
self.log_actions ||= [] | |
self.log_actions << event | |
end |
# This gist records the steps to setup a new Ubuntu Server | |
# User Setup - add user with sudo | |
sudo adduser $USERNAME | |
sudo adduser $USERNAME sudo | |
# Add SSH Login | |
mkdir ~$USERNAME/.ssh/ | |
cat public_key > ~$USERNAME/.ssh/authorized_keys | |
chmod 500 -R ~$USERNAME/.ssh/ |
# Git Remove Merged Branch | |
git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d | |
# Git List branch, with commit id and message, ordered by last commit date | |
git for-each-ref --sort=committerdate refs/heads/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))' | |
# Remote the deleted branch in the remote `origin` | |
git remote prune origin | |
import java.util.Random; | |
import java.util.Set; | |
import java.util.TreeSet; | |
public class MontyHall { | |
static Random rand = new Random(); | |
public static void main(String args[]){ | |
Spree::ProductProperty.class_eval do | |
belongs_to :value_object, class_name: 'Spree::PropertyValue', foreign_key: :value_id | |
before_validation { self.value = value_object.value if value_id and changes[:value_id] } | |
end |