Skip to content

Instantly share code, notes, and snippets.

View shaoshing's full-sized avatar

Shaoshing Li shaoshing

View GitHub Profile
interpolations :site_name
tags :title, :description, :keywords, :robot
meta_variables
meta_attrs :title, :description, :keyword, :name
# product_path
# products#show
@shaoshing
shaoshing / Number2Txt for Flashcard Deluxe
Last active December 11, 2015 17:29
Shell script to convert Numbers file to txt that could imported to Flashcard Deluxe (an iOS app)
#!/bin/bash
#
# Usage:
# convert.sh ~/Downloads/Cards.numbers
# (must specify full path)
#
# AppleScript to convert from numbers to csv
osascript -e '
on run argv
@shaoshing
shaoshing / number2txt for SuperMemo
Last active August 2, 2022 20:43
Ruby script to convert Numbers file to txt, so that it can be imported into Supermemo.
#!/usr/bin/env ruby
#
# Usages
# num2txt path/to/your/file.numbers
require 'csv'
if !ARGV[0]
puts "Please specify a number file."
@shaoshing
shaoshing / Gemfile
Created January 16, 2014 17:26
Using ActiveRecord in jRuby
source "https://rubygems.org"
gem 'activerecord', '~> 3.2.14'
gem 'activerecord-jdbcmysql-adapter', :platform => :jruby
@shaoshing
shaoshing / run.sh
Created February 11, 2014 03:38
Benchmarking Node.js and Golang
echo "\n\n# Benchmarking Golang"
go build server.go
./server &
PID=$!
sleep 2
ab -c 100 -n 10000 http://127.0.0.1:8000/
kill $PID
echo "\n\n# Benchmarking Node.js"
node server.js &
Node.JS
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 127.0.0.1 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
@shaoshing
shaoshing / gist:5b835655b06f1aff33b2
Created June 12, 2014 20:20
Publish your package to npmjs.org
# 1
# register an user at npmjs.org
# 2
npm adduser
# 3
cd /path/to/your/package
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-field/core-field.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../core-input/core-input.html">
<link rel="import" href="../core-icons/core-icons.html">
@shaoshing
shaoshing / examples.js
Created March 29, 2015 15:23
The Symmetry of JavaScript Functions (revised) http://raganwald.com/2015/03/12/symmetry.html
// Yellow - Decorator for method
function isFruit(name){
return ['banana', 'apple'].indexOf(name) !== -1;
}
function not(fn){
return function(){
return !fn.apply(null, arguments);
};
}
@shaoshing
shaoshing / examples.js
Created March 29, 2015 15:23
The Symmetry of JavaScript Functions (revised) http://raganwald.com/2015/03/12/symmetry.html
// Yellow - Decorator for method
function isFruit(name){
return ['banana', 'apple'].indexOf(name) !== -1;
}
function not(fn){
return function(){
return !fn.apply(null, arguments);
};
}