Skip to content

Instantly share code, notes, and snippets.

View suzukimilanpaak's full-sized avatar

Tatsuya Suzuki suzukimilanpaak

  • Manchester, UK
  • 15:32 (UTC +01:00)
View GitHub Profile
# - Description
# This program enables you to create a buck up with date in its name,
# which contains files symbolic links in copy source refers.
#--------------------
# Usage
#--------------------
# $ bak /path/to/source /path/to/dest
#!/bin/sh
1 鈴木 達矢 19800324 1
3 Matthew Day 19850324 0
5 人見 裕 19811103 3
2 Jerome Kumori 19880505 1
4 Agata Znamienkiewicz 19821213 0
# This is a code snippet for my exercise on Lambda and Proc.
# Let's say there is a supermarket which sells only three products bellow.
# Product Code | Name | Price
# FR1 | Fruit Tea | £3.11
# SR1 | Strawberries| £5.00
# CF1 | Coffee | £11.23
# - It offers buy-one-get-one-free for fruit tea.
# - It offers strawberries to get a price discount for bulk purchases. If you buy 3 or more strawberries, the price should drop to £4.50.
@suzukimilanpaak
suzukimilanpaak / htmls2hamls
Created October 13, 2011 09:50
bash script to html2haml for multiple files
# Usage;
# htmls2hamls RAILS_ROOT/app/views/TARGETS
# Assume $1 is path to directory containing views in a rails project and $2
: $1
if test -d $1
then echo 'processing..'
else echo Directory path must be specified for first argument; exit
@suzukimilanpaak
suzukimilanpaak / autoreconf.log
Created November 26, 2011 08:30
Error with autoreconf when installing rvm 1.9.2
$ cat /home/suzukimilanpaak/.rvm/log/libiconv/autoreconf.log
[2011-11-26 16:52:46] autoreconf -is --force
configure.ac:134: warning: AC_LANG_CONFTEST: no AC_LANG_SOURCE call detected in body
../../lib/autoconf/lang.m4:194: AC_LANG_CONFTEST is expanded from...
../../lib/autoconf/general.m4:2591: _AC_COMPILE_IFELSE is expanded from...
../../lib/autoconf/general.m4:2607: AC_COMPILE_IFELSE is expanded from...
../../lib/m4sugar/m4sh.m4:606: AS_IF is expanded from...
../../lib/autoconf/general.m4:2032: AC_CACHE_VAL is expanded from...
../../lib/autoconf/general.m4:2053: AC_CACHE_CHECK is expanded from...
configure.ac:134: the top level
@suzukimilanpaak
suzukimilanpaak / let_and_timecop_spec.rb
Created October 29, 2012 06:21
Spec wiht let! and Timecop
# coding: utf-8
require 'spec_helper'
describe Time do
TIMETABLE = [Time.local(2012, 10, 26, 21), Time.local(2012, 11, 2, 21)]
describe '#now' do
let!(:now) {
now = Time.now
puts "in let! #{now}"
@suzukimilanpaak
suzukimilanpaak / 0.oop.rb
Last active December 28, 2015 16:19
my lecture on 18th Nov.
class Human # => design
def say_hello(name)
'hello' + name
end
end
@human = Human.new # instance
@human.say_hello('David')
#=> 'hello David'
@suzukimilanpaak
suzukimilanpaak / Website.rb
Created January 1, 2014 04:12
Counter cache for HABTM
class Website < ActiveRecord::Base
has_and_belongs_to_many :categories, after_add: :increment_categories_counter_cache, after_remove: :decrement_categories_counter_cache
private
def increment_categories_counter_cache(category)
Category.increment_counter(:websites_count, category.id )
end
def decrement_categories_counter_cache(category)
@suzukimilanpaak
suzukimilanpaak / draw_equilateral_polygon.pde
Last active January 2, 2016 01:59
Draw a Equilateral Polygon according to the number of vertexes in Processing language 2.1
// Size of display
int DISPLAY_WIDTH = 500;
int DISPLAY_HEIGHT = 500;
// Colours
int BLACK = 0;
int WHITE = 255;
int CENTER_X = 0;
int CENTER_Y = 0;
@suzukimilanpaak
suzukimilanpaak / drawing_dosts_with_fibonacci.pde
Created January 4, 2014 04:54
Drawing dots with Fibonacci
import java.util.*;
Fibonacci fibonacci;
float unitAngle;
float unitFibonacciAngle;
int NUM_POINTS = 90;
float NUM_DISTANCE_FROM_APEX = 1;
class Fibonacci {