Instantly share code, notes, and snippets.

View Base10ToBase64Url.cs
public static string Base10ToBase64Url(ulong base10)
{
char[] base64url = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".ToCharArray();
var res = new List<char>();
for (ulong remainder = base10, mod = remainder % 64; remainder > 0; remainder = remainder / 64, mod = remainder % 64)
{
res.Add(base64url[mod]);
}
res.Reverse();
return new String(res.ToArray());
View IQueryableExtensions.cs
using System;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
internal static class IQueryableExtensions
{
public static IQueryable<T> OrderBy<T>(this IQueryable<T> source, string ordering)
{
return source.OrderBy(ordering, "OrderBy");
View HttpAuthModule.cs
using System;
using System.Linq;
using System.Security.Claims;
using System.Text;
using System.Threading;
using System.Web;
namespace HttpAuthModule
{
public class HttpAuthModule : IHttpModule
View StorageProvider.cs
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;
using System;
using System.IO;
using System.Net.Mime;
using System.Threading.Tasks;
namespace N3rd.Storage
{
public interface IStorageProvider
View RotaryEncoder.py
#!/usr/local/bin/python
import RPi.GPIO as GPIO
class RotaryEncoder:
DIRECTION_CLOCKWISE = 1
DIRECTION_COUNTERCLOCKWISE = 3
prv_seq = 0
View gist:5c29fd1ccd23852e050c
$.ajaxSetup({
beforeSend: function (jqXHR, settings) {
var types = ['DELETE', 'HEAD', 'PUT'];
if ($.inArray(settings.type, types) !== -1) {
jqXHR.setRequestHeader('X-HTTP-Method-Override', settings.type);
settings.type = 'POST';
}
}
});
View sortableListBindingHandler.js
ko.bindingHandlers.sortableList = {
init: function (element, valueAccessor, allBindings) {
var items = allBindings.get('items') || 'li';
var update = allBindings.get('update') || 'Index';
var disable = allBindings.get('disable') || false;
$(element).sortable({
items: items,
update: function ($e, $ui) {
$ui.item.parent().children(items).each(function (k, v) {
View AuthenticationHandler.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Security.Claims;
using System.Security.Principal;
using System.Threading;
using System.Threading.Tasks;
using System.Web;
View Rx-Test.cs
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Reactive.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Rx_Test
View Dynamic.cs
using System;
using System.Collections.Generic;
using System.Dynamic;
namespace DynamicTest
{
class Program
{
static void Main(string[] args)
{