Skip to content

Instantly share code, notes, and snippets.

View ta1kt0me's full-sized avatar
🐢
slow

ta1kt0me

🐢
slow
View GitHub Profile
-(NSMutableArray *)createNSMutableArray:(int)max
{
NSMutableArray *numberArray = [NSMutableArray new];
for (int i=1; i<=max; i++) {
[numberArray addObject:[NSNumber numberWithInt:i]];
}
[self sortByRandom:numberArray];
return numberArray;
}
UIAlertView *alert = [UIAlertView new];
alert.title = @"Complete!!!";
alert.message = @"You are Perfect!";
[alert addButtonWithTitle:@"OK"];
[alert show];
@ta1kt0me
ta1kt0me / gist:ecf1ede307d6a93a90a7
Last active August 29, 2015 14:07
CSVのデータ行の合計を出力する
###```csv test.csv
# j,m,h,s
# 1,2,3,4
# 5,6,7,8
# 9,0,1,2
###```
data = CSV.open("test.csv","r")
header = data.take(1)[0]
calc = Array.new(header.size).map{[]}

Switch To Vim For Good

This guide is coming from an email I used to send to newcomers to Vim. It is not intended to be a complete guide, it is about what worked for me.

Some background: my decision to switch to Vim has been made a long time ago. Coming from TextMate 1, I wanted to learn an editor that is Open Source (so I don’t lose my time learning a tool that can be killed), cross platform (so I can use it everywhere), and powerful enough (so I won’t regret TextMate). For these reasons, Vim has always been the editor I wanted to learn, but it took me several years before I did it in a way that works for me. I tried to switch progressively, using the Janus Vim distribution for a few months, then got back to using TextMate 2 for a time, waiting for the next attempt… here is what finally worked for me.

Non Optional

  1. Watch the Derek Wyatt videos in order (at least the “Novice” ones for now): http://derekwyatt.org/vim/tutorials/
  2. Read the first part of this Stack
@ta1kt0me
ta1kt0me / vvv
Last active August 29, 2015 14:23
become a vimmer
# first
- https://getpocket.com/a/read/961571271
# useful
- http://matome.naver.jp/odai/2131556055506548701
- http://qiita.com/wadako111/items/5eb8e30aca1737ba6ba5
- http://postd.cc/how-to-boost-your-vim-productivity/
@ta1kt0me
ta1kt0me / ar_innodb_row_format.rb
Last active August 29, 2015 14:27 — forked from keitaj/ar_innodb_row_format.rb
It is forked from https://gist.github.com/keitaj/773c6ba89ffc722d60a5 . It changes ROW_FORMAT to COMPRESSED.
ActiveSupport.on_load :active_record do
module ActiveRecord::ConnectionAdapters
class AbstractMysqlAdapter
def create_table_with_innodb_row_format(table_name, options = {})
table_options = options.merge(:options => 'ENGINE=InnoDB ROW_FORMAT=COMPRESSED')
create_table_without_innodb_row_format(table_name, table_options) do |td|
yield td if block_given?
end
end
alias_method_chain :create_table, :innodb_row_format
@ta1kt0me
ta1kt0me / Gemfile
Created October 21, 2015 16:17
(大体)Single file Rails Application - https://github.com/suburi/simple-app
source "https://rubygems.org"
gem "rails"
gem "sqlite3"
@ta1kt0me
ta1kt0me / prime_number.rb
Created March 17, 2016 04:29
Sieve of Eratosthenes
STDIN.read.split("\n").map {|i| i.chomp.to_i}.each do |n|
x = n
# lst = (3..x).to_a.select(&:odd?).unshift(2)
lst = (2..x).to_a
result = []
sqrt = Math.sqrt(x)
loop do
elem = lst.shift
result << elem
@ta1kt0me
ta1kt0me / code_review_note
Created July 4, 2016 02:48
コードレビューで注意すること
## refs
http://macotox.hateblo.jp/entry/2014/08/16/231842
@ta1kt0me
ta1kt0me / encode_clone.rb
Last active November 22, 2016 17:01
encoded clone create encoded clone
# http://pam-ya.com/blog/archives/2006/04/post-238.html
$code = <<-EOS
require 'openssl'
require 'base64'
class Clone
def generate
file_name = 'sample_' + Time.now.strftime('%F-%H%M%S%L') + '.rb'
File.open(file_name, 'w') do |f|
header = '$code = <<-EOS'
footer = 'EOS'