Skip to content

Instantly share code, notes, and snippets.

### Keybase proof
I hereby claim:
* I am daniellowtw on github.
* I am dlow (https://keybase.io/dlow) on keybase.
* I have a public key whose fingerprint is 1397 337C B0F0 0E44 1734 99FC 6468 A404 4DC5 AFB9
To claim this, I am signing this object:
@daniellowtw
daniellowtw / gist:6b7154ad89a1443cc233
Created April 26, 2015 14:05
Simple parse.com email collector
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<script src="https://www.parsecdn.com/js/parse-1.4.2.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
</head>
@daniellowtw
daniellowtw / Pycrypto AES
Created May 7, 2015 13:28
Using pycrypto AES
# Taken from http://stackoverflow.com/questions/12524994/encrypt-decrypt-using-pycrypto-aes-256/12525165#12525165
import base64
import hashlib
from Crypto import Random
from Crypto.Cipher import AES
class AESCipher(object):
def __init__(self, key):
@daniellowtw
daniellowtw / Full screen latex image README.md
Last active August 29, 2015 14:21
Full screen latex image
  • Create a new directory.
  • Download script.sh.
  • Create a folder in that directory called images.
  • Dump all images (whatever includegraphics can accept) that you want to combine in there.
  • Run script
@daniellowtw
daniellowtw / Zim resize.ahk
Created May 25, 2015 11:31
Macro to resize images in zim wiki after pasting them
SetTitleMatchMode, 2
#IfWinActive Zim ahk_class gdkWindowToplevel
!1::
SendInput, {AppsKey}e{Tab}{Tab}{Tab}{Tab}100{Enter}{Enter}
return
!2::
SendInput, {AppsKey}e{Tab}{Tab}{Tab}{Tab}200{Enter}{Enter}
return
!3::
var gulp = require('gulp'),
connect = require('gulp-connect');
watch = require('gulp-watch');
gulp.task('watch', function() {
watch(['*.html','js/*.js']).pipe(connect.reload());
});
gulp.task('server', function(done) {
@daniellowtw
daniellowtw / MyCakePattern.scala
Created October 15, 2015 13:51
An exploration of the cake pattern for scala
import org.scalatest.mock.MockitoSugar
/**
* This explores self type and the cake pattern
*
* The recipe:
* 1) Create a trait component
* 2) Declare any dependent components using self-types
* 3) Create the trait
* 4) Create an abstract val that will be instantiated with an instance of the component
@daniellowtw
daniellowtw / memoize.js
Created October 25, 2015 00:32
Javascript memoize decorator functor
function memoize(fn) {
var invocationCache = {};
return function() {
var args = Array.prototype.slice.call(arguments);
var cachedValue = invocationCache[args];
if (cachedValue !== undefined) {
return cachedValue;
}
var result = fn.apply(null, arguments);
invocationCache[args] = result;
@daniellowtw
daniellowtw / main.go
Created October 27, 2015 10:03
Mocking in Go
package main
import (
"golang.org/x/net/context"
"github.com/stretchr/testify/mock"
)
type Foo interface {
Bar (ctx context.Context) (string)
}
@daniellowtw
daniellowtw / shortAssignment.go
Last active October 30, 2015 12:58
Golang good and bad parts
// Cannot use short assignments when dealing with structs
package main
type foo struct {
stuff int
}
func main() {
foo.stuff, a := 1,2
println(a)