Skip to content

Instantly share code, notes, and snippets.

@KyleGobel
KyleGobel / Watermark.cs
Created December 6, 2013 16:47
Watermark For Textbox
/// <summary>
/// Class that provides the Watermark attached property
/// </summary>
public static class WatermarkService
{
/// <summary>
/// Watermark Attached Dependency Property
/// </summary>
public static readonly DependencyProperty WatermarkProperty = DependencyProperty.RegisterAttached(
"Watermark",
using Xunit;
public class MyTests
{
[Fact] //This means this is a test
public void TestMyGetMethodWorks()
{
var journalService = new JournalService(/* not sure what kinda constructor you have */);
@KyleGobel
KyleGobel / HipchatMessage.cs
Created April 5, 2014 03:01
Proposed Model: This is what the bot will receive from redis for each Message
namespace Hipchat.Models
{
public class HipchatMessage
{
public int RoomId { get; set; }
public string RoomName { get; set; }
public string MessageSent { get; set; }
public string MentionName { get; set; }
public DateTime DateSent { get; set; }
public string FileUrl { get; set; }
@KyleGobel
KyleGobel / HttpUtilExtensions.cs
Created April 27, 2014 06:41
Will service stack take me?? Still missing some PCL stuff, but I don't think this can be done PCL anyway..or if it can it's alot harder and I don't know how
public static class HttpUtilExtensions
{
public static Task<string> PostJsonToUrlAsync(this string url, object data,
Action<HttpWebRequest> requestFilter = null, Action<HttpWebResponse> responseFilter = null,
Action<string> callback = null)
{
return SendStringToUrlAsync(url, method: "POST", requestBody: data.ToJson(), contentType: MimeTypes.Json, accept: MimeTypes.Json,
requestFilter: requestFilter, responseFilter: responseFilter, callback: callback);
}
@KyleGobel
KyleGobel / AnyFile.cs
Created June 9, 2014 21:27
Shows how to create a Log4NetLogger using the ServiceStack logging interfaces
public class ExampleController
{
public ILog Logger {get; set;}
public void AnyMethod(int param1, int param2)
{
Logger.DebugFormat("Parameters are {0}, and {1}", param1, param2);
}
}
@KyleGobel
KyleGobel / PathUtilities.cs
Last active August 29, 2015 14:02
Mapping Path Extensions for easily getting the correct Paths in .net projects. Idea taken from ServiceStack.
using System;
using System.IO;
/// <summary>
/// Mapping Path Extensions
/// </summary>
/// Gist Url: https://gist.github.com/KyleGobel/4b0f2b93014cae7bb52b
public static class PathUtilities
{
private static string MapAbsolutePath(string relativePath, string appendPartialPathModifier)
@model List<User>
<!-- loop through all the users in our model, and display their name and age -->
@foreach(var user in Model)
{
<div>
<p>Users Name: @user.Name</p>
<p>Users Age: @user.Age</p>
</div>
#!/usr/bin/env perl
use warnings;
use strict;
use Getopt::Std;
use LWP::UserAgent;
use JSON 'decode_json';
my $plugin_name = "Tracker Status check_tracker_status_json";
my $VERSION = "1.00";
@KyleGobel
KyleGobel / date.js
Created August 11, 2014 04:46
.Net Dates to Javascript Dates
function date(s) {
return new Date(parseFloat(/Date\(([^)]+)\)/.exec(s)[1]));
}
@KyleGobel
KyleGobel / stackedit_vim.js
Created August 15, 2014 00:30
VI StackEdit.io plugin
userCustom.onReady = function() {
var ace = {}
ace.require = require
ace.define = define
ace.require(["ace/lib/net"], function(acenet) {
acenet.loadScript("//cdnjs.cloudflare.com/ajax/libs/ace/1.1.01/keybinding-vim.js", function() {
e = document.querySelector(".ace_editor").env.editor
ace.require(["ace/keyboard/vim"], function(acevim) {
e.setKeyboardHandler(acevim.handler);
});