Skip to content

Instantly share code, notes, and snippets.

View be-hase's full-sized avatar

Ryosuke Hasebe be-hase

View GitHub Profile
@be-hase
be-hase / CookieServerCsrfTokenRepository.java
Created December 28, 2017 14:40
CookieServerCsrfTokenRepository.java
public class CookieServerCsrfTokenRepository implements ServerCsrfTokenRepository {
static final String DEFAULT_CSRF_COOKIE_NAME = "XSRF-TOKEN";
static final String DEFAULT_CSRF_PARAMETER_NAME = "_csrf";
static final String DEFAULT_CSRF_HEADER_NAME = "X-XSRF-TOKEN";
static final String DEFAULT_CSRF_COOKIE_PATH = "/";
private String parameterName = DEFAULT_CSRF_PARAMETER_NAME;
@be-hase
be-hase / out_geoip_custom.rb
Last active April 26, 2016 05:59
Fluentdのout_geoipをちょっと改造したやつ
require 'fluent/mixin/rewrite_tag_name'
class Fluent::GeoipCustomOutput < Fluent::BufferedOutput
Fluent::Plugin.register_output('geoip_custom', self)
config_param :geoip_database, :string, :default => File.dirname(__FILE__) + '/../../../data/GeoLiteCity.dat'
config_param :geoip_lookup_key, :string, :default => 'host'
config_param :tag, :string, :default => nil
config_param :skip_adding_null_record, :bool, :default => false
config_param :result_key_suffix, :string, :default => '_geoip'
@be-hase
be-hase / gist:e97aea92abfd7749ca09
Last active October 14, 2017 08:14
elasticsearchのindex削除用のcron script

elasticsearchのindexを定期的にcronを使用して削除するscript。

indexにTTLを設定すればいいじゃないかという指摘もありそうですが、
公式ブログに大量のログを保存するときは、TTL設定しているとオーバーヘッドが大きいと書いてあったので、
cronで消すようにします。
http://www.elasticsearch.org/tutorials/using-elasticsearch-for-logs/

Curatorを使えばこういったことも楽にできそうではあるが、
わざわざそのためにPythonをいじるのもアレなので、簡単にシェルスクリプトで書いてみました。

@be-hase
be-hase / gist:c43423aa9f6522735ce6
Last active August 29, 2015 14:03
Handlebars.js "extended if"
Handlebars.registerHelper("if?",function(v1,operator,v2,options) {
switch (operator)
{
case "==":
return (v1==v2)?options.fn(this):options.inverse(this);
case "!=":
return (v1!=v2)?options.fn(this):options.inverse(this);
case "===":
@be-hase
be-hase / gist:6350921
Last active December 21, 2015 18:59
MySQL レプリケーション

###【master】mysqlのインストール

# yum install mysql-server

###【master】mysql関連のファイルが入っているか確認

# find / -name mysql