Skip to content

Instantly share code, notes, and snippets.

View kaznum's full-sized avatar

Kazuya NUMATA kaznum

View GitHub Profile
@kaznum
kaznum / amazon_qldb.md
Last active March 24, 2021 23:29
Amazon QLDB

Amazon QLDB

Amazon Quantum Ledger Database (QLDB) 透過的でイミュータブル、かつ暗号的に検証可能なトランザクションログを提供するフルマネージド型台帳データベース。ログは信頼された中央機関が所有。

https://aws.amazon.com/jp/qldb/ https://ap-northeast-1.console.aws.amazon.com/qldb/home?region=ap-northeast-1#getting-started

特徴

  • アプリケーションデータの各変更を追跡し、完全で順番に並んだ変更履歴を長期間維持するジャーナルを使用
@kaznum
kaznum / init.el
Last active August 23, 2017 06:15
Emacsのmarkdownモードのpreviewをgithub flavorにする
;; インターネット上には色々な記述があるが、結局のところ markdown コマンドと同様に、
;; 標準入力からMarkdown形式の文書が入力され、それが成型されたのち標準出力に出力されればよい。
;;
;; M-m m c p でブラウザが起動。
;; 事前に `brew install grip`しておく
;; --gfm をつけると良いという記述があったが、今のgrip(4.3.2)にはこのオプションは存在しなかった。
(setq markdown-command "grip --export - /dev/stdout")
# This module offers the way to get session_id from HTTP_X_SID
# in the request headers for Rack application.
#
# This is only work memcache and dalli
# (Rack::Session::Cookie implements 'extract_session_id' by itself.)
# Put this file in config/initializers when used with Rails.
#
# I don't know why this module exists because the default way is
# using cookies, but cookie is even put in HTTP Request and response
# headers too.
(function(){
var total = {};
var year = '2012';
var all = false;
function init(num) {
if(typeof num !== 'number') {
num = 0;
$('<div/>').css({
position: 'fixed',
left: 0,
@kaznum
kaznum / gist:3810258
Created October 1, 2012 08:16
sanitize HTML with jQuery
/*
* sanitize HTML with jQuery based on whitelist
* example:
* sanitizer.sanitize('<a href="foo" class="bar">aaa</a><script>alert("...")</script>', {'a': ['href'], 'strong': []})
* returns '<a href="foo">aaa</a>'
*/
var sanitizer = {};
(function($) {
function trimAttributes(node, allowedAttrs) {
@kaznum
kaznum / arel_sql92_like_escape.rb
Created September 6, 2012 13:31
SQL92 compatible LIKE escaping
# SQL92 style "LIKE" escaped expression support
#
# load via initializer in Rails
#
# Arel supports the following expression
# where(Item.arel_table[:name].matches("%#{str}%")
# and str have to be escaped.
# The following code specify '!' as an ESCAPE character.
# The target characters to escape are /[%_!]/
# When these characters are escaped with proceeding "!", the following code escapes these character correctly.
@kaznum
kaznum / EmolettHelper.rb
Created May 17, 2012 07:32
Emolett変換
# -*- coding: utf-8 -*-
module EmolettHelper
def emolettise(str)
str.gsub(/(\(|()(笑|爆|嬉|喜|楽|驚|泣|涙|悲|怒|厳|辛|苦|閃|汗|忙|急|輝)(\)|))/) { |s|
"<span class='emo'>#{s}</span>"
}.html_safe
end
end
@kaznum
kaznum / gist:2435951
Created April 21, 2012 09:01 — forked from dx7/gist:1333785
Installing ruby-debug with ruby-1.9.3-p194
# Install with:
# bash < <(curl -L https://raw.github.com/gist/2435951)
#
# Reference: http://blog.wyeworks.com/2011/11/1/ruby-1-9-3-and-ruby-debug
echo "Installing ruby-debug with ruby-1.9.3-p194 ..."
curl -OL http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem
curl -OL http://rubyforge.org/frs/download.php/75415/ruby-debug-base19-0.11.26.gem
@kaznum
kaznum / remove_file_completely_from_git.sh
Created January 4, 2012 19:13
force remove file from git repository.
#!/bin/bash
# force remove file from git repository.
git filter-branch --index-filter 'git update-index --remove filepath_to_remove' HEAD
git push --force --verbose --dry-run
git push --force
@kaznum
kaznum / looking_for_and_killing_process_to_use_tcp_port.sh
Created October 25, 2011 00:26
looking for and killing processes to use tcp port
# to look for the processes to use tcp 443
fuser -n tcp 443
# to kill all processes to use tcp 443
fuser -kn tcp 443