Skip to content

Instantly share code, notes, and snippets.

View iambowen's full-sized avatar
💭
on distributed system

bowen iambowen

💭
on distributed system
View GitHub Profile
@iambowen
iambowen / error.md
Created October 28, 2013 07:47
Does latest version of resi-client still support ruby 1.8.7?

For I get this error when I try to use ree-1.8.7 to install chef which depends on rest-client.

~> gem install rest-client
ERROR:  Error installing rest-client:
   mime-types requires Ruby version >= 1.9.2.

My question is that does rest-client get rid of supporting 1.8.7 completely? If not, how could I make it happen under ruby 1.8.7, by downgrading the version?

Sublime Text 2 – Useful Shortcuts (PC)

Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.

Editing

Ctrl+C copy current line (if no selection)
Ctrl+X cut current line (if no selection)
Ctrl+⇧+K delete line
Ctrl+↩ insert line after

Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:

1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...

By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.

Project Euler

@iambowen
iambowen / Problem_1.markdown
Last active December 22, 2015 03:09
First problem to solve.

The following is the description of first problem we need to solve, try finish it before Friday. There's no rule to complete the issue, you can use either languages with either way. Clean code is also not a requirement. In another way, there's no "Jiecao" to finish that.

Problem 1

If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000.

Problem from

@iambowen
iambowen / gist:6376281
Last active December 21, 2015 22:38
Node js implementation
@iambowen
iambowen / gist:6376252
Last active December 21, 2015 22:38
scala implementation
Range(1,11).filter(_%2 == 0).map(_/2).map(println)
@iambowen
iambowen / gist:6376234
Last active December 21, 2015 22:38
go implementation
package main
import "fmt"

func main() {
  a := [...]int {1, 2, 3, 4, 5, 6, 7 ,8, 9, 10}
    
    for i :=range a {
        if a[i] % 2 == 0 {
 fmt.Println(a[i] / 2)
@iambowen
iambowen / gist:6376228
Last active December 21, 2015 22:38
shell implementation
for i in {1..10}
do
  if [ "$(expr $i / 2)" -eq 0 ]; then
     echo `expr $i / 2`
   if
done
@iambowen
iambowen / gist:6376181
Last active December 21, 2015 22:38
ruby implementation
(1..10).select{|x| x % 2 == 0}.map{|x| puts x / 2}
@iambowen
iambowen / gist:6376158
Last active December 21, 2015 22:42
Clojure implementation
(print (map (fn [a] (/ a 2)) (filter even? (range 1 11))))