Skip to content

Instantly share code, notes, and snippets.

View zchee's full-sized avatar
😩
want to Go knowledge...

Koichi Shiraishi zchee

😩
want to Go knowledge...
View GitHub Profile
#include <iostream>
void setBackground(unsigned r, unsigned g, unsigned b)
{
std::cout << "\x1b[48;2;" << r << ';' << g << ';' << b << 'm';
}
int main()
{
int point[4][3] = { {255,0,0},
@zchee
zchee / minimal-docker-hosts.md
Created January 22, 2016 12:11 — forked from ailispaw/minimal-docker-hosts.md
メモ:Docker ホスト用軽量OS(30MB以下)の比較
DhyveOS DockerRoot RancherOS Boot2Docker Hyper on Mac (*7)
Version 2.0.0 1.2.8 0.4.2 1.9.1 0.4.0
Size 12 MB 13.7 MB 29 MB 30 MB 4.6 MB
Kernel 4.3.3 4.3.3 4.2.3 4.1.13 4.0.4
User Land Buildroot(uClibc) + BusyBox v1.24.1 Buildroot(GLIBC) + BusyBox v1.24.1 Buildroot(GLIBC) + BusyBox v1.23.2 Tiny Core Linux v6.4.1 -
Docker 1.9.1 1.9.1 1.9.1 1.9.1 -
Storage Driver btrfs overlay overlay (*2) aufs (*2) VDI
TLS - (*9) -
Vagrant box - (v0.4.1) (*3) -
@zchee
zchee / complete.cc
Created February 15, 2016 21:55 — forked from xavierd/complete.cc
Hacking with libclang completion.
#include <clang-c/Index.h>
#include <cstdlib>
#include <iostream>
/*
* Compile with:
* g++ complete.cc -o complete -lclang -L/usr/lib/llvm
* Run with:
* LIBCLANG_TIMING=1 ./complete file.cc line column [clang args...]
*/
@zchee
zchee / profile.py
Created February 16, 2016 09:41 — forked from myusuf3/profile.py
Simple little profiling decorator in python.
import cProfile
def profile_this(fn):
def profiled_fn(*args, **kwargs):
# name for profile dump
fpath = fn.__name__ + '.profile'
prof = cProfile.Profile()
ret = prof.runcall(fn, *args, **kwargs)
prof.dump_stats(fpath)
@zchee
zchee / coverage.sh
Created February 28, 2016 20:16 — forked from adamclerk/coverage.sh
gb coverage script
#!/bin/sh
# Generate test coverage statistics for Go packages.
#
# Works around the fact that `go test -coverprofile` currently does not work
# with multiple packages, see https://code.google.com/p/go/issues/detail?id=6909
#
# Usage: script/coverage [--html|--coveralls]
#
# --html Additionally create HTML report and open it in browser
# --coveralls Push coverage statistics to coveralls.io
@zchee
zchee / udp-loader.go
Created March 6, 2016 23:41 — forked from jtblin/udp-loader.go
UDP server performance optimisation
package main
import (
"crypto/rand"
"flag"
"log"
mrand "math/rand"
"net"
"os"
"os/signal"
@zchee
zchee / mac-profiling.md
Created March 7, 2016 08:12 — forked from loderunner/01-mac-profiling.md
Profiling an application in Mac OS X

Profiling an application in Mac OS X

Finding which process to profile

If your system is running slowly, perhaps a process is using too much CPU time and won't let other processes run smoothly. To find out which processes are taking up a lot of CPU time, you can use Apple's Activity Monitor.

The CPU pane shows how processes are affecting CPU (processor) activity:

@zchee
zchee / zhostrc
Created March 13, 2016 04:55 — forked from nhooyr/zhostrc
function vid2Gif {
if [[ $# != 3 ]]; then
print "too many or too less arguments"
return
fi
ffmpeg -y -i $1.mov -vf fps=10,scale=${2}:${3}:flags=lanczos,palettegen palette_$1.png
ffmpeg -i $1.mov -i palette_$1.png -filter_complex "fps=10,scale=${2}:${3}:flags=lanczos[x];[x][1:v]paletteuse" -f gif - | gifsicle --optimize=3 > $1.gif
}
@zchee
zchee / README.md
Created March 13, 2016 18:02 — forked from balupton/README.md
Installing ChromiumOS

Install ChromiumOS

  1. Get Chromium OS from one of the following places
    1. Download the vanilla build (old but stable): http://chromeos.hexxeh.net/
      1. NOTE: Password is facepunch
    2. Download the nightly build (sync doesn't work): http://download-chromiumos.appspot.com/
      1. NOTE: If you want developer mode, you must change _base_ in the download URL to _test_ as the base image does not have developer tools enabled
      2. NOTE: Password is unknown, instructions for working around this are provided later
      3. NOTE: I could not get syncing working with this build, perhaps due to no API KEYS being provided???
  2. NOTE: I could not move past the welcome screen on the 64bit build due to no network being found (32bit worked)
@zchee
zchee / CCacheMacNinja.md
Created March 14, 2016 00:50 — forked from jjgod/CCacheMacNinja.md
Using ccache for Mac builds

Introduction

ccache is a compiler cache. It speeds up recompilation of C/C++ code by caching previous compilations and detecting when the same compilation is being done again. This often results in a significant speedup in common compilations, especially when switching between branches. This page is about using ccache on Mac with clang and ninja build system. If you want to use Xcode, please refer to the old CCacheMac page.

In order to use ccache with clang, you need to use the current git HEAD, since the most recent version (3.1.9) doesn't contain the patch needed for using chromium style plugin.

Installation

To install ccache with [homebrew](http://mxcl.