These are a list of usages of shell commands I can't live without on UNIX-based systems.
Using Homebrew (yes, I am opinionated) you can install the following tools with the following packages:
| # Split MYSQL dump file | |
| zcat dump.sql.gz | awk '/DROP TABLE IF EXISTS/{n++}{print >"out" n ".sql" }' | |
| # Parallel import using GNU Parallel http://www.gnu.org/software/parallel/ | |
| ls -rS *.sql | parallel --joblog joblog.txt mysql -uXXX -pYYY db_name "<" | |
| :environment | |
| {:algorithms | |
| {:lift-fn pallet.core/parallel-lift | |
| :vmfest | |
| {:create-nodes-fn pallet.compute.vmfest/parallel-create-nodes} | |
| :converge-fn pallet.core/parallel-adjust-node-counts} | |
| :phases {:bootstrap | |
| (phase | |
| (package-manager | |
| :configure :proxy local-proxy))} |
| // http://en.wikipedia.org/wiki/Decorator_pattern | |
| trait Coffee { | |
| def cost:Double | |
| def ingredients: String | |
| } | |
| class SimpleCoffee extends Coffee { | |
| override def cost = 1 | |
| override def ingredients = "Coffee" |
| #!/usr/bin/ruby | |
| class IPGenerator | |
| public | |
| def initialize(session_count, session_length) | |
| @session_count = session_count | |
| @session_length = session_length | |
| @sessions = {} | |
| end |
| (defn validates-credentials [username password] | |
| (let [uc (count username) | |
| pc (count password)] | |
| (match [username uc password pc] | |
| [(:or nil "") _ _ _] {:error "No username given" :field "name"} | |
| [_ _ (:or nil "") _] {:error "No password given" :field "pass"} | |
| [_ (_ :guard #(< % 3)) _ _] {:error "Username less than 3 characters" :field "pass"} | |
| [_ _ _ (_ :guard #(< % 4))] {:error "Password less than 4 characters" :field "pass"} | |
| [#"^([a-z0-9-_]+)$" _ _ _] {:error "Username contains invalid characters" :field "name"} | |
| :else true))) |
| #!/bin/bash -ex | |
| # Paste this into ssh | |
| # curl -sL https://gist.github.com/andsens/2913223/raw/bootstrap_homeshick.sh | tar -xzO | /bin/bash -ex | |
| # When forking, you can get the URL from the raw (<>) button. | |
| ### Set some command variables depending on whether we are root or not ### | |
| # This assumes you use a debian derivate, replace with yum, pacman etc. | |
| aptget='sudo apt-get' | |
| chsh='sudo chsh' |
| -- 0.1 ログインインターバルの分布 -- | |
| -- 当日入会->辞めた人もインターバルは1となるので1回以上プレイしている人に限定 -- | |
| td query -w -d your_app -f csv -o dist_of_login_interval.csv " | |
| SELECT ROUND((datediff(latest_login, registered_day)+1)/login_times) AS login_interval, COUNT(*) AS cnt | |
| FROM | |
| ( | |
| SELECT v['uid'] AS uid, from_unixtime(MAX(time),'yyyy-MM-dd' ) AS latest_login | |
| FROM login | |
| GROUP BY v['uid'] | |
| ) t1 |