Skip to content

Instantly share code, notes, and snippets.

@msarchet
msarchet / plexer.js
Created June 30, 2019 19:19
A Dexplexer example for working with orca on multiple port
const dgram = require('dgram')
const PortMaps = require('./portmaps.json')
this.server = dgram.createSocket('udp4')
this.listener = dgram.createSocket('udp4')
this.listener.on('message', (msg, rinfo) => {
let parts = `${msg}`.split("M")
let maps = parts[0].split("")
@msarchet
msarchet / GenericLockedUpdates.cs
Last active October 16, 2017 17:37
Sometime you need to make sure that Redis is actually updating what you want to update
/*
Sometimes you need to just update something and assure that it happens
*/
public static class GenericReplaceLock
{
public static void UpdateListItem<T>(this IRedisClientsManager Manager, string key, T old, T newer)
{
using (var Client = Manager.GetClient())
using (var redis = Client.As<T>())
using (var transaction = redis.CreateTransaction())
@msarchet
msarchet / chosenhandler.js
Created June 9, 2012 17:05
Simple Chosen.js binding handler for knockoutjs
//knockout.js can be found at http://www.knockoutjs.com
//chosen.js can be found at http://harvesthq.github.com/chosen/
//jquery.js can be found at http://jquery.com
//Usage is data-bind="chosen: true"
//Want to clean this up to eventually work as
//data-bind="chosen: { options: SelectOptions, value: selectValue}"
ko.bindingHandlers.chosen = {
@msarchet
msarchet / SelfServer.js
Last active November 2, 2016 05:35
A Javascript file that acts as both a nodejs webserver and the index.html for the site that it serves
//<html>
// <head>
// <title>Self Server</title>
// </head>
// <body>
// <h1>Explanation here: https://gist.github.com/msarchet/d630edffda1522fa8dc0ad238969fdc0</h1>
// <script type='text/javascript'>
// var process = { env: { server: false } }
if (process.env.server) {
const http = require('http')
@msarchet
msarchet / Test.xaml
Created June 24, 2016 17:26
Template-10-UnitTest-Failure
<UserControl
x:Class="DebugCheck.Views.Test"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:DebugCheck.Views"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="400">
using System;
namespace Sandbox
{
class Program
{
static void Main(string[] args)
{
// Annoying to have to check Value all the time
Console.WriteLine(Person.LazyPerson.Value == Person.LazyPerson.Value);
public class LayoutController : ApiController
{
[HttpGet]
[Route("", Name = "Index")]
public async Task<HttpResponseMessage> LayoutHtml()
{
var path = HttpContext.Current.IsDebuggingEnabled
? HttpContext.Current.Server.MapPath("~/App/Views/Index.html")
: HttpContext.Current.Server.MapPath("~/App/View/Index_Release.html");
var file = await File.OpenText(path).ReadToEndAsync();
@msarchet
msarchet / BaseActionResult.cs
Last active January 2, 2016 17:59
Generic Inheritance
namespace Services.Core.HttpActionResult
{
using System.Web.Http;
using System.Net.Http;
using System.Threading.Tasks;
public abstract class BaseActionResult : IHttpActionResult
{
protected readonly HttpRequestMessage request;
protected readonly Task task;
Disable-UAC
Set-ExplorerOptions -showHiddenFilesFoldersDrives
Enable-RemoteDesktop
Set-TaskbarSmall
cinst VisualStudio2013Ultimate
cinst Fiddler
cinst SublimeText2
cinst kdiff3
cinst Dropbox
@msarchet
msarchet / redis.md
Last active December 13, 2015 22:09
Overview for Redis Hangout

Redis Basics

  • How to get it running
  • Data Types
  • Using it in a development environment
  • Using it in a production environment

ServiceStack.Redis

  • Generic vs Non-Generic