Skip to content

Instantly share code, notes, and snippets.

@Seteh
Seteh / easing.js
Created June 6, 2018 18:09 — forked from yairEO/easing.js
Simple Easing Functions in Javascript - see https://github.com/gre/bezier-easing
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {
// no easing, no acceleration
linear: function (t) { return t },
// accelerating from zero velocity
easeInQuad: function (t) { return t*t },
// decelerating to zero velocity
@Seteh
Seteh / gist:5a3c5386b7e0a1772ccb
Last active February 15, 2016 15:13
A tool for mocking XMLHttpRequest
(function(global) {
var DummyServer = function() {
var states = {
UNSENT: 0,
OPENED: 1,
HEADERS_RECEIVED: 2,
LOADING: 3,
DONE: 4
};
@Seteh
Seteh / fib.ts
Created September 27, 2015 22:26 — forked from sampsyo/fib.ts
function inheritance in TypeScript
// This is a quick demonstration of "function inheritance" as described in
// this paper from Daniel Brown and William Cook.
// http://www.cs.utexas.edu/users/wcook/Drafts/2009/sblp09-memo-mixins.pdf
// Expressed in TypeScript (and without the monads).
// Syntax note: When you write function types in TypeScript, you need to name
// each parameter. But the names don't actually matter, so I just use _. You
// can read `(_:A) => B` as `a -> b` in ML or Haskell syntax.
// In Brown and Cook's Haskell, `type Gen a = a -> a` is a "generator." The
@Seteh
Seteh / recursion.asm
Last active August 29, 2015 14:16 — forked from mcfedr/recursion.asm
;;; --- Skip lots of stuf ---
;;; <@19,#13> compare-numeric-and-branch
0x49252d6f 47 83f800 cmp eax,0x0
0x49252d72 50 0f843e000000 jz 118 (0x49252db6)
;;; <@20,#17> -------------------- B2 (unreachable/replaced) --------------------
;;; <@24,#24> -------------------- B3 --------------------
;;; <@27,#26> compare-numeric-and-branch
0x49252d78 56 83f802 cmp eax,0x2 ;; debug: position 81
0x49252d7b 59 0f842a000000 jz 107 (0x49252dab)
var above = function(limit){
return function(value){
return value > limit;
};
};
var isAbove10 = above(10);
console.log(isAbove10(5)); // false
console.log(isAbove10(8)); // false
/**
* A simple Time travel machine to the future.
*
* A theoretical time-traveling to the future
* (a very-very-very simplified explanation/application
* of the General relativity).
*
* .allgemeine Relativitätstheorie
*
* by Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
@Seteh
Seteh / reg-vm.js
Last active August 29, 2015 14:07 — forked from DmitrySoshnikov/reg-vm.js
// "Fetch, decode, eval!"
// A simple Register-based VM, Assembler, and Disassembler.
// by Dmitry Soshnikov <[email protected]>
// This virtual machine (VM) consists of registers (data storage),
// and operations (instructions) which operate on the registers.
// --------------------------------------------------------------
// Registers.
// --------------------------------------------------------------
@Seteh
Seteh / expr.erl
Last active August 29, 2015 14:07 — forked from DmitrySoshnikov/expr.erl
-module(expr).
-export([
parse/1,
test/0
]).
% ------------------------------------------------------
%
% Simple math-expressions parser
// by Dmitry Soshnikov <[email protected]>
// MIT Style License.
// Short URL for this example to run online is: http://cpp.sh/333
#include <iostream>
#include <vector>
#include <ctype.h>
#include <cstring>
// Using bin/typescript.js from TypeScript 0.9.7
function compile(source) {
var parseErrors = [];
var logger = new TypeScript.NullLogger();
var compilationSettings = TypeScript.ImmutableCompilationSettings.defaultSettings();
var compiler = new TypeScript.TypeScriptCompiler(logger, compilationSettings);
var snapshot = TypeScript.ScriptSnapshot.fromString(source);