Skip to content

Instantly share code, notes, and snippets.

@Layoric
Layoric / AppHost.cs
Last active August 29, 2015 13:56
Dart config
public override void Configure(Funq.Container container)
{
//ServiceStack v3
//SetConfig(new EndpointHostConfig {AllowFileExtensions = {"dart"}});
//ServiceStack v4
SetConfig(new HostConfig { AllowFileExtensions = {"dart"}});
}
@Layoric
Layoric / ArrayToTable.js
Created March 3, 2014 03:56
Javascript function to split a flat array into a fixed number of columns
var arrayToTable = function (array, numOfCols) {
var arrayLength = array.length;
var rows = [{
columns: []
}];
var rowNum = 0;
for(var i = 0; i < arrayLength; i++) {
var rowMod = (i) % numOfCols;
if(rowMod === 0) {
rows.push({
@Layoric
Layoric / scrollto.js
Created June 16, 2014 07:15
Simple angular replacement for scroll to content links
app.directive('scrollTo', [function () {
"use strict";
return {
restrict: 'EA',
controller: function ($scope) {
},
link: function ($scope,$element,$attrs) {
if($attrs.scrollTo != null) {
var elementNameToScroll = $attrs.scrollTo;

Keybase proof

I hereby claim:

  • I am layoric on github.
  • I am layoric (https://keybase.io/layoric) on keybase.
  • I have a public key whose fingerprint is 135F AF1F 5D3D 50D3 DBA3 FB53 E636 C4A7 22FE 459D

To claim this, I am signing this object:

@Layoric
Layoric / basicAuthTest
Created September 7, 2014 09:14
SS Basic authentication
[TestFixture]
public class UnitTests
{
private readonly ServiceStackHost appHost;
public UnitTests()
{
appHost = new TestAppHost();
appHost.Init().Start("http://*:10100/");
}
@Layoric
Layoric / getasync.cs
Created August 20, 2015 06:04
ServiceStack JsonServiceClient GetAsync example snippet
client.GetAsync<CustomersResponse>("/customers").Success(response => {
foreach(var c in response.Customers) {
Console.WriteLine(c.CompanyName);
}
}).Error(exception => {
Console.WriteLine(exception.Message);
});
@Layoric
Layoric / GetAllValuesBetweenIDs.cs
Created November 5, 2012 23:35
Helpful C# method to get value between two string identifiers
/// <summary>
/// Generic function to pull out string values between two identifiers
/// </summary>
/// <param name="document"></param>
/// <param name="startVal"></param>
/// <param name="endVal"></param>
/// <returns></returns>
private static List<string> GetAllValuesBetweenKeys(string document, string startVal, string endVal)
{
string temp = document;
@Layoric
Layoric / CookieAwareWebClient.cs
Created December 2, 2012 06:00
CookieAwareWebClient
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
@Layoric
Layoric / HelloWorld.cs
Created December 5, 2015 04:05
ServiceStack Model routes example
[Route("/hello/{Name}")]
public class Hello : IReturn<HelloResponse>
{
public string Name { get; set; }
}
public class HelloResponse
{
public string Result { get; set; }
}
@Layoric
Layoric / ApplicationDirectory
Created July 25, 2013 01:10
Get file system directory of where the current executable is running from
string assemblyDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetCallingAssembly().Location);