Skip to content

Instantly share code, notes, and snippets.

View gam0022's full-sized avatar
😇
なの

がむ gam0022

😇
なの
View GitHub Profile
@gam0022
gam0022 / q3_3.m
Created September 12, 2012 13:16
function [] = q3_3(m)
x = linspace(-40*pi,40*pi,1000);
y = 0;
for j = 0:m
y = y + sin(1/(1+j/50)*x);
end
plot(x,y);
@gam0022
gam0022 / asteroid.c
Created January 8, 2013 07:20
CG基礎 課題3 全方位シューティングゲーム
//
// title:
// 全方位シューティングゲーム
//
// how to play:
// カーソルキー左右:旋回
// カーソルキー上:ブースト
// スペース:ショット
#include <stdio.h>
@gam0022
gam0022 / octopress_filters.rb.diff
Last active December 12, 2015 04:09
h1の見出しにはアンカーリンクを作成する。
@@ -16,7 +16,7 @@ module OctopressFilters
end
def post_filter(input)
input = unwrap(input)
- RubyPants.new(input).to_html
+ RubyPants.new(input).to_html.gsub(/<h1>([^<].*[^>])<\/h1>/, '<h1><a name="\1" href="#\1">\1</a></h1>')
end
end
@gam0022
gam0022 / Gemfile
Last active December 26, 2015 07:09
BundlerでC拡張を含んだgemを公開する ref: http://qiita.com/gam0022/items/2ee82e84e5c9f608eb85
source 'https://rubygems.org'
# Specify your gem's dependencies in immutable_list.gemspec
gemspec
+gem "rake-compiler"
[~/Downloads]$ gem install -l unicode_math-1.2.0.gem
Successfully installed unicode_math-1.2.0
Parsing documentation for unicode_math-1.2.0
Installing ri documentation for unicode_math-1.2.0
1 gem installed
でも無限リストを処理できる
Enumerator.new{|y|
(1..Float::INFINITY).each{|n|
y << n*2
}
}.first(5) # => [2, 4, 6, 8, 10]
class Hoge
someInstanceProp: [1,2,3] # インスタンス変数
someInstanceMethod: -> # インスタンスメソッド
@callAnotherInstanceMethod() # インスタンスメソッドを呼ぶ
alert @someInstanceProp # ==> "hoge"
@someClassProp: "hogehoge" # クラス変数
@someClassMethod: -> # クラスメソッド
@callAnotherClassMethod() # 同一クラスのクラスメソッドを呼ぶ
alert @someClassProp # ==> "hogehoge"
@gam0022
gam0022 / Rakefile
Created December 7, 2014 03:54
Octopressで最後に編集した記事だけをgenerate ref: http://qiita.com/gam0022/items/7b5a6e4492c90583706f
# usage rake generate_only[my-post]
# thanks to http://rcmdnk.github.io/blog/2013/12/06/blog-octopress-rake/
desc "Generate only the specified post (much faster)"
task :generate_only, :filename do |t, args|
if args.filename
filename = args.filename
else
filename = Dir.glob("#{source_dir}/#{posts_dir}/*.#{new_post_ext}").sort_by{|f| File.mtime(f)}.last
end
puts "## Test build for #{filename}"
@gam0022
gam0022 / Gemfile
Created December 9, 2014 12:59
Rails4のアプリをHerokuで動かす ref: http://qiita.com/gam0022/items/e9e0fe3e195035873462
gem 'rails', '4.0.0'
# Use sqlite3 as the database for Active Record
-gem 'sqlite3'
+gem 'sqlite3', groups: %w(test development), require: false
+gem 'pg', groups: %w(production), require: false
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'
@gam0022
gam0022 / file0.txt
Last active August 29, 2015 14:14
change_column で 型を integer や boolean に変更すると失敗する問題の解決方法 ref: http://qiita.com/gam0022/items/a73910de5b8eb44e5b13
[~/RubymineProjects/drwallet]$ rake db:migrate
== ChangeColumnsToCreditCards: migrating =====================================
-- change_column(:credit_cards, :etc_issuance, :boolean)
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
PG::Error: ERROR: column "etc_issuance" cannot be cast automatically to type boolean
HINT: Specify a USING expression to perform the conversion.
: ALTER TABLE "credit_cards" ALTER COLUMN "etc_issuance" TYPE boolean/Users/gam0022/RubymineProjects/drwallet/db/migrate/20150206071431_change_columns_to_credit_cards.rb:3:in `change'
Tasks: TOP => db:migrate