Skip to content

Instantly share code, notes, and snippets.

View bennage's full-sized avatar
📺
please stay tuned

Christopher Bennage bennage

📺
please stay tuned
View GitHub Profile
@bennage
bennage / alias.cs
Created March 10, 2014 23:10
making tuples a little easier to work with
namespace AliasFun
{
using MyRecord = System.Tuple<string, int>;
public class AnExample
{
public void Demonstrating()
{
var record = new MyRecord("thing", 42);
}
@bennage
bennage / ideas.md
Last active August 29, 2015 14:02
What questions do you have about participating in open source?

Are you new to open source? What sort of questions, concerns, or even fears do you have?

Culture

  • How do I start contributing to other projects?
  • How can I encourage contribution to my project?
  • Who should have commit rights?
  • What commitment am I making by opening my source?
  • How do I establish a community?
  • What expectations will the community have?
@bennage
bennage / sliding_window.cs
Last active August 29, 2015 14:02
is there an Rx method that already does this?
namespace RxTest
{
using System;
using System.Collections.Generic;
using System.Linq;
using Chunk = System.Collections.Generic.List<int>;
internal class Program
{
@leebyron
leebyron / es6_import.js
Last active August 29, 2015 14:13
ES6 import -> CJS example
import * as foo from "foo"
var $foo = require("foo");
var foo = $foo;
import foo from "foo"
var $foo = require("foo");
var foo = $foo.default;
import { foo } from "foo"
var $foo = require("foo");
// How about?
let (|NullEmpty|NonNull|) input =
if System.String.IsNullOrEmpty input then NullEmpty else NonNull
let fullName first last =
match first, last with
| NullEmpty, NullEmpty -> failwith "Both first and last cannot be null"
| NonNull, NullEmpty -> first
| NullEmpty, NonNull -> last
# in ruby, nil is an instance of NilClass. we're monkeypatching NilClass at this point, which is a bad idea for a production app.
# but for this example, it gets the point across and should help you find a solution to what you want... maybe...
class NilClass
def method_missing(name, *args)
if respond_to? name
return name(*args)
else
puts "do something about #{name} being nil, here"
# this will forward the call to the original NilClass.method_missing
@half-ogre
half-ogre / NuGet.targets.xml
Created February 22, 2012 04:22
A replacement for the NuGet.targets file that requires nuget.exe be on the path, so you don't have to commit it.
<?xml version="1.0" encoding="utf-8"?>
<!-- #### NOTE #### -->
<!-- To build with Mono's xbuild on bash, you must execute [`sudo install-nuget.sh`](https://gist.github.com/2595337) first. -->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>
<!-- Windows specific commands -->
param(
[string]$server = "origin",
[string]$branch = "master"
)
$gitStatus = (Get-GitStatus)
if ($gitStatus -eq $null) {
write-error "Not in a Git repository."
} elseif ($gitStatus.HasUntracked -or $gitStatus.HasWorking -or $gitStatus.HasIndex) {
@tj
tj / some.sh
Created October 11, 2012 18:45
change terminal tab name on cd
function tabname {
printf "\e]1;$1\a"
}
if [ x`type -t cd` == "xfunction" ]; then
# previously wrapped cd
eval $(type cd | grep -v 'cd is a function' | sed 's/^cd/original_cd/' | sed 's/^}/;}/' )
else
# builtin
eval "original_cd() { builtin cd \$*; }"
@domenic
domenic / launcher.cpp
Created November 6, 2012 22:23
Programmatically running a Windows 8 Metro app
#include <SDKDDKVer.h>
#include <ShObjIdl.h>
#include <tchar.h>
int wmain(int argc, wchar_t* argv[])
{
const wchar_t* appId = L"WinningJS-test-runner_aw9cjjms6ptaw!App";
CoInitialize(nullptr);
IApplicationActivationManager* aam = nullptr;