Skip to content

Instantly share code, notes, and snippets.

View alea12's full-sized avatar
🏠

alea12 alea12

🏠
View GitHub Profile
@alea12
alea12 / .vimrc
Last active February 13, 2016 08:38
if has('vim_starting')
set nocompatible
set runtimepath+=~/.vim/bundle/neobundle.vim/
endif
if !has('gui_running')
set t_Co=256
endif
call neobundle#begin(expand('~/.vim/bundle'))
@alea12
alea12 / tv_scraping_1.rb
Last active December 31, 2015 02:58
テレビ王国 (tv.so-net.ne.jp) のテレビ番組表から、番組詳細情報を取得する
require 'open-uri'
require 'nokogiri'
# date
date = '20131213'
# open tv.so-net.ne.jp and parse it by Nokogiri
target = 'http://tv.so-net.ne.jp/chart/23.action?head=' + date + '0000&span=24'
doc = Nokogiri::HTML(open(target))
@alea12
alea12 / nokogiri_ajax.rb
Created December 12, 2013 03:27
nokogiri で ajax 使われてるサイトをパースしたい場合、どうしたら良いんだろう
require 'nokogiri'
require 'open-uri'
require 'pp'
html = open('')
sleep 10
doc = Nokogiri::HTML(html)
@alea12
alea12 / where_is_mysql_sock.sh
Created December 2, 2013 03:15
mysql.sock の場所を確認する方法
mysql_config --socket
@import 'compass';
* {
@include box-shadow(0px 0px 10px black, 0px 0px 10px black);
}
gem 'sass-rails', '~> 4.0.0'
gem 'compass-rails', github: 'Compass/compass-rails', branch: 'rails4-hack'
@alea12
alea12 / twitter_gem_v5.rb
Created November 25, 2013 07:12
Twitter gem のバージョンをあげたら Twitter.configure ができなくなってた
# Global configuration has been removed, as it was not threadsafe.
# Without this, you will face an error saying: NoMethodError: undefined method `configure' for Twitter:Module
client = Twitter::REST::Client.new do |config|
config.consumer_key = "YOUR_CONSUMER_KEY"
config.consumer_secret = "YOUR_CONSUMER_SECRET"
config.access_token = "YOUR_ACCESS_TOKEN"
config.access_token_secret = "YOUR_ACCESS_SECRET"
end
@alea12
alea12 / post.rb
Created September 21, 2013 14:19
なんか Rails というか ruby におけるオブジェクトの扱い方を完全に間違えてる気がする
class Post < ActiveRecord::Base
# posts table から、public が 1 なレコードの id 一覧を取得する
def self.public_post_id_list
Array(select('id').where(public:1).order('id desc')).map{|a| a.id.to_i}
end
end
@alea12
alea12 / rainfall.php
Last active December 21, 2015 18:39
降水量をもとに、雨の強さを気象庁風に表現する
<?php
/**
* 降水量をもとに、雨の強さを気象庁風に表現する
* 参考: 気象庁 | 雨と風の表 http://www.jma.go.jp/jma/kishou/know/yougo_hp/amehyo.html
*
* @example
* <code>
* echo getRainstatus(15); // => 'やや強い雨'
* </code>

CEDEC 2013 AI CHALLENGE "TERRA FORMING"

MENU

  • Information
  • Schedule
  • Download
  • Documents