Skip to content

Instantly share code, notes, and snippets.

View ilstar's full-sized avatar

Fred Liang ilstar

  • Instacart
  • San Francisco
View GitHub Profile
@ilstar
ilstar / Mermaid_on_Github_Examples.md
Created September 19, 2023 00:30 — forked from ChristopherA/Mermaid_on_Github_Examples.md
Mermaid on Github Examples

Mermaid on Github Examples

All of these diagrams are dynamically rendered during html display by Github, the images generated from text inside the Github-Flavored Markdown. None are static images. Mermaid support was released for Github on 2022-02-14

Pros & Cons:

  • Pro: You don't need to care about the layout.
  • Con: You cannot control the layout.

Notes:

  • Not all the features of Mermaid (in particular symbols B-->C[fa:fa-ban forbidden], hyperlink and tooltips) are supported by Github.
@ilstar
ilstar / gist:32e265b36337828bc8f4
Created December 16, 2014 23:02
Python Ticker or thresholding
from gevent import monkey;monkey.patch_all()
import gevent
import time
import logging
logging.basicConfig( level=logging.INFO, format="%(asctime)-15s %(message)s", datefmt="%Y-%m-%d %H:%M:%S")
def timer(seconds, func):
while True:
@ilstar
ilstar / update_hosts
Created June 28, 2014 00:26
Update your hosts
#!/usr/bin/ruby
# Usage
# sudo ruby update_hosts.rb
require 'rubygems'
require 'fileutils'
require 'net/http'
@ilstar
ilstar / rspec_rails_cheet_sheat.rb
Last active August 29, 2015 13:57
Rspec Rails cheat sheet
# version
# gem 'rspec-rails', '~> 2.14.2'
# render and redirect
response.should be_success
response.status.should == 404
response.response_code.should == 404
response.should render_template('index')
response.should redirect_to(movies_path)
@ilstar
ilstar / disable_assets_logger.rb
Created July 23, 2012 10:00
Disable Assets Logger
# Usage: in develoopment.rb
#
# config.middleware.insert_before Rails::Rack::Logger, DisableAssetsLogger
#
class DisableAssetsLogger
def initialize(app)
@app = app
Rails.application.assets.logger = Logger.new('/dev/null')
end
@ilstar
ilstar / deploy.rb
Created July 9, 2012 10:09
Capistrano example
$:.unshift(File.expand_path("./lib", ENV['rvm_path']))
require 'rvm/capistrano'
require 'bundler/capistrano'
require "whenever/capistrano"
set :rvm_ruby_string, '1.9.3'
set :rvm_type, :user
set :whenever_command, "bundle exec whenever"
set :domain, "your.domain"
@ilstar
ilstar / douban_oauth.rb
Created July 4, 2012 07:19
douban oauth
require 'oauth'
require 'oauth/consumer'
api_key = "xx"
api_key_secret = "xx"
consumer = OAuth::Consumer.new(
api_key,
api_key_secret,
{
@ilstar
ilstar / 3.css
Created May 29, 2012 08:07
3列固定的页面布局
/* ------------------------------
HTML Redefine Tags
------------------------------ */
body{font-family:Arial, Helvetica, sans-serif; font-size:12px; margin:20px; padding:0;}
input, form, textarea
h1, h2, h3, h4, h5, h6{margin:0; padding:0;}
h1{font-size:18px;}
h2{font-size:14px; color:#999999;}
h3{font-size:13px; border-bottom:solid 1px #DEDEDE; padding:4px 0; margin-bottom:10px;}
@ilstar
ilstar / dropbox_back.sh
Created May 15, 2012 03:39
利用Dropbox自动备份VPS的数据,无需安装dropbox
#!/bin/bash
DROPBOX_USER="Your Dropbox username"
DROPBOX_PASS="Your Dropbox password"
DROPBOX_DIR="Directory in your dropbox account to store the backups, e.g. /backups"
BACKUP_SRC="/home /var/www /var/git /etc /root"
BACKUP_DST="/tmp"
MYSQL_SERVER="127.0.0.1"
MYSQL_USER="root"
MYSQL_PASS="Your MySQL password"
@ilstar
ilstar / rcd
Created July 23, 2011 01:46
batch open iTerm tab with same path
#!/usr/bin/osascript
#
# Install
# copy this file to a directory which is one of your system PATH
# chmod +x filename
#
# Usage
# rcd ~/Download 3
# argv 1: the path which you want to "cd"
# argv 2: the count of new tab.