Skip to content

Instantly share code, notes, and snippets.

const express = require('express')
const jwt = require('express-jwt');
const dotenv = require('dotenv');
const constants = require('./constants');
const sandcastle = require('sandcastle');
dotenv.config();
const app = express()
const port = constants.PORT
@dschenkelman
dschenkelman / CreateFile.cs
Created May 9, 2014 04:24
Asynchronous I/O in C#: I/O Completion Ports
const uint Flags = 128 | (uint)1 << 30;
var fileHandle = Interop.CreateFile("test.txt", (uint)1 << 31, 0, IntPtr.Zero, 3,
/*FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED */ Flags,
IntPtr.Zero);
Interop.CreateIoCompletionPort(
fileHandle,
completionPortHandle,
(uint)fileHandle.ToInt64(),
@dschenkelman
dschenkelman / Extensions.cs
Created May 9, 2014 04:38
Intro to OWIN talk and a simple IP filtering middleware sample
namespace Owin.IpFilter
{
using System;
using System.Net;
public static class Extensions
{
public static IAppBuilder UseIpFiltering(this IAppBuilder appBuilder, Func<IPAddress, bool> rejectRequest)
{
appBuilder.Use(typeof(IpFilterMiddleware), rejectRequest);
@dschenkelman
dschenkelman / EventAggregator.js
Created October 8, 2016 02:49
JS event aggregator
import * as Rx from 'rx';
const kSubject = Symbol('subject');
export default class EventAggregator {
constructor(){
this[kSubject] = new Rx.Subject();
}
publish(event, payload){
@dschenkelman
dschenkelman / perf-flame-graph-notes.md
Last active June 20, 2016 21:56 — forked from trevnorris/perf-flame-graph-notes.md
Quick steps of how to create a flame graph using perf

The prep-script.sh will setup the latest Node and install the latest perf version on your Linux box.

When you want to generate the flame graph, run the following (folder locations taken from install script):

sudo sysctl kernel.kptr_restrict=0
# May also have to do the following:
# (additional reading http://unix.stackexchange.com/questions/14227/do-i-need-root-admin-permissions-to-run-userspace-perf-tool-perf-events-ar )
sudo sysctl kernel.perf_event_paranoid=0
@dschenkelman
dschenkelman / keybase.md
Created April 7, 2016 13:34
keybase.md

Keybase proof

I hereby claim:

  • I am dschenkelman on github.
  • I am yenkel (https://keybase.io/yenkel) on keybase.
  • I have a public key whose fingerprint is 6955 6E57 3532 5D50 05EE FBF1 75A0 FEFD F7B4 DDAA

To claim this, I am signing this object:

@dschenkelman
dschenkelman / Async.cs
Last active January 1, 2016 09:49
Async XBehave Steps
[Trait("AcceptanceTest", "RunningScriptsTests")]
[Trait("Requires", "Internet Connection")]
[Trait("Requires", "Administrator Privileges")]
public void RunningWebApiHostSampleEnablesWebAccessInLocalhostXBehave(string originalWorkingDirectory, Task<int> scriptTask)
{
const string MethodName = "RunningWebApiHostSampleEnablesWebAccessInLocalhostXBehave";
"Given an existing Web API host sample (similar to https://github.com/scriptcs/scriptcs-samples/tree/master/webapihost)"
._(() =>
{
@dschenkelman
dschenkelman / InitialTest.cs
Last active January 1, 2016 09:19
IntegrationTests
public class NugetPackageInstallationTests : IDisposable
{
private readonly string _originalWorkingDirectory;
private readonly string _filesDirectory;
private string _localDirectory;
public NugetPackageInstallationTests()
{
_originalWorkingDirectory = Environment.CurrentDirectory;
_filesDirectory = Path.Combine(AcceptanceTestHelpers.GetExecutingAssemblyDirectory(), "Files");
@dschenkelman
dschenkelman / outstart
Created November 24, 2015 18:25
perf script
root@login:/home/vagrant# perf script
# ========
# captured on: Tue Nov 24 10:13:31 2015
# hostname : login
# os release : 3.13.0-57-generic
# perf version : 3.13.11-ckt21
# arch : x86_64
# nrcpus online : 4
# nrcpus avail : 4
# cpudesc : Intel(R) Core(TM) i7-4558U CPU @ 2.80GHz