Skip to content

Instantly share code, notes, and snippets.

View flyfy1's full-sized avatar

Song Yangyu flyfy1

View GitHub Profile
@flyfy1
flyfy1 / index.html
Last active January 12, 2016 09:45
Body.no-scoll test
<html>
<head>
<title>Test Body No Scoll</title>
<style>
body{
background-color: black;
color: white;
}
</style>
</head>
@flyfy1
flyfy1 / check_pr_status
Created March 7, 2016 07:06
Check the Application status for Singapore Permanent Residence. Used to work long time ago.. not sure if it is still working now.
#!/usr/bin/env ruby
require 'rubygems'
require 'selenium-webdriver'
# Configs
FIN = "YOUR_FIND_NUMBER"
APPLICATION_NUMBER = "YOUR-PR-APPLICATION-NUMBER"
APPNUM_ARR = APPLICATION_NUMBER.split "-"
@flyfy1
flyfy1 / app-models-product_property_decorator.rb
Last active June 6, 2016 10:23
For Solidus: making Property selectable field
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
@flyfy1
flyfy1 / gist:15cd169339f4dac446039976c6e0390a
Last active July 16, 2016 13:29 — forked from jfreeze/gist:8894279
Get VI bindings in IEX (Elixir REPL)

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

To run iex WITHOUT rlwrap

\iex

@flyfy1
flyfy1 / MontyHall.java
Created October 15, 2016 11:55
Java Simulation for the MontyHall Problem
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[]){
@flyfy1
flyfy1 / git_note.sh
Last active June 6, 2017 14:36
Collection of quick notes.. in bash
# 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
# 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/
@flyfy1
flyfy1 / 1.callback.rb
Created May 15, 2017 03:31
Ruby Memory Leak Examples
module Logger
extend self
attr_accessor :output, :log_actions
def log(&event)
self.log_actions ||= []
self.log_actions << event
end
@flyfy1
flyfy1 / .railsrc
Last active November 19, 2017 15:10
Rails starter template: rspec / factory_bot / slim
# Put this file in your home foler
-d postgresql
-T
@flyfy1
flyfy1 / get-geektime-links.js
Last active August 9, 2018 15:36
因为极客时间网页版上的专栏中,点开一篇文章在返回的时候,会重置上一个页面。这极大地影响了刷专栏的体验。这个脚本用来获取《极客时间》网页版的 标题、发布时间 和 连接,复制内容到剪贴版,用以直接粘贴进Excel / Google SpreadSheet 这样的程序