Skip to content

Instantly share code, notes, and snippets.

View jay16's full-sized avatar

俊杰.li jay16

View GitHub Profile
# encoding: utf-8
#
# - [HTTP协议及签名](https://help.aliyun.com/document_detail/56189.html)
# - [OpenSSL::HMAC](https://ruby-doc.org/stdlib-2.1.0/libdoc/openssl/rdoc/OpenSSL/HMAC.html)
#
require 'uri'
require 'cgi'
require 'base64'
require 'openssl'
require 'httparty'
# encoding: utf-8
#
# - [HTTP协议及签名](https://help.aliyun.com/document_detail/56189.html)
# - [OpenSSL::HMAC](https://ruby-doc.org/stdlib-2.1.0/libdoc/openssl/rdoc/OpenSSL/HMAC.html)
#
require 'uri'
require 'cgi'
require 'base64'
require 'openssl'
require 'httparty'
@jay16
jay16 / wav2mp3.sh
Created October 19, 2016 10:08
convert wav to mp3 file with ffmep on mac
#!/usr/bin/env bash
##
##############################################################################
##
## Script convert wav to mp3 for UN*X
##
## Dependence:
## - [ffmpeg](https://ffmpeg.org/)
##
## Script File:
@jay16
jay16 / redis-backup.sh
Created October 8, 2016 13:56 — forked from acenqiu/redis-backup.sh
redis rdb backup script
#!/bin/bash
#
## redis backup script
## usage
## redis-backup.sh port backup.dir
port=${1:-6379}
backup_dir=${2:-"/data/backup/redis"}
cli="/usr/local/bin/redis-cli -p $port"
require './application'
namespace :routes do
task :show do
endpoints = {}
if Sinatra::Application.descendants.any?
#Classic application structure
applications = Sinatra::Application.descendants
applications.each do |app|
@jay16
jay16 / pdf.js-server
Last active August 29, 2015 14:21
pdf.js server with sinatra.
#encoding: utf-8
=begin
pdf.js server with sinatra.
put all your pdfjs_generic folder into together-path/ folder
then `cd together-path/ && ruby server.rb`
=end
require "sinatra"
get "/" do
builds = Dir.glob("build/generic*") + Dir.glob("generic*")
@jay16
jay16 / mkgitignore
Last active August 29, 2015 14:21 — forked from wusuopu/mkgitignore
#!/bin/bash
if [[ $@ != "" ]]; then
if [[ $2 != "" ]]; then
curl http://www.gitignore.io/api/$1 -o $2
else
curl http://www.gitignore.io/api/$1
fi
else
echo 创建gitignore文件
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
# 有关 Fiber 的解释: (按照数据流的方向分为两部分)
# 在 `主线程' 中使用 resume 方法来启动(或继续执行)一个 `纤程'.
# 1. 第一次调用 fiber.resume, 会启动一个纤程,
# 如果 resume 调用时提供了实参, 会作为代码块形参传入代码块.
# 2. 如果非第一次调用 fiber.resume, 即, `恢复' 一个纤程, 会做两件事:
# - 从上次离开纤程的那个位置(调用 Fiber.yield 离开纤程的那个位置), 恢复纤程的执行.
@jay16
jay16 / .muttrc.bind
Created April 30, 2015 09:11
.muttrc.bind
# ~/.muttrc.bind
#
# curl http://bronski.net/data/bind > ~/.muttrc.bind
# echo "source ~/.muttrc.bind" >> ~/.muttrc
## Command bind :
## Syntax unto version 0.60: bind <key> <function-name> <menu-name>
## Syntax From version 0.61: bind <menu-name> <key> <function-name>
## Values for <menu-name>:
## attach, folder-menu, alias-menu; index; pager.
#!/usr/bin/env ruby
# List all keys stored in memcache.
# Credit to Graham King at http://www.darkcoding.net/software/memcached-list-all-keys/ for the original article on how to get the data from memcache in the first place.
require 'net/telnet'
headings = %w(id expires bytes cache_key)
rows = []