Skip to content

Instantly share code, notes, and snippets.

@xem
xem / JSGameFramework2020.html
Last active November 11, 2023 19:53
JS game framework 2020
<body style=margin:0>
<canvas id=a>
<script>
// initialize 2D canvas (c)
// initialize game state (s)
// initialize keys states (u,r,d,l for directions, k for all the keyboard)
c=a.getContext`2d`,k=[u=r=d=l=s=0]
// (initialize your global variables here)
<?php
/**
* A php implementation of the Hungarian algorithm for solving the assignment
* problem. An instance of the assignment problem consists of a number of
* workers along with a number of jobs and a cost matrix which gives the cost of
* assigning the i'th worker to the j'th job at position (i, j). The goal is to
* find an assignment of workers to jobs so that no job is assigned more than
* one worker and so that no worker is assigned to more than one job in such a
* manner so as to minimize the total cost of completing the jobs.
@genekogan
genekogan / _Instructions.md
Last active March 5, 2021 13:10
instructions for generating a style transfer animation from a video

Instructions for making a Neural-Style movie

The following instructions are for creating your own animations using the style transfer technique described by Gatys, Ecker, and Bethge, and implemented by Justin Johnson. To see an example of such an animation, see this video of Alice in Wonderland re-styled by 17 paintings.

Setting up the environment

The easiest way to set up the environment is to simply load Samim's a pre-built Terminal.com snap or use another cloud service like Amazon EC2. Unfortunately the g2.2xlarge GPU instances cost $0.99 per hour, and depending on parameters selected, it may take 10-15 minutes to produce a 512px-wide image, so it can cost $2-3 to generate 1 sec of video at 12fps.

If you do load the

@staltz
staltz / introrx.md
Last active July 26, 2024 04:24
The introduction to Reactive Programming you've been missing
@jbenet
jbenet / simple-git-branching-model.md
Last active June 17, 2024 14:53
a simple git branching model

a simple git branching model (written in 2013)

This is a very simple git workflow. It (and variants) is in use by many people. I settled on it after using it very effectively at Athena. GitHub does something similar; Zach Holman mentioned it in this talk.

Update: Woah, thanks for all the attention. Didn't expect this simple rant to get popular.

  • Install GNU IMP
  • Install GNU IMP PAL Filters http://registry.gimp.org/node/19058
  • Open image in GNU IMP
  • Make sure image is in RGB (Image > Mode > RGB is checked)
  • Color->Components->Decompose->YCbCr R470 (this decomposes the layers into Y, Cb, Cr, and opens a new three-layer image. Y = brightness, Cb = blueness, Cr = magentaness, roughly)
  • increase the brightness on the Cr layer a bit
  • decrease the brightness on the Cb layer a bit (played with both of these til it looked right)
  • Color->Components-> Recompose
  • Color > Hue-Saturation: select magenta and red, increase the saturation a little on both of these to make it more neon
  • Filters > Artistic > PAL: press okay to select defaults
@daschl
daschl / couchbase-php-2pc-simple.php
Created July 21, 2012 08:39
Simple Couchbase PHP 2PC Implementation
<?php
/**
* Simple two-phase commit for PHP couchbase.
*
* Michael Nitschinger (@daschl, 2012)
*
* Additional Remarks
* ------------------
* - The Couchbase extension makes it currently pretty hard to write easy readable code when dealing with
* CAS (compared to the ruby adapter). This could certainly be improved with closures. I also found that
@drewbourne
drewbourne / ColorizeTest.as
Created December 14, 2010 05:29
Colorize Flash trace() messages
package asx.string
{
public class ColorizeTest
{
var colors:Object = { red: red, green: green, yellow: yellow, blue: blue, purple: purple, cyan: cyan, gray: gray };
[Test]
public function colorize_shouldReturnColorizedString():void
{
for (var color:String in colors)
function lineTowards(g:Graphics, x:int, y:int, length:int):void
{
var c:Number = Math.sqrt(Math.sqr(x) + Math.sqr(y));
var ratio:Number = length / c;
g.lineTo(x*ratio, y*ratio);
}