Skip to content

Instantly share code, notes, and snippets.

@Aimeast
Aimeast / Inlining.cs
Last active February 21, 2017 17:04
Test C# inlining method (framework 4.5)
/*
* Following code for test an method will be inlined by JIT or not
* Tested on Framework 4.5, Win8 x64
*
* http://blogs.msdn.com/b/ericgu/archive/2004/01/29/64717.aspx
* http://blogs.microsoft.co.il/blogs/sasha/archive/2012/01/20/aggressive-inlining-in-the-clr-4-5-jit.aspx
*/
using System;
using System.Diagnostics;
@cstipkovic
cstipkovic / formatDate.js
Last active July 31, 2017 03:02
A simple format Date function using Javascript prototype
/*
Based on Rick Strahl code
http://www.west-wind.com/weblog/posts/2008/Mar/18/A-simple-formatDate-function-for-JavaScript
Contributors:
Clauber Stipkovic - @clauberhalic
Mário Rinaldi - @MarioRinaldi
*/
Date.prototype.formatDate = function (format) {
using Microsoft.ConcurrencyVisualizer.Instrumentation;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApplication3
@jchadwick
jchadwick / JsonMessageFormatter.cs
Created April 20, 2012 18:47
MSMQ Message JSON Formatter
using System;
using System.IO;
using System.Messaging;
using System.Text;
using Newtonsoft.Json;
public class JsonMessageFormatter : IMessageFormatter
{
private static readonly JsonSerializerSettings DefaultSerializerSettings =
new JsonSerializerSettings {
@johnmcase
johnmcase / updateNpm.bat
Last active October 6, 2022 16:28
Update npm on windows
rem see https://github.com/coreybutler/nvm-windows/issues/300
@echo off
SETLOCAL EnableDelayedExpansion
if [%1] == [] (
echo Pass in the version you would like to install, or "latest" to install the latest npm version.
) else (
set wanted_version=%1
@rajeshsegu
rajeshsegu / BrowserDetectProtocol.js
Created September 13, 2012 19:26
Detect Browser Custom Protocols
<html>
<head>
<title>Detect Custome Protocol</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.1.min.js"></script>
</head>
<body>
<input id="protocol" value="" placeholder="custom protocol"/>
<button id="launch">Launch</button>
<!-- Mozilla Only -->
<iframe id="hiddenIframe" src="about:blank" style="display:none"></iframe>
@dhoerl
dhoerl / KeychainItemWrapper.h
Last active April 4, 2023 08:15
KeychainItemWrapper ARCified. Added the ability to manage a dictionary in place of just a string - the #define PASSWORD_USES_DATA in the .m file switches the mode.
/*
File: KeychainItemWrapper.h
Abstract:
Objective-C wrapper for accessing a single keychain item.
Version: 1.2 - ARCified
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
Inc. ("Apple") in consideration of your agreement to the following
terms, and your use, installation, modification or redistribution of
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Newtonsoft.Json.Serialization
{
/// <summary>
/// Keep casing when serializing dictionaries
/// cf. https://stackoverflow.com/a/24226442/3781540
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="false"
internalLogLevel="Off" internalLogFile="logs/nlog-internal.log">
<!-- cf. https://github.com/NLog/NLog/wiki/Layout-Renderers -->
<variable name="default_layout"
value="${time} [${logger}(L\:${callsite-linenumber})] ${uppercase:${level}} (TID\:${threadid}) ${message}${onexception:${newline}${exception:format=ToString}}" />
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Web;
using Newtonsoft.Json;
namespace Newtonsoft.Json.Serialization
{
/// <summary>