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

Keybase proof

I hereby claim:

  • I am asbjornu on github.
  • I am asbjornu (https://keybase.io/asbjornu) on keybase.
  • I have a public key whose fingerprint is C671 0035 5226 586F 63DF 0B80 BC58 62FF 43E5 C36E

To claim this, I am signing this object:

@asbjornu
asbjornu / case-insensitive.cs
Last active August 29, 2015 13:57
What would C# look like if it was case insensitive?
namespace CaseInsensitive
{
public class Test
{
private readonly string name;
public Test(string name)
{
this.name = name;
}
@asbjornu
asbjornu / inline-unit-test.cs
Created February 24, 2014 08:39
Unit test syntax for C#
public class HelloWorld
{
public string Say()
{
return "Hello World!";
}
test
{
void Say_ReturnsHelloWorld()
@asbjornu
asbjornu / the_post_thumbnail_url.php
Last active December 18, 2015 09:19
WordPress' missing the_post_thumbnail_url() function.
<?php
/**
* Outputs the URL of the "Featured Image", also known as "Post Thumbnail".
* @param $post_id (optional) The ID of the Post whose Thumbnail you wish to output. When used within "The Loop", this parameter can be ommitted.
* @return void
*/
function the_post_thumbnail_url($post_id = false) {
global $post;
@asbjornu
asbjornu / sum.bas
Created November 29, 2012 15:20
Sums Cell(j, k) in all Tables in a Microsoft Word document and places the Sum in the last Table in the document
'
' Sums Cell(j, k) in all Tables in a Microsoft Word document and places the Sum in the last Table in the document.
'
' It will only work for very specific scenarios where your Tables follow the standard Word Table template where the
' first row and cell contains headers and the last row contains some sort of footer. The rest of the cells in
' the Table will be summarized according to the rowCount, rowOffset, cellCount and cellOffset constants below.
'
Sub Sum()
' This constant is the string of the first cell of the first row in the tables
' it needs to find to add its cells to the total sum
@asbjornu
asbjornu / OpenRastaResourceRegistration.cs
Created August 1, 2012 08:10
OpenRasta resource registration with codecs for three different MIME types and extensions
MediaType json = MediaType.Json.WithQuality(1f);
MediaType xml = MediaType.Xml.WithQuality(0.9f);
MediaType html = MediaType.Html.WithQuality(0.1f);
ResourceSpace.Has
.ResourcesOfType<ResourceBase>()
.WithoutUri
.TranscodedBy<MyXmlCodec>().ForMediaType(xml).ForExtension("xml")
.And.TranscodedBy<MyHtmlCodec>().ForMediaType(html).ForExtension("html")
.And.TranscodedBy<JsonDataContractCodec>().ForMediaType(json).ForExtension("json");
@asbjornu
asbjornu / argumentexception.txt
Created December 16, 2011 10:50
Mono.Cecil throws ArgumentException on AssemblyDefinition.ReadAssembly()
System.ArgumentException: Value does not fall within the expected range.
at System.Runtime.CompilerServices.RuntimeHelpers.InitializeArray(Array array, RuntimeFieldHandle fldHandle)
at Mono.Cecil.Mixin.GetSize(CodedIndex self, Func`2 counter)
at Mono.Cecil.PE.Image.GetCodedIndexSize(CodedIndex coded_index)
at Mono.Cecil.PE.ImageReader.GetCodedIndexSize(CodedIndex index)
at Mono.Cecil.PE.ImageReader.ComputeTableInformations()
at Mono.Cecil.PE.ImageReader.ReadTableHeap()
at Mono.Cecil.PE.ImageReader.ReadMetadata()
at Mono.Cecil.PE.ImageReader.ReadImage()
at Mono.Cecil.PE.ImageReader.ReadImageFrom(Stream stream)
@asbjornu
asbjornu / cs-namespace-svn-move.rb
Created December 6, 2011 09:17
Move C# files into namespace folders with Subversion
Dir.glob("*.cs") do | file |
target = file.split('.').map { | segment |
if segment != "cs"
segment
end
}.compact.join('/')
if target.index('Generated')
target['/Generated'] = ''
target = 'Generated/' + target
@asbjornu
asbjornu / new-finder-window.scpt
Created September 10, 2011 13:29
Open the home folder in a new Finder window
tell application "Finder"
activate
open (path to home folder)
end tell
@asbjornu
asbjornu / volume-up.scpt
Created September 10, 2011 13:21
Turn up the volume in OS X by two steps
set volume output volume (get (output volume of (get volume settings)) + 2)