Skip to content

Instantly share code, notes, and snippets.

@zealinux
zealinux / faraday.md
Created July 19, 2019 09:37 — forked from rummelonp/faraday.md
Ruby の HTTP クライアントライブラリ Faraday が便利そう

Ruby の HTTP クライアントライブラリ Faraday が便利そう

Ruby の HTTP クライアントライブラリ Faraday が便利そう

API ラッパの開発には [RestClient gem][rest_client_gem] だとか
OAuth の必要なものは [Net/HTTP][net_http] + [OAuth gem][oauth_gem] を使ってた

[Twitter gem][twitter_gem] や [Instagram gem][instagram_gem] など API ライブラリのソースを読んでみると
[Faraday gem][faraday_gem] というものがよく使われてた

@zealinux
zealinux / .git-commit-template.txt
Created June 14, 2019 07:24 — forked from jmaxhu/.git-commit-template.txt
一份建议的git commit模板
# <类型>: (类型的值见下面描述) <主题> (最多50个字)
# 解释为什么要做这些改动
# |<---- 请限制每行最多72个字 ---->|
# 提供相关文章和其它资源的链接和关键字
# 例如: Github issue #23
# --- 提交 结束 ---
# 类型值包含
@zealinux
zealinux / download_image.py
Created April 18, 2019 15:06 — forked from mjdietzx/download_image.py
Download image from url and save as file
import io
from PIL import Image # https://pillow.readthedocs.io/en/4.3.x/
import requests # http://docs.python-requests.org/en/master/
# example image url: https://m.media-amazon.com/images/S/aplus-media/vc/6a9569ab-cb8e-46d9-8aea-a7022e58c74a.jpg
def download_image(url, image_file_path):
r = requests.get(url, timeout=4.0)
if r.status_code != requests.codes.ok:
@zealinux
zealinux / pg_random_int_array.sql
Created April 10, 2019 02:01 — forked from ekho/pg_random_int_array.sql
Postgresql function for generating random integer array
CREATE OR REPLACE FUNCTION random_int_array(dim integer, min integer, max integer) RETURNS integer[] AS $BODY$
begin
return (select array_agg(round(random() * (max - min)) + min) from generate_series (0, dim));
end
$BODY$ LANGUAGE plpgsql;
-- usage example
select random_int_array(15, 6, 40);
-- return example
@zealinux
zealinux / gist:5c69e978b316473a9abe2d4ef7630b5a
Created March 26, 2019 08:55 — forked from newhouseb/gist:1620133
MySQL vs PostgreSQL Schema changes benchmarks
The basic idea here is to substantiate the claims made by this square post:
http://corner.squareup.com/2011/06/postgresql-data-is-important.html
In PostgreSQL, and MySQL (MyISAM and InnoDB) I create millions of rows and then add
and remove columns and add and remove indexes. For columns without defaults this is
basically free in PostgreSQL and O(n) in MySQL. For adding indexes its at best O(n)
everywhere, but with PostgreSQL it claims not to do any locking that would otherwise
prevent table interaction.
Also, PostgreSQL has _awsome_ documentation (it has real examples!). I always get
@zealinux
zealinux / org-mode-reference-in.org
Created March 22, 2019 03:42 — forked from drj42/org-mode-reference-in.org
This is a cheat sheet for Emacs org-mode... in org-mode format!
@zealinux
zealinux / tmux-cheatsheet.markdown
Created February 28, 2019 10:16 — forked from ryerh/tmux-cheatsheet.markdown
Tmux 快捷键 & 速查表

注意:本文内容适用于 Tmux 2.3 及以上的版本,但是绝大部分的特性低版本也都适用,鼠标支持、VI 模式、插件管理在低版本可能会与本文不兼容。

Tmux 快捷键 & 速查表

启动新会话:

tmux [new -s 会话名 -n 窗口名]

恢复会话:

@zealinux
zealinux / install-docker.sh
Created January 4, 2019 10:09 — forked from brianz/install-docker.sh
Install docker on Amazon Linux
#!/bin/bash
#
# steps taken verbatim from:
# http://docs.aws.amazon.com/AmazonECS/latest/developerguide/docker-basics.html#install_docker
#
sudo yum update -y
sudo yum install -y docker
sudo service docker start
sudo usermod -a -G docker ec2-user
# log out and log in to pickup the added group
@zealinux
zealinux / checkUrlExists.m1.py
Created December 18, 2018 06:51 — forked from fedir/checkUrlExists.m1.py
Check if URL exists via Python
from urllib2 import urlopen
code = urlopen("http://example.com/").code
if (code / 100 >= 4):
print "Nothing there."
# via http://stackoverflow.com/questions/1966086/how-can-i-determine-if-anything-at-the-given-url-does-exist
@zealinux
zealinux / homebrew_opencv_245.sh
Created May 29, 2018 04:25 — forked from tstellanova/homebrew_opencv_245.sh
Install a specific version of OpenCV on OSX with homebrew
# 20131214
# switch to the relevant keg directory
cd /usr/local/Library/Taps/homebrew-science
brew versions opencv
# look for the version you want, eg:
# 2.4.5 git checkout ae74fe9 opencv.rb
# checkout the version you want
git checkout ae74fe9 opencv.rb