Skip to content

Instantly share code, notes, and snippets.

@meisinger
meisinger / redis-command.cs
Created May 1, 2014 02:34
an approach to creating redis commands
public class RedisCommand
{
static byte[] GenerateCommand(byte[][] arguments)
{
using (var stream = new MemoryStream())
{
var request = CreateIndicator('*', arguments.Length);
stream.Write(request, 0, request.Length);
stream.WriteNewLine();
@meisinger
meisinger / cooperative-queue.cs
Last active August 29, 2015 14:00
queue with cooperative cancellation
public class CooperativeQueue<TMessage>
where TMessage : class, IQueueMessage
{
private readonly Queue<TMessage> internalQueue;
private readonly ManualResetEventSlim manualReset;
private bool open;
public CooperativeQueue()
{
internalQueue = new Queue<TMessage>();
@meisinger
meisinger / csv-reader.cs
Created May 1, 2014 03:33
example of a simple csv reader
public sealed class CsvReader : IDisposable
{
private const char DefaultFieldChar = ',';
private const char DefaultQuoteChar = '"';
private const char DefaultEscapeChar = '\\';
private readonly List<CsvLine> collection;
private readonly StringBuilder buffer;
private readonly Stream stream;
private readonly StreamReader reader;
@meisinger
meisinger / task-controller.cs
Created May 29, 2014 03:32
example of a task controller
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using StructureMap;
namespace Task.Services.Service
{
public class Controller
@meisinger
meisinger / cooperative-consumer.cs
Last active August 29, 2015 14:02
consumer for cooperative queue
using RabbitMQ.Client
public class CooperativeConsumer : IBasicConsumer
{
private readonly IModel channel;
private readonly CooperativeQueue<IQueueMessage> queue;
public IModel Model
{
get { return channel; }
@meisinger
meisinger / cooperative-queue-factory.cs
Created June 3, 2014 04:21
factory class to create a connection to rabbit mq along with a consumer and publisher
using RabbitMQ.Client;
using RabbitMQ.Client.Exceptions;
public class MessageQueueFactory : IMessageQueueFactory
{
private readonly ConnectionFactory factory;
private IConnection connection;
public bool IsOpen
{
@meisinger
meisinger / bootstrap.sh
Last active August 29, 2015 14:02
vagrant bootstrap
#!/usr/bin/env bash
## add redis to the package list
cat <<BAM >> /etc/apt/sources.list.d/dotdeb.org.list
# /etc/apt/sources.lsit.d/dotdeb.org.list
deb http://packages.dotdeb.org squeeze all
deb-src http://packages.dotdeb.org squeeze all
BAM
## import redis public key to package keys
@meisinger
meisinger / example_bashrc.txt
Created December 17, 2015 05:39
arch linux stuff
#
# ~/.bashrc
#
export LANG=en_US.UTF-8
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
alias ls='ls --color=auto -F'
alias grep='grep --color=auto'
@meisinger
meisinger / main.js
Created January 7, 2016 23:27
example of react with a page view approach (no flux or events)
'use strict';
import React from 'react';
import ReactDom from 'react-dom';
import { UserService, ExampleService } from './service';
import Promise from 'bluebird';
import assign from 'object-assign';
class ComponentWrapper {
@meisinger
meisinger / webpack.config.js
Created May 26, 2016 19:34
webpack basics
var path = require('path');
var webpack = require('webpack');
module.exports = {
devtool: 'eval',
entry: [
'./src/index'
],
output: {
path: path.join(__dirname, 'public'),