Skip to content

Instantly share code, notes, and snippets.

View yancya's full-sized avatar
💭
😂

Shinta Koyanagi yancya

💭
😂
View GitHub Profile
@yancya
yancya / init.el
Last active June 6, 2020 09:35
今の emacs の設定ファイル
;;scratch の初期メッセージを消す
(setq initial-scratch-message "")
;;ツールバー不要
(tool-bar-mode -1)
;;スタートアップ画面を表示しない
(setq inhibit-startup-message t)
;; 対応するカッコを強調表示
@yancya
yancya / infinity_takoyaki.rb
Last active December 14, 2015 02:28
万葉.rb の無限たこやきを表現してみた
# -*- coding: utf-8 -*-
# Ruby >= 2.0.0
class Rubyist
def initialize
@ibukuro = Ibukuro.new
end
def mgmg(takoyaki)
begin
// ==UserScript==
// @name ねえねえ今どんな気持ち?
// @namespace http://udzura.jp/kokubun
// @description 国分太一fier
// @include https://www.facebook.com/*
// @version 0.0.1.20121205
// ==/UserScript==
(function () {
function pingTaichi () {
@yancya
yancya / gist:5288843
Created April 2, 2013 00:02
rabbit インストールメモ
brew install cairo
brew link cairo
brew install pango
brew install gtk+
brew install poppler --with-glib
brew install librsvg
brew tap homebrew/versions
brew install gstreamer010
brew install gst-plugins-base010
PKG_CONFIG_PATH=/usr/local/opt/libxml2/lib/pkgconfig gem i rabbit
@yancya
yancya / c.sh
Created April 10, 2013 16:37
C 言語の勉強するのに、いちいちコンパイルするのが面倒だったので、C のソース受け取って実行するスクリプト書いた。自動的に付与するヘッダの宣言は適宜増やす。
#!/bin/bash
echo '#include <stdio.h>' > source.c
cat $1 >> source.c
gcc source.c
rm source.c
./a.out
rm a.out
# 1 から n までの連続数を足す関数
def sum_one_to(n)
(1+n)*(n/2)+(1+n)/2*(n%2)
end
# ↑のほうが↓よりも圧倒的に高速
def sum_one_to(n)
(1..n).inject(0){|m,n| m+=n}
@yancya
yancya / gist:5703011
Created June 4, 2013 01:49
each_slice
(1..100).to_a.each_slice(15).to_a
#=> [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
# [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],
# [31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45],
# [46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60],
# [61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75],
# [76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90],
# [91, 92, 93, 94, 95, 96, 97, 98, 99, 100]]
(function(){
var total = 0;
var year = '2012';
function init(num) {
num = (typeof num !== 'number' ? 0 : num);
if(num === 0) {
$('<div/>').css({
position: 'fixed',
left: 0,
top: 0,
@yancya
yancya / crosstab_sample.sql
Last active December 19, 2015 09:19
PostgreSQL の crosstab サンプル
-- PostgreSQL 9.2 で動作確認
create extension tablefunc
;
select *
from crosstab('
select year, month, 5
from generate_series(2009, 2013) as year
cross join generate_series(1, 12) as month', '
@yancya
yancya / hexadecimal_to_sjis_string.rb
Last active December 19, 2015 12:29
PDF における 16進数表記の文字列のデコード... もっと簡単にやれないのかね...
"8A4682B382F182B182F182C982BF82CD".
split("").
each_slice(2).
map{|a| a.join.hex}.
each_slice(2).
map{|a| a.pack("c*").encode("utf-8", "Shift_JIS")}.
join