Skip to content

Instantly share code, notes, and snippets.

@killwing
killwing / ScopeGuard.hpp
Created February 6, 2013 09:44
[ScopeGuard] encapsulates scoped control flow from @andrei
#ifndef SCOPEGUARD_H
#define SCOPEGUARD_H
template <typename Fun>
class ScopeGuard {
public:
ScopeGuard(Fun f) : f_(std::move(f)), active_(true) {}
~ScopeGuard() {
if (active_) {
f_();
@killwing
killwing / Printtype.hpp
Last active December 15, 2015 00:09
[Printtype] String representation of a type from @marc Glisse
// extern "C" not handled
#include <typeinfo>
#include <type_traits>
#include <string>
template<class...> struct Printtype;
template<> struct Printtype<> {
std::string name() {
return "";
}
@killwing
killwing / slideshare-downloader.sh
Last active December 15, 2015 04:38 — forked from giudinvx/slideshare-downloader.sh
[slideshare-downloader] This script takes a slideshare presentation URL as an argument and carves all the slides in flash format, then they are converted to and finally merged as a PDF.
#!/bin/bash
# Author: Andrea Lazzarotto
# http://andrealazzarotto.com
# andrea.lazzarotto@gmail.com
# Slideshare Downloader
# This script takes a slideshare presentation URL as an argument and
# carves all the slides in flash format, then they are converted to
# and finally merged as a PDF
@killwing
killwing / getPrime.clj
Created March 24, 2013 13:45
[getPrime] kinds of primes generation
(defn lazy-primes []
(letfn [(enqueue [sieve n step]
(let [m (+ n step)]
(if (sieve m)
(recur sieve m step)
(assoc sieve m step))))
(next-sieve [sieve candidate]
(if-let [step (sieve candidate)]
(-> sieve
(dissoc candidate)
@killwing
killwing / canvas-sketch.html
Last active December 21, 2015 09:28
character sketch in canvas
<!doctype html>
<head>
<title>Canvas Data</title>
</head>
<body>
<canvas id="canvas" width="1500" height="2000" style="position: absolute; top: 0px; left: 0px;"></canvas>
</body>
<script>
var theCanvas = document.getElementById('canvas');
var context = theCanvas.getContext('2d');
@killwing
killwing / striker.html
Last active December 22, 2015 16:29
a HTML5 canvas based simplified copycat of the shooting game in Wechat 5.0
<!doctype html>
<html>
<head>
<title>striker</title>
</head>
<body align="center" style="margin:0;">
<canvas id="canvas" width="1500" height="900"></canvas>
<script>
// class inherit
function inherits(ctor, superCtor) {
@killwing
killwing / proxy.go
Created December 13, 2015 11:00
simple proxy
package main
import (
"fmt"
"io"
"io/ioutil"
"net"
"net/http"
"sync"
"time"
@killwing
killwing / main.go
Created March 31, 2017 11:46
flac cue maker (with foobar)
package main
import (
"fmt"
"regexp"
"strings"
)
const cueInfo = `FILE "01 遺サレタ場所:丁.wav" WAVE
TRACK 01 AUDIO
@killwing
killwing / markdown.css
Created June 15, 2012 17:55
[markdowncss]flavored markdown style
/*
CSS stylesheet is based on Kevin Burke's Markdown.css project:
http://kevinburke.bitbucket.org/markdowncss
For code highlighting:
<link rel="stylesheet" href="http://yandex.st/highlightjs/6.1/styles/magula.min.css">
<script src="http://yandex.st/highlightjs/6.1/highlight.js"></script>
<script src="http://yandex.st/highlightjs/6.1/languages/cpp.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
*/
#!/bin/bash
FQDN=$1
# make directories to work from
mkdir -p server/ client/ all/
# Create your very own Root Certificate Authority
openssl genrsa \
-out all/my-private-root-ca.privkey.pem \
2048