Skip to content

Instantly share code, notes, and snippets.

View sntran's full-sized avatar

Sơn Trần-Nguyễn sntran

View GitHub Profile
%% Copyright 2010 Erlang Solutions Ltd (ESL). All rights reserved.
%% Redistribution and use in source and binary forms, with or without
%% modification, are permitted provided that the following conditions are met:
%%
%% 1. Redistributions of source code must retain the above copyright notice,
%% this list of conditions and the following disclaimer.
%%
%% 2. Redistributions in binary form must reproduce the above copyright
%% notice, this list of conditions and the following disclaimer in
%% the documentation and/or other materials provided with the distribution.
@ggoodman
ggoodman / README.md
Created September 6, 2011 20:56
Slamikaze html5 game proof of concept

SLAMIKAZE

With your guns disabled and no other means of fighting back, your hopes of survival are all but lost. The enemy are savage, suicidal beasts who will follow you blindly to the furthest reaches of the universe.

Only one hope remains; if you are quick and clever, there might just be a chance... good luck.

How to play

  • Your ship (blue square) follows your mouse cursor closely
  • Enemy ships (red squares) follow your mouse cursor as fast as their weaker ships allow
  • Avoid enemy ships while causing them to collide in order to flee to safety
@SteveSongMIT
SteveSongMIT / captainflint.dtl
Created March 20, 2012 22:50
Simple Cowboy web server + ErlyDTL
<html>
<body>
GET squawk:<br />
{{ squawk_get }}<br /><br />
POST squawk:<br />
{{ squawk_post }}<br /><br />
@nijikokun
nijikokun / example-user.js
Created May 3, 2012 20:46
Beautiful Validation... Why have I never thought of this before?!
var user = {
validateCredentials: function (username, password) {
return (
(!(username += '') || username === '') ? { error: "No Username Given.", field: 'name' }
: (!(username += '') || password === '') ? { error: "No Password Given.", field: 'pass' }
: (username.length < 3) ? { error: "Username is less than 3 Characters.", field: 'name' }
: (password.length < 4) ? { error: "Password is less than 4 Characters.", field: 'pass' }
: (!/^([a-z0-9_-]+)$/i.test(username)) ? { error: "Username contains invalid characters.", field: 'name' }
: false
);
@wolfeidau
wolfeidau / gist:2757480
Created May 20, 2012 09:28
Erlang running on Netgear WNDR3800
root@OpenWrt:~# erl
Erlang R15B01 (erts-5.9.1) [source] [async-threads:0] [kernel-poll:false]
Eshell V5.9.1 (abort with ^G)
1> erlang:system_info(system_architecture).
"mips-openwrt-linux-gnu"
2> q().
ok
3> root@OpenWrt:~# uname -a
Linux OpenWrt 3.3.6 #1 Sun May 20 15:43:19 EST 2012 mips GNU/Linux
@samthor
samthor / dialog-focus-restore.js
Last active December 1, 2023 14:39
Restore focus after a HTML dialog is shown modally
/**
* Updates the passed dialog to retain focus and restore it when the dialog is closed. Won't
* upgrade a dialog more than once. Supports IE11+ and is a no-op otherwise.
* @param {!HTMLDialogElement} dialog to upgrade
*/
var registerFocusRestoreDialog = (function() {
if (!window.WeakMap || !window.MutationObserver) {
return function() {};
}
var registered = new WeakMap();
@mikaelhg
mikaelhg / README.md
Last active December 30, 2023 22:24
Get started with Protomaps single-file static map hosting

Get started with Protomaps single-file static map hosting

Build maps

Planetiler downloads data files for you automagically.

java -jar planetiler.jar --download --area=finland --output=finland.pmtiles