Skip to content

Instantly share code, notes, and snippets.

View k-oguma's full-sized avatar
:octocat:
( ̄(工) ̄)

oguma k-oguma

:octocat:
( ̄(工) ̄)
View GitHub Profile
@jimeh
jimeh / sudome.rb
Created November 20, 2009 23:30
sudome — A simple Ruby method which checks if the current script is running as root, and if not, re-invokes itself by using the sudo command.
# A simple Ruby method which checks if the current script
# is running as root, and if not, re-invokes itself by
# using the sudo command.
def sudome
if ENV["USER"] != "root"
exec("sudo #{ENV['_']} #{ARGV.join(' ')}")
end
end
@rummelonp
rummelonp / faraday.md
Last active May 20, 2022 12:23
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] というものがよく使われてた

@digitaljhelms
digitaljhelms / gist:3761873
Last active September 10, 2023 23:43
Git/GitHub commit standards & conventions

Committing Code

General Rules

  • Make atomic commits of changes, even across multiple files, in logical units. That is, as much as possible, each commit should be focused on one specific purpose.
  • As much as possible, make sure a commit does not contain unnecessary whitespace changes. This can be checked as follows:
$ git diff --check
@hayajo
hayajo / changelog_en.md
Last active May 3, 2024 08:29
ChangeLog を支える英語

ChangeLog を支える英語

ChangeLog を書く際によく使われる英語をまとめました。

ほとんど引用です。

基本形

@devlights
devlights / test.py
Last active August 10, 2022 03:00
Pythonでマルチバイト文字を扱う際に気をつける点。
# vim:fileencoding=utf-8
import codecs
import sys
import types
if __name__ == '__main__':
#
# ターミナルに出力する場合
# 以下のサンプルは、ターミナルに出力する場合は
# うまくいくが、リダイレクトさせてファイルに出力すると
@masquaremo
masquaremo / str_num_sample.rb
Last active May 30, 2021 06:56
Rubyで文字列と数値を相互に変換するメソッドとかのまとめ
#!/usr/bin/ruby
#数値を16進数文字列に
p 65.to_s(16) #=> "41"
#数値をASCII文字に
p 65.chr #=> "A"
#文字列を16進数とみなして数値に
p "41".hex #=> 65
@shtwave
shtwave / gist:5162614
Last active November 10, 2021 07:04
netfilterチューニング
ip_conntrack: table full, dropping packet.
この一行のログに悩まされた方は多いのではないでしょうか。
自分もその一人です。
多くのブログには echo '500000' > /proc/sys/net/ipv4/netfilter/ip_conntrack_max で解決。みたいなことが書いてあると思います。
では、この数字について根拠はなんでしょうか。そもそも何のためにconntrack tableというものがあるのか考えたことはありますか?
闇雲に最大値をあげることにたいして抵抗がある方もいると思います。
このテキストは、転職後2日目にGWとして使っているLinux NAT BOXが爆発したことを起因とした、netfilterのチューニングについてまとめようと思います。
# bash <(curl -s https://gist.github.com/drye/5387341/raw/ec72cddfe43ec3d39c91a3c118cb68ab14a049f8/enable_dnsmasq_on_osx.sh)
# ----------------------
# installing dnsmasq and enable daemon
# ----------------------
brew install dnsmasq
sudo cp -v $(brew --prefix dnsmasq)/homebrew.mxcl.dnsmasq.plist /Library/LaunchDaemons
# ----------------------
# adding resolver for vbox domain
# ----------------------
@japboy
japboy / jade-ftw.md
Last active October 23, 2023 11:18
Jade について。

Jade FTW

こんにちは。今回は現実逃避を兼ねて Jade の素晴らしさをお伝えしたいと思います。

Jade とは何か

[Jade][0] は JST (JavaScript Templates) の一つであり、HTML を書くための[軽量マークアップ言語][1] である [Haml][2] に影響を受けた JavaScript テンプレートエンジンでもあります。

@ogrrd
ogrrd / dnsmasq OS X.md
Last active May 3, 2024 08:33
Setup dnsmasq on OS X

Never touch your local /etc/hosts file in OS X again

To setup your computer to work with *.test domains, e.g. project.test, awesome.test and so on, without having to add to your hosts file each time.

Requirements

Install