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
@asbjornu
asbjornu / gist:1053555
Created June 29, 2011 09:56
IronJS executing UglifyJS results in 'TypeError: 64'
IronJS.UserError: TypeError: 64
at IronJS.Hosting.FSharp.run(Delegate compiled, T t) in D:\AUL\Dev\Misc\IronJS\Src\IronJS\Hosting.fs:line 152
at IronJS.Hosting.CSharp.Context.Execute(String source) in D:\AUL\Dev\Misc\IronJS\Src\IronJS\Hosting.fs:line 240
at Uglify.Uglifier.Uglify(String code) in D:\AUL\Dev\Misc\Uglify.NET\src\app\Uglify\Uglifier.cs:line 28
at Uglify.Terminal.Terminal.Main() in D:\AUL\Dev\Misc\Uglify.NET\src\tests\Terminal\Terminal.cs:line 12
@asbjornu
asbjornu / export-address-book.scpt
Created September 10, 2011 12:26
Export all Mac OS X Address Book entries as single vCard files to a chosen folder
property targetfolder : "" as Unicode text
try
set targetfolder to choose folder with prompt "Choose a folder or volume:" as Unicode text
on error
beep
display dialog "Invalid path" buttons "Exit"
return
end try
@asbjornu
asbjornu / volume-down.scpt
Created September 10, 2011 13:20
Turn down the volume in OS X by two steps
set volume output volume (get (output volume of (get volume settings)) - 2)
@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)
@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 / 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 / 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 / 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 / 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 / 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;