Skip to content

Instantly share code, notes, and snippets.

@ruslangabitov
ruslangabitov / go-tls-renegotiation patch
Created December 1, 2014 23:41
go-tls-renegotiation patch
diff -r c242bbf5fa8c src/pkg/crypto/tls/common.go
--- a/src/pkg/crypto/tls/common.go Wed Jul 17 14:03:27 2013 -0400
+++ b/src/pkg/crypto/tls/common.go Thu Jul 18 13:45:43 2013 -0400
@@ -44,6 +44,7 @@
// TLS handshake message types.
const (
+ typeHelloRequest uint8 = 0
typeClientHello uint8 = 1
typeServerHello uint8 = 2
@sgrankin
sgrankin / macvim.rb
Created February 6, 2013 00:55
Hombrew's macvim formula using brew-installed python and ruby
require 'formula'
class Macvim < Formula
homepage 'http://code.google.com/p/macvim/'
url 'https://github.com/b4winckler/macvim/tarball/snapshot-66'
version '7.3-66'
sha1 'd11696f7089688fa96a45fc57410c60f6ca5a394'
head 'https://github.com/b4winckler/macvim.git', :branch => 'master'
@anaisbetts
anaisbetts / gh_unsub.rb
Last active December 25, 2015 18:09
Unsubscribe from all repos that you have not contributed to
#!/usr/bin/env ruby
require 'octokit'
pass_re = /^password: "(.*)"$/
token = `security find-generic-password -s "GitHub API Token" -g 2>&1 | grep "password"`.match(pass_re)[1]
c = Octokit::Client.new(:access_token => token)
user_login = c.user.login
@eulerfx
eulerfx / EvetStore.fs
Last active February 20, 2016 13:07
EventStore pull-to-push subscription transition
let subscribeAsAsyncSeq (conn:IEventStoreConnection) (stream:string) (resolveLinks:bool) (bufferSize:int) (ct:CancellationToken) = asyncSeq {
use buffer = new System.Collections.Concurrent.BlockingCollection<ResolvedEvent>(bufferSize)
let inline onEvent subs (evt:ResolvedEvent) =
buffer.Add(evt)
let inline onDrop (subs:EventStoreSubscription) (reason:SubscriptionDropReason) (ex:exn) =
printfn "SUBSCRIPTION DROPPED! last position=%i reason=%O ex=%O" (subs.LastEventNumber.GetValueOrDefault()) reason ex
()
let! subs = conn.SubscribeToStreamAsync(stream, resolveLinks, Action<_,_>(onEvent), Action<_,_,_>(onDrop), null) |> Async.AwaitTask
yield! buffer.GetConsumingEnumerable(ct) |> AsyncSeq.ofSeq
}
@AlainODea
AlainODea / hello.c
Last active March 16, 2016 09:00
Cross-compiler from x86_64 Linux to x86_64 Illumos on Ubuntu (works for Hello World and possibly more)
#include<stdio.h>
main()
{
printf("Hello World");
}
@imduffy15
imduffy15 / policy.json
Created September 13, 2016 18:01
Packer AWS IAM policy
{
"Statement": [
{
"Action": [
"ec2:Describe*",
"ec2:CreateKeyPair",
"ec2:DeleteKeyPair",
"ec2:CreateImage",
"ec2:DescribeKeyPairs",
"ec2:CreateSecurityGroup",
@smoser
smoser / debconf-get-selections
Created August 9, 2012 02:20
debconf-get-selections
#!/usr/bin/perl
#
# The goal of this is to read a bunch of variables from debconf
# To implement a "late_command_runparts" like function.
# Ie, you would populate the preseed with content like:
# late-command-d late-command/90-fix-hosts string content-for-fix-hosts
# late-command-d late-command/10-install-my-packages string payload
#
# Then, in the actual late_command, we would suck out all those
# values, and run them by doing something like this:
@thinkbeforecoding
thinkbeforecoding / FsCluster.fs
Created May 20, 2014 12:14
EventStore cluster in a F# script !
(*
This gist runs a 3 in memory node EventStore cluster
and a client that send messages to the cluster
To use the web interface, copy EventStore web folders.
You can found them in the server distribution at http://geteventstore.com/downloads/.
Then connect to http://localhost:2113/
You can view the cluster status at:
http://localhost:2113/web/gossip.htm
@praeclarum
praeclarum / SingleThreaded.cs
Created January 25, 2014 23:36
Use single threaded blocking code from your UI
using System;
using System.Threading;
using System.Threading.Tasks;
using System.Collections.Concurrent;
namespace Praeclarum
{
/// <summary>
/// Wraps a value and only allows access to it using a single thread
/// of execution (see SingleThreadQueue).
@robfe
robfe / QrCodeElement.cs
Created November 9, 2011 22:20
WPF templated control for QrCode.codeplex.com
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using Gma.QrCodeNet.Encoding;
namespace Gma.QrCodeNet.Wpf
{
public class QrCodeElement : Control