Skip to content

Instantly share code, notes, and snippets.

View tomsmeding's full-sized avatar
🦆

Tom Smeding tomsmeding

🦆
View GitHub Profile
@tomsmeding
tomsmeding / gist:96060c7db3f1c3483668
Created May 1, 2014 17:19
King of the walls fillupbot output
~/Documents/C$ ./kingofthewalls '#.....................##.;#.....................###;#########################;#########################;#########################;#########################;###################.1####;##############.....2#####;########.....############;.......##################;################........#;####...........##########;...################......;..................#######;###########.............#;..........#########......;..................##.....;...................#.....;...................##....;....................##...;.....................#...;.....................##..;......................##.;#########################;......................###'
W
~/Documents/C$
@tomsmeding
tomsmeding / gist:494da58726843984bcea
Created March 25, 2015 16:46
Minus zero ≠ zero in C++ (and C and other C-based languages)
#include <iostream>
#include <iomanip>
#include <cstdint>
#include <cstring>
using namespace std;
typedef float fltp;
int main(void){
@tomsmeding
tomsmeding / MagisterCLI.js
Created April 6, 2015 12:02
MagisterCLI by tomsmeding
#!/usr/bin/env node
var mjs=require("magister.js"),
persist=require("node-persist"),
readline=require("readline"),
util=require("util");
require("datejs"); //modifies prototypes
function logRuler(maxwid,s){
var i,j,len;
@tomsmeding
tomsmeding / translate
Created April 12, 2015 15:14
Vertalen op de commandline
#!/usr/bin/env bash
if [[ "$#" != "3" ]]; then
echo "Give on the command line: from-language to-language word"
echo "Languages: NL EN DE FR ES"
exit
fi
text=$(w3m "http://www.mijnwoordenboek.nl/vertaal/$1/$2/$3" | cat)
startline=$(echo "$text" | grep -ne '^Vertalingen' | sed 's/:.*//')
text=$(echo "$text" | gtail -n "+$startline")
@tomsmeding
tomsmeding / fish_prompt.fish
Last active August 29, 2015 14:19
My fish_prompt
set -g __fish_git_prompt_show_informative_status 1
set -g __fish_git_prompt_hide_untrackedfiles 1
set -g __fish_git_prompt_color_branch magenta bold
set -g __fish_git_prompt_showupstream "informative"
set -g __fish_git_prompt_char_upstream_ahead "↑"
set -g __fish_git_prompt_char_upstream_behind "↓"
set -g __fish_git_prompt_char_upstream_prefix ""
set -g __fish_git_prompt_char_stagedstate "●"
@tomsmeding
tomsmeding / wrapAsync.js
Last active August 29, 2015 14:22
Async function to sync using node fibers/future
function wrapAsync(fn) {
return function () {
var fut=new Future();
var args=Array.apply(Array,arguments);
args.push(fut.resolver());
fn.apply(this,args);
return fut.wait();
}
}
@tomsmeding
tomsmeding / wscat.html
Created June 14, 2015 07:13
Simple wscat implementation that works. The npm wscat uses readline a bit strangely.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>wscat</title>
<script>
var address="",conn=null;
var inputhistory=[],historyidx=null,droppedCurrent=null;
function log(src,s){
function niceDate(d){
var now=new Date();
if(!d.getFullYear)d=new Date(d);
if(d.getDate()==now.getDate()){
if(d.getHours()==now.getHours()){
if(d.getMinutes()==now.getMinutes()){
return now.getSeconds()-d.getSeconds()+" seconds ago";
}
return now.getMinutes()-d.getMinutes()+" minutes ago";
}
@tomsmeding
tomsmeding / sicktiles.cpp
Created June 23, 2015 17:01
A146971 generator
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <vector>
#include <unordered_map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <cassert>
#!/usr/bin/env node
"use strict";
var fs=require("fs");
var body;
if(process.argv[2]=="-"){
body="";
var res;
while(true){
res=fs.readSync(0,1024);
if(res[1]==0)break;