Skip to content

Instantly share code, notes, and snippets.

Avatar

Oded Welgreen odedw

View GitHub Profile
@odedw
odedw / rafTicker.js
Created May 30, 2014
Lightweight ticker based on requestAnimationFrame using Paul Irish's polyfill.
View rafTicker.js
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
@odedw
odedw / gist:d6a3f493c01de4f10264
Created Sep 12, 2014
Parallel Map Generation
View gist:d6a3f493c01de4f10264
[Test]
public void ParallelMapGenerationTest()
{
const int SIZE = 1000;
const int NUMBER_OF_ROOMS = 320;
const int NUMBER_OF_PARALLEL_CALLS = 16;
var generator = new DungeonGenerator<Cell>();
DateTime start = DateTime.Now;
//One big map
for (var i = 0; i < ITERATIONS; i++)
@odedw
odedw / RandomUserFetcher
Created Jan 12, 2015
Fetch a random user from randomuser.me
View RandomUserFetcher
public class RandomUserFetcher
{
public async Task<RandomUser> Fetch()
{
using (var webClient = new WebClient())
{
var result = await webClient.DownloadStringTaskAsync("http://api.randomuser.me");
dynamic obj = JsonConvert.DeserializeObject(result);
var userStr = obj.results[0].user.ToString();
var user = JsonConvert.DeserializeObject<RandomUser>(userStr);
@odedw
odedw / gist:01cdda96f1ae5143406f
Created Oct 27, 2015
xUnit JSON reporter test output example
View gist:01cdda96f1ae5143406f
{"message":"testCollectionStarting","flowId":"ef88d720e40b440e9ef79461eaea4e91","assembly":"test.xunit.runner.reporters, Version=99.99.99.0, Culture=neutral, PublicKeyToken=null","collectionName":"Test collection for TeamCityReporterMessageHandlerTests+OnMessage_ITestStarting","collectionId":"151794a8-0e29-4e6d-a464-d215967eeb22"}
{"message":"testCollectionStarting","flowId":"d372efdc4f0c4dbf85dd3ad91ad07638","assembly":"test.xunit.runner.reporters, Version=99.99.99.0, Culture=neutral, PublicKeyToken=null","collectionName":"Test collection for TeamCityReporterMessageHandlerTests+OnMessage_ITestCollectionStarting","collectionId":"ca68584f-b31f-4ef4-a61a-9802a1a2f966"}
{"message":"testCollectionStarting","flowId":"a9c9647c2cca435abe99cc33ea503639","assembly":"test.xunit.runner.reporters, Version=99.99.99.0, Culture=neutral, PublicKeyToken=null","collectionName":"Test collection for TeamCityReporterMessageHandlerTests+OnMessage_ITestSkipped","collectionId":"55fa344e-cee5-4198-a6bd-204342559bb4"}
{"message":"test
@odedw
odedw / .eslintrc.yaml
Last active Aug 13, 2018 — forked from cletusw/.eslintrc
ESLint Reset - A starter .eslintrc file that resets all rules to off and includes a description of what each rule does. From here, enable the rules that you care about by changing the 0 to a 1 or 2. 1 means warning (will not affect exit code) and 2 means error (will affect exit code).
View .eslintrc.yaml
# http:#eslint.org/docs/rules/
ecmaFeatures:
binaryLiterals: false # enable binary literals
blockBindings: false # enable let and const (aka block bindings)
defaultParams: false # enable default function parameters
forOf: false # enable for-of loops
generators: false # enable generators
objectLiteralComputedProperties: false # enable computed object literal property names
objectLiteralDuplicateProperties: false # enable duplicate object literal properties in strict mode
objectLiteralShorthandMethods: false # enable object literal shorthand methods
@odedw
odedw / CorridorCleaner.cs
Last active Mar 11, 2017
Map Processor for Karcero to remove corridors with less than X cells
View CorridorCleaner.cs
using Karcero.Engine.Contracts;
using Karcero.Engine.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Karcero.Visualizer
{
@odedw
odedw / Todo.elm
Created Aug 27, 2017
Todo app in Elm
View Todo.elm
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import Html.Keyed as Keyed
-- MODEL
type alias Model =
{ entries : List Entry
, uid : Int
, newTodoText : String
@odedw
odedw / first-pass.ts
Last active Jan 3, 2020
Reverse Proxy
View first-pass.ts
function handleRequest(request) {
const firstSegment = getFirstSegmentOfPath(request);
const destinationApp = config.apps.find((app) => firstSegment === app.path);
if (destinationApp) {
proxyRequestToDomain(destinationApp.domain);
return;
}
proxyRequestToApp(config.defaultDomain);
}
View 2020-10-03-hydra-sketch.js
s0.initScreen();
src(s0)
.rotate([Math.PI / 4, Math.PI / 2, (Math.PI * 3) / 4, Math.PI].fast(0.5))
.repeat(4)
.scale([1, 1.5].fast(0.1))
.thresh(0.4, 0.4)
.colorama(({ time }) => Math.sin(time / 20))
.saturate([1, 0.9, 0.8, 0.7].fast(0.2))
View chloe.js
document.addEventListener("DOMContentLoaded", function () {
// create a new hydra-synth instance
const canvas = document.getElementById("myCanvas");
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
new window.Hydra({
canvas: canvas,
detectAudio: false,
});
const button = document.getElementById("myButton");