Skip to content

Instantly share code, notes, and snippets.

View jeffijoe's full-sized avatar
:shipit:
Netting them dots

Jeff Hansen jeffijoe

:shipit:
Netting them dots
View GitHub Profile
/*
Authors: Jeff Hansen, Bjarke Søgaard
Description: Simple TCP Client for use in Unity3D. Very nice, so doge.
*/
public class SimpleTcpClient
{
private TcpClient socket;
private NetworkStream net_stream;
private StreamWriter socket_writer;
private StreamReader socket_reader;
@jeffijoe
jeffijoe / HttpClient.iOS.md
Last active August 29, 2015 14:00
Using PCL HttpClient (and PortableRest) in Xamarin iOS.

Using HttpClient in Xamarin.iOS

A small setup guide for getting HttpClient working in Xamarin.iOS. Hopefully this guide will be deprecated when Microsoft/Xamarin fix these issues.

What went wrong

At work we were trying to get PortableRest working in iOS, but we kept running into issues with either the build process or something about us not setting Http headers correctly. For example:

@jeffijoe
jeffijoe / Benchmark.cs
Created September 11, 2014 14:31
C# "Benchmark" helper.
// Benchmark.cs
// Author: Jeff Hansen <jeff@memberlink.com>
using System;
using System.Diagnostics;
namespace Sharp2D.Tests.EngineTests.TestHelpers
{
/// <summary>
/// Benchmark helper.
@jeffijoe
jeffijoe / bootstrap.onFieldValidatedHandler.js
Last active August 29, 2015 14:06
jQuery.Validator onFieldValidatedHandler
var setValidationStatusFor = function($field, isValid, errorMessage) {
var
$formgroup = $field.closest(".form-group"),
$helpBlock = $formgroup.find(".help-block");
if (isValid) {
if ($helpBlock.data().hasShownErrorBefore) {
$helpBlock.text($helpBlock.data().originalText);
}
$formgroup.removeClass("has-error");
@jeffijoe
jeffijoe / ReflectionHelper.cs
Created June 24, 2015 07:08
Utility I use in my tests to steal someone's private property.
// SkyClip
// - ReflectionHelper.cs
// --------------------------------------------------------------------
// Author: Jeff Hansen <jeff@jeffijoe.com>
// Copyright (C) Jeff Hansen 2015. All rights reserved.
using System;
using System.Reflection;
namespace SkyClip.TestHelpers.Reflection
@jeffijoe
jeffijoe / compositionRoot.js
Created September 6, 2016 08:53
Code snippets for my Medium article.
const currentUser = {
id: 123,
name: 'Jeff'
}
const todosRepository = new TodosRepository()
const todosService = makeTodosService({
todosRepository,
currentUser
})
@jeffijoe
jeffijoe / express-di.js
Created September 6, 2016 09:42
Snippet for my Medium article
var express = require('express')
var app = express()
var session = require('express-session')
app.use(session({
store: require('connect-session-knex')()
}))
@jeffijoe
jeffijoe / not-di.js
Created September 6, 2016 09:45
Snippet for my Medium article
import db from '../mydatabase'
export default {
getTodos: () => {
return db.query('select * from todos')
}
}
@jeffijoe
jeffijoe / di-todos-example.js
Created September 6, 2016 09:45
Snippet for my Medium article
export default function makeTodosService ({ db }) {
return {
getTodos: () => {
return db.query('select * from todos')
}
}
}
@jeffijoe
jeffijoe / di-todos-class-example.js
Created September 6, 2016 09:46
Snippet for my Medium article
export default class TodosService {
constructor({ db }) {
this.db = db
}
getTodos() {
return this.db.query('select * from todos')
}
}