Skip to content

Instantly share code, notes, and snippets.

View kaochenlong's full-sized avatar
🖐️
World Peace!

Eddie Kao kaochenlong

🖐️
World Peace!
View GitHub Profile
list = [37, 38, 39, 40, 41]
list.shuffle.each_slice(4) do |team|
p team.sort
end
func add(x: Int)(y: Int) -> Int {
return x + y
}
let add100 = add(100) // 這邊等於產生了一個會加 100 的 function
println(add100(y:20)) // 得到 120
# rb_ary_join
VALUE
rb_ary_join(VALUE ary, VALUE sep)
{
long len = 1, i;
int taint = FALSE;
int untrust = FALSE;
VALUE val, tmp, result;
Question 1
>> 2.21 * 7
=> 15.469999999999999
>> "%0.2f" % (2.21 * 7)
=> "15.47"
Question 2
>> 3.1415.round(3)
=> 3.142
extension Int {
func times(task:() -> ()) {
for i in 0..self {
task()
}
}
}
5.times {
println("Hey! You look really like Ruby")
require "faker"
names = []
20.times do
names << Faker::Name.last_name
end
p names
f = open('access.log')
ip_list = {}
for line in f.readlines():
ip = line.split(' ')[0]
ip_list[ip] = ip_list.get(ip, 0) + 1
f.close()
sorted_ip_list = sorted(ip_list.items(), key=lambda x: x[1])
//
// ViewController.m
// buttonDemo
//
// Created by 高 見龍 on 13/9/22.
// Copyright (c) 2013年 高 見龍. All rights reserved.
//
#import "ViewController.h"
// NSObject+Utils.h
#import <Foundation/Foundation.h>
@interface NSObject (Utils)
- (BOOL) isNull;
- (BOOL) isNotNull;
@end