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"
"io/ioutil"
"regexp"
)
func main() {
var filename string
@guesslin
guesslin / 0_reuse_code.js
Created June 16, 2014 04:27
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@guesslin
guesslin / python_resources.md
Created June 16, 2014 04:33 — forked from jookyboi/python_resources.md
Python-related modules and guides.

Packages

  • lxml - Pythonic binding for the C libraries libxml2 and libxslt.
  • boto - Python interface to Amazon Web Services
  • Django - Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.
  • Fabric - Library and command-line tool for streamlining the use of SSH for application deployment or systems administration task.
  • PyMongo - Tools for working with MongoDB, and is the recommended way to work with MongoDB from Python.
  • Celery - Task queue to distribute work across threads or machines.
  • pytz - pytz brings the Olson tz database into Python. This library allows accurate and cross platform timezone calculations using Python 2.4 or higher.

Guides

#!/bin/bash
# Copyright 2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# Author:
#
source /lib/gentoo/functions.sh
scriptpath=${BASH_SOURCE[0]}
scriptname=${scriptpath##*/}
import os
base = os.path.abspath(
os.path.dirname(__file__)
)
# 4 spaces indent
KODOU_ROOT = os.path.normpath(os.path.join(_current_dir,
".."))
# hanging indent
@guesslin
guesslin / block_message.txt
Created September 17, 2015 08:40
gentoo block message
guesslin portage # emerge --update --newuse --deep --with-bdeps=y @world -av
These are the packages that would be merged, in order:
Calculating dependencies... done!
[ebuild U ] virtual/perl-version-0.990.900-r2::gentoo [0.990.900::gentoo] 0 KiB
[ebuild U ] virtual/perl-ExtUtils-CBuilder-0.280.217-r2::gentoo [0.280.217::gentoo] 0 KiB
[ebuild U ] dev-perl/XML-LibXML-2.12.100::gentoo [2.1.400-r1::gentoo] USE="{-test}" 454 KiB
[ebuild U ] x11-proto/fontsproto-2.1.3::gentoo [2.1.2::gentoo] USE="-doc" 151 KiB
[ebuild U ] x11-libs/libXfont-1.5.1::gentoo [1.4.8::gentoo] USE="bzip2 ipv6 -doc -static-libs -truetype" 492 KiB
package main
import (
"flag"
"fmt"
"io/ioutil"
"math/rand"
"os"
"strings"
"time"
@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()
package main
import (
"fmt"
"math"
)
func draw(radius, little, dist int) {
if radius == dist || little == dist {
fmt.Printf("*")
#!/bin/bash
a="hello"
l=`echo $a|wc -m`
echo ${a:($l-4):$l}