Skip to content

Instantly share code, notes, and snippets.

python

2と3が混在していて、かなりちがいます。相互運用性はないとおもっていいです。 Python 3 のほうが日本語の扱いが圧倒的にラクで直感的なので、こちらがおすすめです。

ふるいライブラリは 3 に対応してないですが、そういうのはメンテされていない証拠なので、つかうのを避けたほうがいいです。 (といいつつ、メジャーなものでも結構ある。こまる)

一部の Linux OS では Python 2 が標準インストールされていて、これを消したり上書きしたりするとぶっこわれます。 ユーザ環境でインストールするとか、 pyenv をつかうとか工夫してください。

Scala の勉強法

体系的な勉強法や定番はよくわからないので、自分が参考にしたものを挙げます。

Scala は Ruby 以上に変化の速い言語なので、本は参考程度にしかなりません。

プロジェクトでは 2.10 を使っていますが、 2.9 の機能は Obsolete になっているものがいくつもあります。 actor が外れたり macro が入ったりしてます。

. /etc/profile
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
@tomykaira
tomykaira / ar_buggy_beahvior.rb
Created June 1, 2014 03:33
ActiveRecord 4.0.5 behaves unexpectedly when has-many relationship and `where_values` are used in the same query.
require 'active_record'
require 'sqlite3'
prepare = <<SQL
create table viewers (
id integer primary key autoincrement, name, created_at, updated_at
);
create table notes (
id integer primary key autoincrement, name, created_at, updated_at
);
@tomykaira
tomykaira / Gemfile.lock
Created June 1, 2014 04:10
Env: x86_64 Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz GenuineIntel GNU/Linux, Gentoo, rbenv, ruby ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-linux]
GEM
remote: https://rubygems.org/
specs:
diff-lcs (1.2.5)
rspec (2.14.1)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
rspec-core (2.14.8)
rspec-expectations (2.14.5)
[branch]
autosetuprebase = always # default pull strategy is rebase
[merge]
keepBackup = false;
tool = vimdiff
[mergetool "p4merge"]
cmd = /opt/p4v/bin/p4merge "$BASE" "$LOCAL" "$REMOTE" "$MERGED"
keepTemporaries = false
trustExitCode = false
keepBackup = false
@tomykaira
tomykaira / extend.rb
Created July 6, 2014 08:24
The simplest webpay-extend application.
# -*- coding: utf-8 -*-
require 'sinatra'
require 'oauth2'
enable :sessions
# アプリケーション情報を持つクライアントオブジェクトを作成
client = OAuth2::Client.new('client_id', 'client_secret', :site => 'https://webpay.jp')
get '/' do
%Q{<a href="/request">テストアプリケーションを認可する</a>}
@tomykaira
tomykaira / remove_rcov_reports.sh
Last active August 29, 2015 14:04
Remove RCov *.html files in /builds for Jenkins.
#!/bin/sh
# This simple shell script removes intermediate HTML files used by RCov and RubyMetrics plugin.
# RubyMetrics plugin extract data from HTML and save them to build.xml, so they are not used after tests are done.
# The HTML files are generated per tested file, then its number becomes enormous.
# Execute this script by cron or something to clean them up.
set -e
# Set this variable to the directory you want to cleanup
# example: /var/lib/jenkins/jobs/JOB_NAME/builds
BUILDS_DIR=''
@tomykaira
tomykaira / disable_ctrl_k.js
Created August 29, 2014 07:37
Disable Ctrl+K in Slack, because it is to delete a line.
// ==UserScript==
// @name Disable ctrl+k
// @namespace http://userscript.org/users/tomy_kaira
// @include https://webpay.slack.com/*
// @version 1
// ==/UserScript==
var origKeyDown = TS.ui.onWindowKeyDown;
TS.ui.onWindowKeyDown = function (j) {
if (TS.ui.isUserAttentionOnChat() && !j.altKey && j.which == 75 && TS.utility.cmdKey(j)) {
@tomykaira
tomykaira / letter_opener_in_rails.rb
Created September 21, 2014 23:19
How to use letter_opener for debugging mail messages in tests
it do
require 'letter_opener'
mail.delivery_method LetterOpener::DeliveryMethod, location: Rails.root.join('tmp', 'letter_opener').to_s
mail.deliver
end