Skip to content

Instantly share code, notes, and snippets.

View ta1kt0me's full-sized avatar
🐢
slow

ta1kt0me

🐢
slow
View GitHub Profile
@ta1kt0me
ta1kt0me / ExerciseLoopsAndFunctions.go
Created January 22, 2017 07:03
Exercise: Loops and Functions
package main
import (
"fmt"
"math"
)
func Sqrt(x float64) float64 {
z := 9.0
for i := 0; i < 10; i++ {
@ta1kt0me
ta1kt0me / ExerciseStringers.go
Created January 22, 2017 04:11
Exercise: Stringers
package main
import (
"fmt"
"strconv"
)
type IPAddr [4]byte
func (ip IPAddr) String() string {
@ta1kt0me
ta1kt0me / fib.rb
Last active January 22, 2017 03:33
fib in ruby
def fib
a, b = 0, 1
Proc.new() {
a, b, c = b, b + a, a
c
}
end
f = fib
10.times {
@ta1kt0me
ta1kt0me / ExerciseFibonacciClosure.go
Last active January 21, 2017 14:59
Execise Fibonacci closure
// Execise: Fibonacci closure
package main
import "fmt"
// fibonacci is a function that returns
// a function that returns an int.
func fibonacci() func() int {
a, b := 0, 1
@ta1kt0me
ta1kt0me / ExerciseMaps.go
Last active January 21, 2017 14:50
Exercise: Maps
// Exercise: Maps
package main
import (
"golang.org/x/tour/wc"
"strings"
)
func WordCount(s string) map[string]int {
@ta1kt0me
ta1kt0me / ExerciseSlices.go
Last active January 21, 2017 14:42
Exercise Slices
// Exercise Slices
package main
import "golang.org/x/tour/pic"
func Pic(dx, dy int) [][]uint8 {
pic := make([][]uint8, dy)
for i, _ := range pic {
pic[i] = make([]uint8, dx)
for j, _ := range pic[i] {
require 'curses'
include Curses
init_screen
start_color
(Curses.constants.grep(/\AA_/) - [:A_ATTRIBUTES]).each.with_index do |e, i|
setpos(i, 0)
addstr(e.to_s)
setpos(i, 15)
@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'
@ta1kt0me
ta1kt0me / code_review_note
Created July 4, 2016 02:48
コードレビューで注意すること
## refs
http://macotox.hateblo.jp/entry/2014/08/16/231842
@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