Skip to content

Instantly share code, notes, and snippets.

Asbjørn Ulsberg asbjornu

View GitHub Profile
@asbjornu
asbjornu / soundcloud-no-reposts.js
Created Sep 24, 2018
Removes reposts from your SoundCloud stream
View soundcloud-no-reposts.js
// ==UserScript==
// @name SoundCloud No Reposts
// @version 1
// @grant none
// ==/UserScript==
(function repeat() {
var posts = document.getElementsByClassName('soundList__item');
var skip = [];
@asbjornu
asbjornu / thingthangthung.cs
Last active Apr 22, 2017 — forked from einarwh/thingthangthung.cs
Object initializer surprise.
View thingthangthung.cs
void Main()
{
var t = new Thing(new Thang { Thung = "lol" })
{
Thang = { { "OMG" } }
};
t.Dump();
}
View RecursiveDataAnnotationsValidator.cs
public class RecursiveDataAnnotationsValidator : IModelValidator
{
private readonly IModelValidator validator;
public RecursiveDataAnnotationsValidator(IModelValidator innerValidator, Type type)
{
if (innerValidator == null)
throw new ArgumentNullException(nameof(innerValidator));
@asbjornu
asbjornu / configure.sh
Created Aug 9, 2016
SchismTracker configure script
View configure.sh
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for schismtracker 20160805.
#
#
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
#
#
# This configure script is free software; the Free Software Foundation
# gives unlimited permission to copy, distribute and modify it.
@asbjornu
asbjornu / GetWholeNumberAndDecimalsFromDecimal.cs
Last active Jan 26, 2016
Get whole number and decimals from a System.Decimal in C#
View GetWholeNumberAndDecimalsFromDecimal.cs
var value = 123.8723498m;
var major = (int)Math.Truncate(value);
var bits = decimal.GetBits(value);
var decimalPart = bits[3];
var bytes = BitConverter.GetBytes(decimalPart);
var decimalLength = bytes[2];
var pow = (int)Math.Pow(10, decimalLength);
var minor = (int)((value - major) * pow);
var formatted = String.Format("{0}.{1}", major, minor);
View infinite-scroll-conditional-query-args.php
<?php
/**
* Includes a few useful predicates in the bootstrapped `infiniteScroll` JS object
* that is served along with the rest of the document upon initial page request.
*/
add_filter( 'infinite_scroll_js_settings', 'pla_extra_js_settings' );
function pla_extra_js_settings( $js_settings ) {
$js_settings['text'] = __( "Plus de contenus", "pla" );
@asbjornu
asbjornu / PayEx_CLA.md
Last active Sep 3, 2018 — forked from CLAassistant/SAP_CLA
PayEx Individual Contributor License Agreement
View PayEx_CLA.md

PayEx Individual Contributor License Agreement

Thank you for your interest in contributing to open source software projects (“Projects”) made available by PayEx or its affiliates (“PayEx”). This Individual Contributor License Agreement (“Agreement”) sets out the terms governing any source code, object code, bug fixes, configuration changes, tools, specifications, documentation, data, materials, feedback, information or other works of authorship that you submit or have submitted, in any form and in any manner, to PayEx in respect of any of the Projects (collectively “Contributions”).

Contrary to “Closed Source” software or proprietary software – where a creator maintains exclusive control over his or her source code – “Open Source Software” is software with source code that anyone can inspect, modify, share, learn from and enhance. Outlined below you will find PayEx Individual Contributor License Agreement under which you as a contributor retain all of your rights, titles and interests in and to your con

@asbjornu
asbjornu / enforce-unicode.py
Last active Aug 29, 2015
Enforce UTF-8 Without BOM In All C# Files
View enforce-unicode.py
#!/usr/local/bin/python
# -*- coding: utf-8 -*-
import os
import glob
import fnmatch
import codecs
from chardet.universaldetector import UniversalDetector
# from http://farmdev.com/talks/unicode/
View keybase.md

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 Aug 29, 2015
What would C# look like if it was case insensitive?
View case-insensitive.cs
namespace CaseInsensitive
{
public class Test
{
private readonly string name;
public Test(string name)
{
this.name = name;
}
You can’t perform that action at this time.