Skip to content

Instantly share code, notes, and snippets.

<match fluent.**>
type record_modifier
tag internal.message
host ${hostname}
tag_key original_tag
include_tag_key
</match>
CREATE TABLE todesking (created_at text, status int);
INSERT INTO todesking VALUES
('01-01', 0),
('01-02', 0),
('01-03', 1),
('01-04', 0)
;
SELECT
CREATE FUNCTION eval(sql Text) RETURNS SETOF Record AS $$
BEGIN
RETURN QUERY EXECUTE sql;
RETURN;
END;
$$ LANGUAGE plpgsql;
SELECT * FROM eval('SELECT * FROM( VALUES (1), (3) ) AS t') AS (i Int);
i
#!/usr/bin/env ruby
require 'twilio-ruby'
require 'json'
require 'optparse'
require 'uri'
require 'logger'
module TwilioCall
class Conf
#include <msgpack.h>
int main()
{
msgpack_sbuffer sbuf;
msgpack_sbuffer_init(&sbuf);
msgpack_packer pk;
msgpack_packer_init(&pk, &sbuf, msgpack_sbuffer_write);
@choplin
choplin / twilio-caller.rb
Last active December 26, 2015 16:59
cli tool for calling using twilio
#!/usr/bin/env ruby
require 'twilio-ruby'
require 'json'
require 'optparse'
require 'uri'
require 'logger'
module TwilioCall
class Conf
-- 準備
psql1 $ create table foo(v text);
psql1 $ create table bar(v text);
psql1 $ insert into foo values ('foo');
psql1 $ insert into tmp values ('bar');
-- swap: bar -> foo, foo -> bar
psql1 $ begin;
psql2 $ begin;
@choplin
choplin / rename.sql
Last active December 25, 2015 06:09
-- 準備
psql1 $ create table foo(v text);
psql1 $ create table tmp(v text);
psql1 $ insert into foo values ('foo');
psql1 $ insert into tmp values ('tmp');
-- rename: tmp -> foo
psql1 $ begin;
psql2 $ begin;
@choplin
choplin / explains.sql
Last active December 22, 2015 03:49
ここの記述が怪しいという話 http://d.hatena.ne.jp/Sikushima/20130828/1377663112
-- バージョン
SELECT version();
version
-----------------------------------------------------------------------------------------------------------------------------------------------
PostgreSQL 9.2.0 on x86_64-apple-darwin11.4.2, compiled by Apple clang version 4.0 (tags/Apple/clang-421.0.60) (based on LLVM 3.1svn), 64-bit
(1 row)
-- ランダム文字
CREATE OR REPLACE FUNCTION random_char() RETURNS text AS $$
SELECT chr((round((random() * 25)::numeric, 0))::int + 97);
package main
import (
"net"
"fmt"
"runtime"
"sync"
"time"
)