This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# for optional arguments: short - there can't be any spaces between the option and the argument | |
# long - the argument can only be passed by "=" | |
# parse options | |
OPTIONS=$(getopt -o o::r:n -l optional::,required:,none -n "$0" -- "$@") | |
# check result | |
[ $? -ne 0 ] && exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// extern "C" not handled | |
#include <typeinfo> | |
#include <type_traits> | |
#include <string> | |
template<class...> struct Printtype; | |
template<> struct Printtype<> { | |
std::string name() { | |
return ""; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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_(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef EXPECTED_H | |
#define EXPECTED_H | |
#include <exception> | |
#include <typeinfo> | |
// Make exceptions be the error codes! | |
template <typename T> | |
class Expected { | |
public: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
using namespace std; | |
std::string escapeXml(const std::string& s) { | |
std::string ret; | |
std::string::size_type i = 0; | |
std::string::size_type pos = 0; | |
for (; i != s.size(); ++i) { | |
std::string rep; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/node | |
var Registry = function() { | |
this.r = [null]; | |
}; | |
Registry.prototype.register = function(object) { | |
var id = this.r[0]; | |
if (id === null) { | |
this.r.push(object); |