Skip to content

Instantly share code, notes, and snippets.

View Alxandr's full-sized avatar
⁉️
⁉️

Aleksander Heintz Alxandr

⁉️
⁉️
View GitHub Profile
@Alxandr
Alxandr / WebAPIResourceServer.cs
Created July 28, 2012 18:23
WebAPIResourceServer - so, yeah.. Have fun -.-
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Security.Cryptography.X509Certificates;
using System.Security.Principal;
using System.Text;
using System.Threading;
class Percolation extends WeightedQuickUnionUF {
private int width;
public Percolation(int n) {
super(n * n + 2);
for(int i = 0; i < n; i++) {
union(1 + n * (n - 1) + i, n * n + 1);
}
width = n;
}
@Alxandr
Alxandr / table.js
Created September 3, 2012 19:05
Javascript table
function table()
{
var keys = [],
vals = [];
function indexOf(key) {
return keys.indexOf(key);
}
function get(key) {
@Alxandr
Alxandr / gist:3763712
Created September 21, 2012 20:28
Sample async SpotiFire usage
Console.WriteLine("Enter username and password (a line for each)");
ISession session = await Spotify.CreateSession(key, cache, settings, userAgent);
session.MusicDeliver += session_MusicDeliver;
await session.Login(Console.ReadLine(), Console.ReadLine(), false);
session.SetPrefferedBitrate(sp_bitrate.BITRATE_320k);
await session.PlaylistContainer;
var playlist = await session.PlaylistContainer[0];
Console.WriteLine("Playing first from " + playlist.Name);
@Alxandr
Alxandr / bootstrap.bat
Created March 30, 2013 22:39
Bootstrap new win8 developer pc
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('http://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%systemdrive%\chocolatey\bin
cinst GoogleChrome
cinst firefox
cinst msysgit
cinst nodejs.install
cinst vlc
cinst sublimetext2
cinst fiddler4
@Alxandr
Alxandr / DatabaseExtensions.cs
Created July 16, 2013 13:03
Convert records in a record-set to a given type. Usage: myDbReader.Get<string>("userName")
internal static class DatabaseExtensions
{
public static bool HasColumn(this IDataRecord reader, int columnNumber)
{
return reader.FieldCount > columnNumber && columnNumber >= 0;
}
public static bool HasColumn(this IDataRecord reader, string columnName)
{
for (int i = 0, l = reader.FieldCount; i < l; i++)
@Alxandr
Alxandr / gist:6052416
Created July 22, 2013 08:58
Sample setter-compiler that setts all properties of a single type on an object.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace Tests
{
using System;
@Alxandr
Alxandr / gist:4ab0475c0e1ec86dbad8
Created May 13, 2014 21:58
Utility-method to enable per-default calling to base-methods in FakeItEasy
public static IFakeOptionsBuilder<TFaked> CallBase<TFaked>(this IFakeOptionsBuilder<TFaked> config)
{
return config.Strict()
.OnFakeCreated(fake =>
A.CallTo(fake).Where(c => !c.Method.IsFinal && !c.Method.IsAbstract)
.CallsBaseMethod());
}
#!/bin/sh
if test `uname` = Darwin; then
# Running on mac
brew update
brew install mono
else
# Running (presumably) on linux
# sudo add-apt-repository -y ppa:directhex/monoxide
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Runt.Bootstrap
{