Skip to content

Instantly share code, notes, and snippets.

@akishin
akishin / errbit_notifier.pl
Last active August 29, 2015 14:24
Perl から Errbit にデータ登録するサンプル
use strict;
use warnings;
use utf8;
use Data::Dumper;
use Furl;
use XML::Simple;
my $notify_url = 'http://errbit.example.com/notifier_api/v2/notices';
my $api_key = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
@akishin
akishin / tag.inc.php
Created June 10, 2014 02:31
ローカルで使う PukiWiki 用の HTML タグ表示用プラグイン 2。中身は一緒。
<?php
function plugin_tag_inline()
{
$args = func_get_args();
array_pop($args);
return join(',', $args);
}
?>
@akishin
akishin / html.inc.php
Created June 10, 2014 02:29
ローカルで使う PukiWiki 用の HTML タグ表示用プラグイン
<?php
function plugin_html_inline()
{
$args = func_get_args();
array_pop($args);
return join(',', $args);
}
?>
@akishin
akishin / checkcron01.jpg
Last active August 29, 2015 14:01
image test
checkcron01.jpg
@akishin
akishin / sidekiq
Last active December 20, 2015 08:59
Gitlab の起動スクリプトを Passenger で使うために Sidekiq のみにしたもの。
#!/bin/bash
#
# Sidekiq
# chkconfig: 2345 82 55
# processname: sidekiq
# description: Runs sidekiq
# Include RedHat function library
. /etc/rc.d/init.d/functions
@akishin
akishin / readonlyable.rb
Created July 17, 2013 12:46
ActiveRecord read only model
module Readonlyable
extend ActiveSupport::Concern
def readonly?
return true
end
def before_destroy
raise ActiveRecord::ReadOnlyRecord
end
# https://gist.github.com/sue445/5261654
ja:
helpers:
actions: "Actions"
links:
back: "戻る"
cancel: "キャンセル"
confirm: "本当にいいですか?"
destroy: "削除"
@akishin
akishin / auto_compression_redis.rb
Created June 22, 2013 04:04
redis-rb auto compression client
# -*- coding: utf-8 -*-
require 'json'
require 'zlib'
class Redis
class Client
def call(command, &block)
if write?(command.first)
command[command.length - 1] = encode(command.last)
@akishin
akishin / RubyCompatibleShardedJedis.java
Created May 6, 2013 12:11
Jedis を使って redis-rb の Redis::Distributed 互換の ConsistentHashing を使用するための ShardedJedis 継承クラス。
package examples.redis;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.regex.Pattern;
import java.util.zip.CRC32;
@akishin
akishin / restful_authentication.rb
Last active December 13, 2015 18:08
restful-authentication で暗号化したパスワードに対応した sorcery 用 CryptoProvider。
# -*- encoding: utf-8 -*-
require "digest/sha1"
# restful-authentication の config/initializers/site_keys.rb に設定されている
# REST_AUTH_SITE_KEY の値を持ってきて設定
REST_AUTH_SITE_KEY = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
module Sorcery
module CryptoProviders
class RestfulAuthentication < SHA1