Skip to content

Instantly share code, notes, and snippets.

Seivan Heidari seivan

Block or report user

Report or block seivan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
c0gent /
Created Jul 28, 2016
Glium - instancing over a vertex buffer slice
//! An example demonstrating that glium has a problem using instancing when
//! the vertex buffer is a slice with a non-zero starting index.
#[macro_use] extern crate glium;
use glium::{DisplayBuild, Surface};
// Vertex Shader:
static VERTEX_SHADER_SRC: &'static str = r#"
#version 140
bitwalker / config.ex
Created Jul 19, 2016
Useful config wrapper for Elixir
View config.ex
defmodule Config do
@moduledoc """
This module handles fetching values from the config with some additional niceties
@doc """
Fetches a value from the config, or from the environment if {:system, "VAR"}
is provided.
An optional default value can be provided if desired.
xem /
Last active Nov 11, 2019
Maths & trigonometry cheat sheet for 2D & 3D games


  • A = [xA, yA] is a point on the 2D plane. Same for B, C, ...
  • lengths are in any unit (ex: pixels)
  • code snippets are in JavaScript

Degrees to radians

angleRad = angleDeg * Math.PI / 180;

(* for OCaml <4.03.0 define:
type ('a, 'b) result = Ok of 'a | Error of 'b *)
module type MONAD = sig
type 'a t
val return : 'a -> 'a t
val (>>=) : 'a t -> ('a -> 'b t) -> 'b t
module Id = struct
moklett / task1.exs
Last active Sep 17, 2019
Elixir Task - Crash Handling
View task1.exs
# This demonstrates that, when using async/await, a crash in the task will crash the caller
defmodule Tasker do
def good(message) do
IO.puts message
def bad(message) do
IO.puts message
raise "I'm BAD!"
bitwalker /
Created Mar 17, 2016 — forked from pnc/
Using Erlang observer/appmon remotely

Using OTP's observer (appmon replacement) remotely

$ ssh remote-host "epmd -names"
epmd: up and running on port 4369 with data:
name some_node at port 58769

Note the running on port for epmd itself and the port of the node you're interested in debugging. Reconnect to the remote host with these ports forwarded:

$ ssh -L 4369:localhost:4369 -L 58769:localhost:58769 remote-host
View Phone Words II.swift
## Phone Words
Generate a collection of words that can be represented by a given phone number. If a phone number contains the digits `1` or `0` then split up the phone number and find the words for each of the substrings as long as each substring has more than one digit. Non-keypad characters can be ignored. Optionally, filter out words so that only dictionary words are present in the result.
║ 1 ║ 2 ║ 3 ║
║ ║ abc ║ def ║
║ 4 ║ 5 ║ 6 ║
stephantabor / bb.js
Last active Feb 16, 2019
Bluebird .each vs .mapSeries vs .map
View bb.js
var Promise = require('bluebird');
var funcs = Promise.resolve([500, 100, 400, 200].map((n) => makeWait(n)));
.each(iterator) // logs: 500, 100, 400, 200
.then(console.log) // logs: [ [Function], [Function], [Function], [Function] ]
.mapSeries(iterator) // logs: 500, 100, 400, 200
View tap-and-hold.js
const touchStart = Rx.Observable.fromEvent(window, 'touchstart').timestamp();
const touchMove = Rx.Observable.fromEvent(window, 'touchmmove');
const touchEnd = Rx.Observable.fromEvent(window, 'touchend').timestamp();
const touchAndHold = touchStart
.flatMap(() => touchEnd.takeUntil(touchMove), (x, y) => { start: x.timestamp, end: y.timestamp })
.filter(ts => (ts.end - ts.start) / 1000 > 2);
const subscription = touchAndHold.subscribe(
() => console.log('touch and hold!')
You can’t perform that action at this time.