Skip to content

Instantly share code, notes, and snippets.

View odedw's full-sized avatar

Oded Welgreen odedw

View GitHub Profile
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");
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))
@odedw
odedw / first-pass.ts
Last active January 3, 2020 17:59
Reverse Proxy
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);
}
@odedw
odedw / Todo.elm
Created August 27, 2017 14:32
Todo app in 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 / CorridorCleaner.cs
Last active March 11, 2017 12:43
Map Processor for Karcero to remove corridors with less than X cells
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 / .eslintrc.yaml
Last active March 8, 2022 05:27 — 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).
# 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 / gist:01cdda96f1ae5143406f
Created October 27, 2015 19:51
xUnit JSON reporter test output example
{"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 / RandomUserFetcher
Created January 12, 2015 06:43
Fetch a random user from randomuser.me
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:d6a3f493c01de4f10264
Created September 12, 2014 13:41
Parallel Map Generation
[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 / rafTicker.js
Created May 30, 2014 21:14
Lightweight ticker based on requestAnimationFrame using Paul Irish's polyfill.
// 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'];