Skip to content

Instantly share code, notes, and snippets.

View guesslin's full-sized avatar

Yu-han Lin guesslin

View GitHub Profile
package main
import "fmt"
type Element struct {
Keyword, Title string
}
func deleteSliceFromMapWrong(elements []Element, blockedSource map[string]int) []Element {
for i, item := range elements {
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def foo(i):
s = 0
for j in xrange(i):
s += j # dummy sum, 只是為了讓迴圈裡面有東西而已
package main
import (
"fmt"
"gopkg.in/cheggaaa/pb.v1"
"io/ioutil"
"net/http"
"time"
)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import time
def numeric_compare(x, y):
return x - y
package main
import (
"fmt"
)
func multi(i, j int) {
if i == 0 {
return
}
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import ConfigParser
class Config(object):
"""Configuration file parser"""
def __init__(self, cfg):
package main
import (
"fmt"
)
func mySqrt(x int) int {
if x <= 1 {
return x
}
#!/bin/bash
a="hello"
l=`echo $a|wc -m`
echo ${a:($l-4):$l}
package main
import (
"fmt"
"math"
)
func draw(radius, little, dist int) {
if radius == dist || little == dist {
fmt.Printf("*")
@guesslin
guesslin / timethis.py
Created October 19, 2015 08:24
time this by function decroators
import time
from functools import wraps
def timethis(func):
@wraps(func)
def func_wrap(*args, **kwargs):
tstart = time.time()
result = func(*args, **kwargs)
tstop = time.time()