Skip to content

Instantly share code, notes, and snippets.

View shionryuu's full-sized avatar
😪
I may be slow to respond.

shionryuu

😪
I may be slow to respond.
View GitHub Profile
@shionryuu
shionryuu / gvm_usage.md
Last active August 29, 2015 14:07
golang gvm版本控制
# Makefile for a go project
#
# Author: Jon Eisen
# site: joneisen.me
#
# Targets:
# all: Builds the code
# build: Builds the code
# fmt: Formats the source files
# clean: cleans the code
@shionryuu
shionryuu / fibonacci.go
Created October 23, 2014 06:44
golang fibonacci generator
package main
import (
"fmt"
)
/*
* fibonacci generator
*/
func fibonacci() func() int64 {
@shionryuu
shionryuu / delete_svn_missing.md
Last active August 29, 2015 14:08
use powershell to delete svn missing files

PowerShell 获取并删除svn丢失的文件

# recommended
function svn_missing
{
    svn status | where { $_ -match '\!\s*(?<x>\S*)' } | foreach { $matches.x }
    # or
    # svn status | where { $_ -match '\!\s*(?<x>\S*)' } | foreach { $matches['x'] }
 # or
@shionryuu
shionryuu / main.go
Created April 22, 2015 11:23
ants-go 测试
package main
import (
"encoding/json"
"fmt"
"github.com/wcong/ants-go/ants/action/http"
"io"
"io/ioutil"
Http "net/http"
"net/url"
@shionryuu
shionryuu / python_challenge_01.py
Created June 11, 2015 12:18
Python Challenge 01
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# http://www.pythonchallenge.com/pc/def/map.html
import string
text = '''
g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj.
'''
@shionryuu
shionryuu / python_challenge_02.py
Created June 11, 2015 12:19
Python Challenge 02
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# http://www.pythonchallenge.com/pc/def/ocr.html
import re
# the content of rare_characters.txt is from the
# source of ocr.html
with open('rare_characters.txt', 'r') as file1:
@shionryuu
shionryuu / interview_2015_09_22.md
Last active September 22, 2015 07:14
面试题 by erlang初学者

1, 有100盏灯,从1~100编上号,开始时所有的灯都是关着的,第一次,把所有编号是1的倍数的灯的开关状态改变一次;第二次,把所有编号是2的倍数的灯的开关状态改变一次;第三次,把所有编号是3的倍数的灯的开关状态改变一次;以此类推,直到把所有编号是100得倍数的灯的开关状态改变一次。问,此时所有开着的灯的编号。

答案:10盏是亮的,分别是1 4 9 16 25 36 49 64 81 100;90盏是灭的。这是因为除了这些平方数以外,其余的任意一个数都能分成不同的两数乘积,质数可以分为1和本身,合数都可以分成若干组乘积(每组两个),因此,这些等都被拉了偶数倍,也就是灭的,平方数因为在被自己的开方数拉是只有一次,所以是奇数次,也就是亮的。随便举两个例子以证明。36分别被1、2、3、4、6、9、12、18、36拉过,共是9次,亮。38分别被1、2、19、38拉过,共是4次,灭。所以10盏是亮的;90盏是灭的

2.假设在一段高速公路上,30分钟之内见到汽车经过的概率是0.95。那么,在10分钟内见到汽车经过的概率是多少?(假设缺省概率固定)

答案:这题的关键在于0.95是见到一辆或多辆汽车的概率,而不是仅见到一辆汽车的概率。在30分钟内,见不到任何车辆的概率为0.05。因此在10分钟内见不到任何车辆的概率是这个值的立方根,而在10分钟内见到一辆车的概率则为1减去此立方根,也就是大约63%。

3.有四个人要在夜里穿过一条悬索桥回到宿营地。可是他们只有一支手电,电池只够再亮17分钟。过桥必须要有手电,否则太危险。桥最多只能承受两个人同时通过的重量。这四个人的过桥速度都不一样:一个需要1分钟,一个需要2分钟,一个需要5分钟,还有一个需要10分钟。他们如何才能在17分钟之内全部过桥?

@shionryuu
shionryuu / circle.yml
Created September 29, 2015 04:35
fix CircleCI docker API version mismatch
machine:
pre:
- |
sudo curl -L -o /usr/bin/docker 'http://s3-external-1.amazonaws.com/circle-downloads/docker-1.8.2-circleci'
sudo chmod 0755 /usr/bin/docker
sudo service docker start
dependencies:
override:
- sudo pip install -U docker-compose==1.4.2