Skip to content

Instantly share code, notes, and snippets.

jokecamp / AppHostBase
Created Jun 4, 2014
ServiceStack v3.9.55.0 - Dynamically add OPTIONS to all routes
View AppHostBase
/// Call this ad the end of your app host Configure(Funq.Container container) method
private void AddOptionsVerbToAllRoutes(IServiceRoutes routes)
var map = EndpointHost.ServiceManager.ServiceController.RestPathMap;
foreach (var key in map.Keys)
foreach (RestPath rp in map[key])
routes.Add(rp.RequestType, rp.Path, "OPTIONS");
jokecamp / client.html
Last active Aug 29, 2015
Working 1.0 with path option
View client.html
<!doctype html>
<title>Socket.IO chat</title>
<form action="">
<input type="input" id="m" /><button>Send</button>
<pre id="output"></pre>
jokecamp / ConsoleExample.cs
Last active Dec 13, 2015
RSS Example Output
View ConsoleExample.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using ServiceStack.Text;
using System.Runtime.Serialization;
using System.Xml;
[assembly: ContractNamespace("", ClrNamespace = "ServiceStackTester")]
jokecamp / gist:7529013
Created Nov 18, 2013
Various ways of sanitizing XML input
View gist:7529013
public string Clean(string text)
return new string(text.Where(XmlConvert.IsXmlChar).ToArray());
public static string CleanInvalidXmlChars(string text)
jokecamp / RequestFilter
Created Dec 13, 2013
ServiceStack v3 Partial Updates
View RequestFilter
this.RequestFilters.Add((httpReq, httpResp, requestDto) =>
var hasFilter = requestDto as IAllowPartialUpdate;
if (hasFilter != null)
if (httpReq.QueryString["fields"] != null)
// store for later
httpReq.Items.Add("Patch_Fields", httpReq.QueryString["fields"].Split(new[] {','}));
View set-assemblyinfo.ps1
function getVersion()
$tag = iex "git describe --long --tags --always"
$a = [regex]"v\d+\.\d+\.\d+\-\d+"
$b = $a.Match($tag)
$b = $b.Captures[0].value
$b = $b -replace '-', '.'
$b = $b -replace 'v', ''
Write-Host "Version found: $b"
View ServiceStackApiHMAC
using ServiceStack.WebHost.Endpoints;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Security;
using ServiceStack.Common.Web;
using ServiceStack.Logging;
using ServiceStack.ServiceHost;
using ServiceStack.ServiceInterface;
jokecamp / monoserver
Created Aug 31, 2013
Linux startup script for fastcgi-mono-server4
View monoserver
# Provides:
# Required-Start: $local_fs $syslog $remote_fs
# Required-Stop: $local_fs $syslog $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start fastcgi mono server with hosts
View Angular No Whitespace Allowed Vaidator Directive
<md-input-container class="admin-form">
<input md-input placeholder="Block Title" nfNoSpaces [(ngModel)]="block.title" id="block-{{ }}-input-name" name="title"
<md-hint [ngStyle]="{'color': 'red'}" align="start" *ngIf="!title.valid && !title.pristine">Title is required.</md-hint>
Be sure to include ref to directive in module declarations array.
jokecamp / example.dart
Created Jan 17, 2014
Dart HMAC SHA 256 Example code
View example.dart
import 'dart:html';
import 'dart:convert';
import 'package:crypto/crypto.dart';
void main() {
String secret = 'secret';
String message = 'Message';
List<int> secretBytes = UTF8.encode('secret');
You can’t perform that action at this time.