Skip to content

Instantly share code, notes, and snippets.

@physacco
physacco / Build.sh
Created August 19, 2014 09:24 — forked from AngryAnt/Build.sh
mcs -target:library -out:MyAssembly.dll -r:/Applications/Unity/Unity.app/Contents/Frameworks/UnityEngine.dll MyAssembly.cs
@physacco
physacco / find_small_images.py
Created March 2, 2015 18:10
Search in current directory for image files that is smaller than specified resolution and optionally remove them.
import os
import re
import sys
import optparse
from PIL import Image
IMAGE_EXT_PATTERN = re.compile(r'\.(jpe?g|png|gif|bmp)', re.IGNORECASE)
def safe_int(string):
try:
@physacco
physacco / zwc.py
Last active December 14, 2015 05:29
Chinese Word Counter
#!/usr/bin/env python
# encoding: utf-8
# Name: Chinese Word Counter
# Description: This is a word counter for Chinese. It reads text from stdin,
# filters white spaces (including the full-width Chinese blank-space character),
# and then counts the remaining characters. In my tests, it usually produces
# the same result as WPS. It may be useful for some writers.
# Example: zwc.py < foo.txt
# Author: physacco
@physacco
physacco / goagent
Last active December 14, 2015 09:08
GoAgent init script for Redhat/Fedora.
#!/bin/sh
# goagent: GoAgent init script for Redhat/Fedora.
# Written by physacco. 2013/03/01
# To start at boot time:
# 1. copy this file to /etc/init.d/goagent
# 2. chkconfig goagent on
# ---------------------
@physacco
physacco / http-hello.go
Last active December 14, 2015 16:18
A simple HTTP server in Go. From A Tour of Go.
package main
import (
"fmt"
"runtime"
"net/http"
)
type Hello struct{}
@physacco
physacco / tcp-echo-server-with-bufio.go
Created March 8, 2013 03:00
A TCP echo server demo.
package main
import (
"os"
"fmt"
"net"
"bufio"
)
func handleConnection(conn net.Conn) {
@physacco
physacco / tcp-echo-client-with-bufio.go
Created March 8, 2013 03:01
A TCP echo client demo.
package main
import (
"os"
"fmt"
"net"
"time"
"bufio"
)
@physacco
physacco / install-vimfiles-for-go.sh
Created March 8, 2013 08:39
Install vim plugin for the go programming language. Tested on Fedora.
#!/bin/sh
GOROOT="/home/i/src/go"
VIMFILES="/usr/share/vim/vimfiles"
mkdir -p $VIMFILES/autoload/go
cp -i $GOROOT/misc/vim/ftdetect/gofiletype.vim $VIMFILES/ftdetect/
cp -i $GOROOT/misc/vim/syntax/go.vim $VIMFILES/syntax/
cp -i $GOROOT/misc/vim/syntax/godoc.vim $VIMFILES/syntax/
cp -i $GOROOT/misc/vim/autoload/go/complete.vim $VIMFILES/autoload/go/
@physacco
physacco / config.ru
Created March 9, 2013 09:58
Send, receive and process binary data in web browser. Using XMLHTTPRequest, ArrayBuffer and ArrayBufferViews. Tested on Firefox 20.0.
# encoding: utf-8
# Tested on ruby 1.9.2
class HTTPNotFound < Exception
end
class MimeTypes
HTML = "text/html; charset=utf-8"
JAVASCRIPT = "application/javascript: charset=utf-8"
BINARY = "application/octet-stream; charset=binary"
@physacco
physacco / test_flag.go
Created March 10, 2013 05:04
Test the usage of the flag package in go's stdlib.
package main
import (
"os"
"fmt"
"flag"
)
func main() {
help := flag.Bool("help", false, "Print help message")