Skip to content

Instantly share code, notes, and snippets.

View theorigin's full-sized avatar

Andy Robinson theorigin

View GitHub Profile
@willurd
willurd / web-servers.md
Last active May 17, 2024 16:24
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@bitsprint
bitsprint / Types.Dictionary.1.sql
Last active December 20, 2015 23:28
Indexed Dictionary (User Defined Table Type)
/****** Object: UserDefinedTableType [dbo].[IndexedDictionary] ******/
IF EXISTS (SELECT * FROM sys.types st JOIN sys.schemas ss ON st.schema_id = ss.schema_id WHERE st.name = N'IndexedDictionary' AND ss.name = N'dbo')
DROP TYPE [dbo].[IndexedDictionary]
GO
/****** Object: UserDefinedTableType [dbo].[IndexedDictionary] ******/
CREATE TYPE [dbo].[IndexedDictionary] AS TABLE(
[Index] [int] NULL,
[Key] [nvarchar](255) NULL,
[Value] [nvarchar](255) NULL
@bitsprint
bitsprint / CsvParser.cs
Created September 16, 2013 13:02
Csv Parser
using (Microsoft.VisualBasic.FileIO.TextFieldParser parser = new Microsoft.VisualBasic.FileIO.TextFieldParser("C:\\testfile.txt")) {
parser.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited;
parser.SetDelimiters(",");
string[] currentRow = null;
while (!parser.EndOfData) {
try {
currentRow = parser.ReadFields();
string currentField = null;
foreach (string field in currentRow) {
currentField = field;
@lennartb-
lennartb- / GameOfLife.cs
Last active May 17, 2023 03:39
Conway's Game of Life in C# (Console App) with basic arrays and without any fancy complicated stuff. No error checking included.
using System;
namespace GameOfLife {
public class LifeSimulation {
private int Heigth;
private int Width;
private bool[,] cells;
/// <summary>
internal static IEnumerable<string> ReadLines(this string s)
{
string line;
using (var sr = new StringReader(s))
while ((line = sr.ReadLine()) != null)
yield return line;
}
@georgepowell
georgepowell / Program.cs
Last active January 8, 2022 11:45
Roman Numerals converter in C#. Run as a console application from Visual Studio. The 'Romanise' function is where the magic happens.
using System;
namespace RomanNumerals
{
class Program
{
// Create rules in descending order
static Rule[] Rules = new Rule[]
{
new Rule(1000, "M"),
@IronMonk-UK
IronMonk-UK / Exit.cs
Created March 7, 2016 13:13
The C# code for the Text Adventure
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TextAdventure
{
class Exit
{
@kjnilsson
kjnilsson / async_consumer.cs
Last active January 24, 2021 07:17
RabbitMQ .NET client async consumer example
using System;
using System.Threading.Tasks;
using RabbitMQ.Client;
using RabbitMQ.Client.Events;
namespace ConsoleApplication
{
public class Program
{
public static void Main(string[] args)
@RickardAhlstedt
RickardAhlstedt / Exit.cs
Created July 24, 2019 07:17 — forked from IronMonk-UK/Exit.cs
The C# code for the Text Adventure
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TextAdventure
{
class Exit
{
@straker
straker / README.md
Last active May 9, 2024 02:49
Basic Tetris HTML and JavaScript Game

Basic Tetris HTML and JavaScript Game

This is a basic implementation of the game Tetris, but it's missing a few things intentionally and they're left as further exploration for the reader.

Further Exploration