Skip to content

Instantly share code, notes, and snippets.

View haf's full-sized avatar
💹
currently succeeding...

Henrik Feldt haf

💹
currently succeeding...
View GitHub Profile
anonymous
anonymous / Ropes in F#
Created May 5, 2010 14:11
// Learn more about F# at http://fsharp.net
#light
module Module1
open System
type Rope = Rope of int * int * RopeNode
and RopeNode =
Concat of Rope * Rope
| Leaf of String
@phatboyg
phatboyg / ActorBehaviorExample.cs
Created November 28, 2011 22:59
Example of applying behavior to an actor
class Cleaner_version_of_defining_actor_behavior
{
public void Some_method_in_your_code()
{
// create the actor instance, passing the state and an initializer
// in this case, applying the initial behavior of to the actor
ActorRef agent = Actor.New<MyState>(x => x.Apply<DefaultBehavior>());
// now messages can be sent to the actor to make it do things
// we will use a stateless actor for that interaction
hiera:
---
:hierarchy:
- %{env}/%{variant}_%{role}_%{group}_%{location}
- %{env}/%{variant}_%{role}_%{group}
- %{env}/%{variant}_%{role}
- %{env}/%{variant}
- %{env}
:backends:
<!DOCTYPE html>
<head>
<style type="text/css">
.saved { border: 3px solid green; }
.unsaved { border: 3px solid red; }
</style>
<script src="jquery-1.7.2.min.js"></script>
<script src="rx.js"></script>
<script src="rx.time.js"></script>
<script src="rx.jquery.js"></script>
@botimer
botimer / yesno.rb
Created June 7, 2012 19:56
Handy yes/no prompt for little ruby scripts
# This is a reasonably well-behaved helper for command-line scripts needing to ask a simple yes/no question.
# It optionally accepts a prompt and a default answer that will be returned on enter keypress.
# It keeps asking and echoes the answer on the same line until it gets y/n/Y/N or enter.
# I tried to get Highline to behave like this directly, but even though it's sophisticated, I didn't like the result.
# This isn't especially elegant, but it is straightforward and gets the job done.
require 'highline/import'
def yesno(prompt = 'Continue?', default = true)
a = ''
s = default ? '[Y/n]' : '[y/N]'
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@englishm
englishm / bootstrap.sh
Created September 4, 2012 02:29 — forked from kuleszaj/bootstrap.sh
Puppet Bootstrap, CentOS
#!/bin/bash
# Update our package manager...
sudo yum check-update -y
# Install dependencies for RVM and Ruby...
sudo yum -y install gcc-c++ patch readline readline-devel zlib zlib-devel libxml2-devel libyaml-devel libxslt-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison iconv-devel git
# Get and install RVM
curl -L https://get.rvm.io | sudo bash -s stable
@beddari
beddari / install_puppet_mac.sh
Created November 2, 2012 09:26 — forked from stevedomin/install_puppet_mac.sh
Installing Puppet on Mac OS X
#!/usr/bin/env bash
set -o errtrace
set -o errexit
facter_version=$1
puppet_version=$2
target_volume=$3
@robinsmidsrod
robinsmidsrod / logstash.conf
Created December 5, 2012 13:01
Logging Windows event log information to Logstash using nxlog and JSON transport
input {
tcp {
type => "syslog"
host => "127.0.0.1"
port => 3514
}
tcp {
type => "eventlog"
host => "10.1.1.2"
port => 3515
@jbtule
jbtule / AESGCM.cs
Last active October 30, 2023 21:14
I have two code examples that I wrote for best practices encrypting a string in c#. They are both using authenticated encryption. http://stackoverflow.com/a/10366194/637783
/*
* This work (Modern Encryption of a String C#, by James Tuley),
* identified by James Tuley, is free of known copyright restrictions.
* https://gist.github.com/4336842
* http://creativecommons.org/publicdomain/mark/1.0/
*/
using System;
using System.IO;
using System.Text;