Skip to content

Instantly share code, notes, and snippets.

View cnosuke's full-sized avatar

cnosuke cnosuke

  • STADIUM Co., Ltd.
  • Tokyo, Japan
  • X @cnosuke
View GitHub Profile
@cnosuke
cnosuke / kayac_post.rb
Created October 23, 2012 09:53
iPhoneに通知出したいときに使う用のアレをkayacさんありがとう的なアレ
# coding: utf-8
#
# Copyright (C) 2012 Shinnosuke TAKEDA All rights reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@cnosuke
cnosuke / gmail.rb
Created October 23, 2012 10:03
action_mailerでメールを送るあれ
# coding:utf-8
require 'action_mailer'
class GMails < ActionMailer::Base
default from: "noreply@example.com"
def sendmail
mail(:to => "to@example.com",
:subject => "Welcome test mail",
:body => "hello!" )
@cnosuke
cnosuke / human.rb
Created October 23, 2012 10:23
そんなに深い意味は無いけど動的にclass選らんであんなことやこんなこと出来たら便利そうな時あるんじゃねっていうアレ
class Human
end
class Male < Human
def self.who
'I am male.'
end
def self.sex?(s)
@cnosuke
cnosuke / stable_mariage_problem.rb
Created October 30, 2012 09:09
STABLE MARIAGE PROBLEM
# <STABLE MARIAGE PROBLEM>
#
# Copyright (C) 2012 Shinnosuke TAKEDA All rights reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@cnosuke
cnosuke / password_maker.rb
Created October 30, 2012 14:20
Password Maker
# Copyright (C) 2012 Shinnosuke TAKEDA All rights reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@cnosuke
cnosuke / ethtool
Created December 22, 2012 15:10
my iptables file
#!/bin/sh
# Copyright (C) 2012 Shinnosuke TAKEDA All rights reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
File.expand_path('../', __FILE__)
__dir__
@cnosuke
cnosuke / radiko_recorder.sh
Created April 9, 2013 08:03
script for recoding radiko.jp
#!/bin/sh
OUTFILEPREFIX=$1
RECTIMEMIN=$2
CHANNEL=$3
FFMPEG=/usr/bin/ffmpeg
FFMPEGOPT="-acodec libmp3lame -ab 64kb -ac 1 -ar 44100"
OUTFILEBASEPATH=/home/cnosuke/radiko/data
FLVFILEEXT=".flv"
MP3FILEEXT=".mp3"
@cnosuke
cnosuke / ecard.rb
Last active December 19, 2015 10:29
ECARD from KAIJI
require 'pry'
module ECard
class Game
attr_reader :players
def initialize
@players = [ Player.new(:emperor), Player.new(:slave) ]
end
@cnosuke
cnosuke / gist:6896318
Created October 9, 2013 04:43
Object#try and NilClass#try
class Object
def try(*a, &b)
if a.empty? && block_given?
yield self
else
public_send(*a, &b) if respond_to?(a.first)
end
end
end