Skip to content

Instantly share code, notes, and snippets.

View axefrog's full-sized avatar

Nathan Ridley axefrog

  • Brisbane, Australia
View GitHub Profile
@axefrog
axefrog / 0.suffixtree.cs
Last active July 12, 2023 01:01
C# Suffix tree implementation based on Ukkonen's algorithm. Full explanation here: http://stackoverflow.com/questions/9452701/ukkonens-suffix-tree-algorithm-in-plain-english
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace SuffixTreeAlgorithm
{
public class SuffixTree
{
@axefrog
axefrog / gist:3353609
Created August 14, 2012 22:36
Node.js HTTP/HTTPS double forward proxy with two-stage authorization
/*
HTTP/HTTPS Forward Proxy
------------------------
The purpose of this proxy is to manage a set of third party proxies
internally, routing incoming requests through those proxies and
rotating which remote proxies are in use periodically as requests come
through, and without exposing the proxy credentials to the originating
client. Rate limiting will later be implemented internally so that if
the remote proxies have all been utilised too heavily, a "rate limit
exceeded" message will be returned to the client.
@axefrog
axefrog / sample.html
Last active December 14, 2015 05:40
jQuery plugin that allows any sequence of block elements to become sortable by dragging. Inserts a drag handle element into each item if one is not provided.
<!doctype html>
<html>
<head>
<title>Sortable List</title>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="sortable-list.js"></script>
<script>
$(function() { $('#rows').sortablelist(); });
</script>
<style type="text/css">
@axefrog
axefrog / ioc.ts
Last active December 20, 2015 03:09
MyIOC - A simple, lightweight IOC container for TypeScript (and therefore JavaScript) that does everything I need and nothing I don't.
/*
MyIOC - IOC Container for TypeScript/JavaScript
designed and developed by Nathan Ridley
------------------------------------------------------------------
Copyright (c) 2013 Nathan Ridley (axefrog@gmail.com).
All rights reserved.
Redistribution and use in source and binary forms are permitted
provided that the above copyright notice and this paragraph are
@axefrog
axefrog / computeArrayUpdateOperations.js
Last active December 20, 2015 22:09
A JavaScript algorithm I came up with to calculate the operations to be applied to an array L to make it the same as a new array R when it is undesirable to simply replace L with R. Typically this is when doing so is a costly operation (such as when the elements represent the items of a DOM collection) and/or each component of the update require…
// both arrays should be presorted
function computeArrayUpdateOperations(oldarr, newarr, compare) {
if (!compare)
compare = computeArrayUpdateOperations.compare;
var l = 0, r = 0, p = 0,
op = null, ops = [],
leof = l >= oldarr.length, reof = r >= newarr.length;
while (!(leof && reof)) {
if (!leof && (reof || compare(oldarr[l], newarr[r]) < 0)) {
if (op && op[0] === 'i')
@axefrog
axefrog / test.js
Last active December 24, 2015 04:39
<!-- snip -->
<script type="text/x-handlebars" data-template-name="data_sources">
<h3>Data Source List</h3>
<section id="data-source-list">
{{#each}}
<div id="data-source-list-item-{{id}}" class="data-source">
<h4>{{name}}</h4>
enabled: {{enabled}}
</div>
{{/each}}
@axefrog
axefrog / hello-world-sharpdx-1.cs
Last active December 25, 2015 04:29
Game Dev Samples
namespace SharpDx1
{
class HelloWorld
{
[STAThread]
public static void Main()
{
var app = new HelloWorld();
app.Run();
}
@axefrog
axefrog / hello-world-sharpdx-2.cs
Last active December 25, 2015 04:39
Game Dev Samples
using System;
using SharpDX;
using SharpDX.Direct2D1;
using SharpDX.Direct3D10;
using SharpDX.DirectWrite;
using SharpDX.DXGI;
using SharpDX.Windows;
using AlphaMode = SharpDX.Direct2D1.AlphaMode;
using Device1 = SharpDX.Direct3D10.Device1;
@axefrog
axefrog / hello-triangle-sharpdx-1.cs
Last active March 30, 2018 13:19
Game Dev Samples
using System;
using System.Windows.Forms;
using SharpDX;
using SharpDX.D3DCompiler;
using SharpDX.Direct3D;
using SharpDX.Direct3D11;
using SharpDX.DXGI;
using SharpDX.Windows;
using Buffer = SharpDX.Direct3D11.Buffer;
using Device = SharpDX.Direct3D11.Device;
@axefrog
axefrog / game.cs
Created October 22, 2013 16:58
Not quite sure why resizing the window causes the polygon edges to become a bit jagged.
using System;
using System.Windows.Forms;
using SharpDX;
using SharpDX.D3DCompiler;
using SharpDX.Direct3D;
using SharpDX.Direct3D11;
using SharpDX.DXGI;
using SharpDX.Windows;
using Buffer = SharpDX.Direct3D11.Buffer;
using Device = SharpDX.Direct3D11.Device;