Skip to content

Instantly share code, notes, and snippets.

View johnteee's full-sized avatar

John Lee johnteee

  • Taipei
View GitHub Profile
@johnteee
johnteee / download.py
Created July 20, 2018 03:12 — forked from mjohnsullivan/download.py
Python HTTP download with resume and optional MD5 hash checking
import os.path
import urllib2
import shutil
import hashlib
import logging
def validate_file(file_path, hash):
"""
Validates a file against an MD5 hash value
package main
import (
"bufio"
"log"
"os"
)
var concurrency = 100
@johnteee
johnteee / script.lua
Created August 4, 2018 02:40 — forked from jansegre/script.lua
Very basic luajit from Rust.
-- script.lua
-- Receives a table, returns the sum of its components.
io.write("The table the script received has:\n");
x = 0
for i = 1, #foo do
print(i, foo[i])
x = x + foo[i]
end
io.write("Returning data back to C\n");
return x
@johnteee
johnteee / pythontojulia.md
Created August 8, 2018 07:36 — forked from cuckookernel/pythontojulia.md
Python to Julia Quick translation / conversion reference Guide

A quick and dirty syntax translation / conversion reference guide to ease the transition between Python and Julia. This is not meant as a reference to the language. For that you should read the manual.

Some important differences

  • Arrays in Julia are indexed starting from 1.
  • In Julia classes (i.e. types) don't own methods. Methods are implementations of generic functions and are invoked in a "static style", i.e. instead of Python's str1.rstrip(), we will have rstrip( str1 ), instead of file1.close(), close( file1 ).

Some important similarities.

@johnteee
johnteee / .gitconfig
Last active August 27, 2018 10:50
Git log with colors
[alias]
lg1 = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
lg2 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all
lg = !"git lg1"
@johnteee
johnteee / crypto-stream.js
Created September 1, 2018 15:14 — forked from chris-rock/crypto-stream.js
Encrypt and decrypt streams
// Part of https://github.com/chris-rock/node-crypto-examples
// Nodejs encryption of buffers
var crypto = require('crypto'),
algorithm = 'aes-256-ctr',
password = 'd6F3Efeq';
var fs = require('fs');
var zlib = require('zlib');
@johnteee
johnteee / polyfills.html
Created September 5, 2018 05:08 — forked from jacoduplessis/polyfills.html
Load Promise and Fetch polyfills conditionally (updated 8 Jan 2016)
<script>
window.Promise || document.write('<script src="https://unpkg.com/es6-promise@4.0.5/dist/es6-promise.min.js"><\/script>');
window.fetch || document.write('<script src="https://unpkg.com/whatwg-fetch@1.1.1/fetch.js"><\/script>');
</script>
@johnteee
johnteee / main.css
Created September 5, 2018 08:51 — forked from 6174/main.css
cracked glass effect http://codepen.io/mlegane/pen/kKEyH
/* ------------------------------------------- *\
Main
\* ------------------------------------------- */
html {
background: #DAD8DB;
text-align: center;
}
body {
font: 16px sans-serif;
color: #000;

Shattering Images

I tried to make a gallery, but the images keep shattering when I click on them... I'll need to use more sturdy materials next time.

(Delaunay triangulation part 2)

A Pen by Szenia Zadvornykh on CodePen.

char *x; // x: a pointer to char
char x[3]; // x: an array[3] of char
char x(); // x: a function() returning char
char *x[3]; // x: an array[3] of pointer to char
char (*x)[3]; // x: a pointer to array[3] of char
char **x; // x: a pointer to pointer to char
char *x(); // x: a function() returning pointer to char
char *x()[3]; // x: a function() returning array[3] of pointer to char
char (*x[])(); // x: an array[] of pointer to function() returning char
char (*x())(); // x: a function() returning pointer to function() returning char