Skip to content

Instantly share code, notes, and snippets.

@justqyx
justqyx / Preferences.sublime-settings
Last active October 26, 2016 08:49
My Sublime Text Confirguration
{
"color_scheme": "Packages/Material Theme/schemes/OLD/Material-Theme-Darker.tmTheme",
"default_encoding": "UTF-8",
"ensure_newline_at_eof_on_save": true,
"folder_exclude_patterns":
[
".svn",
".git",
".hg",
"CVS",
@justqyx
justqyx / zshrc
Last active August 15, 2016 01:38
# Path to your oh-my-zsh installation.
export ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="robbyrussell"
# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"
# Uncomment the following line to disable bi-weekly auto-update checks.
source "https://ruby.taobao.org"
ruby "2.1.6"
### Main
gem 'rails', '4.2.3'#, github: 'rails/rails'
gem 'sdoc', '~> 0.4.0', group: :doc # Document is **IMPORTANT**, `bin/rake doc:rails`
gem 'pg' # Postgresql Driver
gem "redis", "~> 3.1", require: ["redis/connection/hiredis", "redis"]
gem "hiredis"
@justqyx
justqyx / transcode_video.rb
Created August 19, 2015 05:14
transcode_video.rb
params = {
bucket: "your_bucket",
key: "j7m3jm9io.mp4",
fops: "avthumb/mp4/vcodec/libx264/vb/512k/r/24/vb/256k/acodec/libfaac/ab/64k|saveas/bGFpMWtlLWRldjpnb3Uyem9yaWRqbnN0dDktbWVkaXVtLm1wNA==",
pipeline: "neolion",
notifyURL: "http://example.com/callback/qiniu_transcoded/23"
}
http_code, resp = Qiniu::Fop::Persistance.pfop params
# _ooOoo_
# o8888888o
# 88" . "88
# (| -_- |)
# O\ = /O
# ____/`---'\____
# . ' \\| |// `.
# / \\||| : |||// \
# / _||||| -:- |||||- \
# | | \\\ - /// | |
@justqyx
justqyx / utils.js
Created May 13, 2015 01:28
Javascript little functions
function numberToChinese(number) {
var UNIT = ['', '十', '百'];
var NUMBER = ['', '一', '二', '三', '四', '五', '六', '七', '八', '九'];
if (number == 0) {
return '零';
}
if (number > 999) {
throw new Error('Too Big');
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
require 'securerandom'
module ActiveSupport
module Notifications
# Instrumenters are stored in a thread local.
class Instrumenter
attr_reader :id
def initialize(notifier)
@id = unique_id
@justqyx
justqyx / clear_pg_dumps.rb
Created December 24, 2014 02:53
清理 PostgreSQL 备份文件
require 'date'
file_paths = Dir.glob("/BACKUP_DIR/*.dump")
file_paths.map! do |file_path|
basename = File.basename(file_path, '.dump')
key = Date.parse(basename)
[key, file_path]
end.sort! do |a, b|
a[0] <=> b[0]
[2014-10-27T00:24:17-07:00] INFO: Forking chef instance to converge...
[2014-10-27T00:24:17-07:00] INFO: *** Chef 11.10.4 ***
[2014-10-27T00:24:17-07:00] INFO: Chef-client pid: 11300
[2014-10-27T00:24:17-07:00] WARN: Run List override has been provided.
[2014-10-27T00:24:17-07:00] WARN: Original Run List: []
[2014-10-27T00:24:17-07:00] WARN: Overridden Run List: [role[rails_srv]]
[2014-10-27T00:24:17-07:00] INFO: Run List is [role[rails_srv]]
[2014-10-27T00:24:17-07:00] INFO: Run List expands to [ruby, memcached, nginx::source, redisio::install]
[2014-10-27T00:24:17-07:00] INFO: Starting Chef Run for ubuntu
[2014-10-27T00:24:17-07:00] INFO: Running start handlers