Skip to content

Instantly share code, notes, and snippets.

View asbjornu's full-sized avatar
💭
He's a loathsome offensive brute, yet I can't look away.

Asbjørn Ulsberg asbjornu

💭
He's a loathsome offensive brute, yet I can't look away.
View GitHub Profile
@mnot
mnot / uri_validate.py
Last active March 3, 2022 14:32
uri_validate.py: Validation regex for URIs, URI references, and relative URIs
#!/usr/bin/env python
"""
Regex for URIs
These regex are directly derived from the collected ABNF in RFC3986
(except for DIGIT, ALPHA and HEXDIG, defined by RFC2234).
Additional regex are defined to validate the following schemes according to
their respective specifications:
@scottlittlewood
scottlittlewood / NHibernateSessionPipelineContributor.cs
Created November 29, 2010 13:43
Shows a simple implementation of using an OpenRasta Pipeline Contributor to manage nHibernate Sessions on a per request basis
public class NHibernateSessionPipelineContributor : IPipelineContributor
{
private readonly IDependencyResolver _resolver;
public NHibernateSessionPipelineContributor(IDependencyResolver resolver)
{
_resolver = resolver;
}
public void Initialize(IPipeline pipelineRunner)
@SzymonPobiega
SzymonPobiega / gist:953302
Created May 3, 2011 13:10
Monads in action
protected override ValidationResults OnValidate(PurchaseTransaction purchaseTransaction)
{
return purchaseTransaction
.With(ValidationCheck)
.Unless(IsValidateServiceDown)
.Try(SendMessageToTransecure)
.InCaseOfException(MarkServiceAsDown)
.Return(TheResult, OrFailureCodeInCaseOfFailure);
}
@jasonrudolph
jasonrudolph / git-branches-by-commit-date.sh
Created February 12, 2012 20:40
List remote Git branches and the last commit date for each branch. Sort by most recent commit date.
# Credit http://stackoverflow.com/a/2514279
for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; done | sort -r
@gasman
gasman / pnginator.rb
Created April 30, 2012 18:08
pnginator: pack Javascript into a self-extracting PNG
#!/usr/bin/env ruby -w
# pnginator.rb: pack a .js file into a PNG image with an HTML payload;
# when saved with an .html extension and opened in a browser, the HTML extracts and executes
# the javascript.
# Usage: ruby pnginator.rb input.js output.png.html
# By Gasman <http://matt.west.co.tt/>
# from an original idea by Daeken: http://daeken.com/superpacking-js-demos
@l15n
l15n / git-branches-by-commit-date.sh
Created July 13, 2012 08:47 — forked from jasonrudolph/git-branches-by-commit-date.sh
List remote Git branches and the last commit's author and author date for each branch. Sort by most recent commit's author date.
# Credit http://stackoverflow.com/a/2514279
for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ai %ar by %an" $branch | head -n 1` \\t$branch; done | sort -r
@robmiller
robmiller / git-cleanup-repo
Last active February 27, 2024 10:09
A script for cleaning up Git repositories; it deletes branches that are fully merged into `origin/master`, prunes obsolete remote tracking branches, and as an added bonus will replicate these changes on the remote.
#!/bin/bash
# git-cleanup-repo
#
# Author: Rob Miller <rob@bigfish.co.uk>
# Adapted from the original by Yorick Sijsling
git checkout master &> /dev/null
# Make sure we're working with the most up-to-date version of master.
git fetch
@death
death / enamel.lisp
Created April 24, 2013 11:07
Old enamel hack
;;;; Enamel - Erik Naggum's Markup Language
;;;
;;; See http://xach.com/naggum/articles/3207626455633924@naggum.net.html
;;;
(define-condition malformed-enamel (error) ())
(defun parse-enamel (in &key (case :upcase) (strip-newlines t) (distinguish-attributes nil) (package *package*))
(let ((node '()))
(labels ((skip-ws () (peek-char t in nil))
@powerumc
powerumc / remove-mono.sh
Last active May 7, 2024 10:57
Uninstalling Mono on Mac OS X
#!/bin/sh -x
#This script removes Mono from an OS X System. It must be run as root
rm -r /Library/Frameworks/Mono.framework
rm -r /Library/Receipts/MonoFramework-*
for dir in /usr/bin /usr/share/man/man1 /usr/share/man/man3 /usr/share/man/man5; do
(cd ${dir};
@panlw
panlw / MyLanguageGen.sh
Last active March 22, 2016 06:29
Use Antlr v4 to do code generation for .NET
#!/bin/sh
# Generate Lexer/Visitor for syntax tree of MyLanguage
# You should download the jar file from
# http://tunnelvisionlabs.com/downloads/antlr/2013-02-27-antlr4-csharp-4.0.1-SNAPSHOT.7z
java -cp .:./antlr4-csharp-4.0.1-SNAPSHOT-complete.jar org.antlr.v4.CSharpTool -Dlanguage=CSharp_v3_5 -no-listener -visitor -package MyNamespace MyLanguage.g4