Skip to content

Instantly share code, notes, and snippets.

@cockscomb
cockscomb / colorado.py
Created April 21, 2011 16:10
Script for getting images from CCAR
# coding: UTF-8
import os
import datetime
import mechanize
import urllib
# Set directory name.
directory_name = "images"
@cockscomb
cockscomb / get_wind.rb
Created September 26, 2011 09:05
Getting per 10 minutes wind data from Kishocho.
# encoding: UTF-8
require 'csv'
require 'date'
require_relative 'kishocho'
include Kishocho
# puts Kishocho.get_10_min_data(1192, Date.new(2010, 5, 1))
# encoding: UTF-8
module Choseki
require 'nokogiri'
require 'open-uri'
require 'date'
HEADER = ['Time', 'Height']
@cockscomb
cockscomb / growlmail.scpt
Created October 4, 2011 03:28
Growl when new messages arrived.
using terms from application "Mail"
on perform mail action with messages these_messages for rule this_rule
tell application "Mail"
set the message_count to the count of these_messages
repeat with i from 1 to the message_count
set this_message to item i of these_messages
-- GET THE SENDER OF THIS MESSAGE
set this_sender to the sender of this_message
-- GET SUBJECT OF MESSAGE
@cockscomb
cockscomb / growlichat.scpt
Created October 4, 2011 11:02
Growl when new message arrived.
using terms from application "iChat"
on message received this_message from this_buddy for this_chat
(*EXAMPLE: this routine automatically sends a random response to messages from specified buddies
set this_name to the name of this_buddy
if the name of this_buddy is in {"Johnny Appleseed"} then
set canned_responses to {"Oh, I know!", "I was just thinking about that.", "Maybe tomorrow.", "Seems logical."}
set this_response to some item of the canned_responses
send this_response to this_chat
end if
*)
@cockscomb
cockscomb / excel_column_name.py
Created November 3, 2011 15:49
Convert mutually Excel’s column names to numbers.
# -*- coding: utf-8 -*-
import string
import re
from functools import reduce
CHARS = string.ascii_uppercase
def number_to_char(number):
if number < 0: raise ValueError
# -*- coding: utf-8 -*-
from itertools import permutations
inputs = [1, 3, 5, 7, 9]
numbers = [7 * n[0] + 3 * n[1] + n[2] for n in permutations(inputs, 3)]
adoptables = list(filter(lambda x: x % 3 == 0, numbers))
@cockscomb
cockscomb / ios_japanese_documents_downloader.rb
Last active September 30, 2015 15:37
iOS Developer Library の日本語ドキュメント PDF を一括ダウンロードする Ruby スクリプト。Ruby 1.9.x 対応。
#! /usr/bin/env ruby
# encoding: UTF-8
require 'uri'
require 'json'
require 'open-uri'
require 'openssl'
require 'nokogiri'
def get_documents_info()
@cockscomb
cockscomb / make_executable.py
Created May 8, 2012 13:37
A plugin for Sublime Text 2. If the file you saved has no extension and start with shebang, this plugin make executable that file.
import sublime, sublime_plugin
import os, stat
class MakeExecutable(sublime_plugin.EventListener):
def on_post_save(self, view):
filename = view.file_name()
ext = os.path.splitext(filename)[1]
#!/usr/bin/env ruby
# coding: utf-8
puts ARGV.join(' ').split(//).collect { |s| 'U+%04X' % s.unpack('U')[0] }.join(' ')