Skip to content

Instantly share code, notes, and snippets.

@Misterhex
Misterhex / happy_git_on_osx.md
Created November 20, 2017 01:34 — forked from trey/happy_git_on_osx.md
Creating a Happy Git Environment on OS X

Creating a Happy Git Environment on OS X

Step 1: Install Git

brew install git bash-completion

Configure things:

git config --global user.name "Your Name"

git config --global user.email "you@example.com"

@Misterhex
Misterhex / docker-images-remove
Created June 2, 2017 03:45
remove all docker images and containers
# Delete every Docker containers
# Must be run first because images are attached to containers
docker rm -f $(docker ps -a -q)
# Delete every Docker image
docker rmi -f $(docker images -q)
@Misterhex
Misterhex / run_netstat.ps1
Created May 8, 2017 08:37
netstat and write to file every minute
for(;;) {
try {
echo "=====================================================================" | Out-File netstat_result.txt -Append
Get-Date | Out-File netstat_result.txt -Append
$netstatResult = netstat -ano
$netstatResult | Out-File netstat_result.txt -Append
$netstatResult | Measure-Object -Line | Out-File netstat_result.txt -Append
}
catch {
@Misterhex
Misterhex / newrelicrepair.ps1
Created April 28, 2017 06:22
Repair newrelic on windows
$HKLM = 2147483650 #HKEY_LOCAL_MACHINE
$reg = [wmiclass]"\\.\root\default:StdRegprov"
$key = "SYSTEM\CurrentControlSet\Services\W3SVC"
$name = "Environment"
$value = "COR_ENABLE_PROFILING=1","COR_PROFILER={71DA0A04-7777-4EC6-9643-7D28B46A8A41}","NEWRELIC_INSTALL_PATH=C:\Program Files\New Relic\.NET Agent\"
$reg.SetMultiStringValue($HKLM, $key, $name, $value)
$key = "SYSTEM\CurrentControlSet\Services\WAS"
$name = "Environment"
@Misterhex
Misterhex / ObservableExtensions.cs
Last active February 17, 2019 19:13
Rx extensions from reactive trader
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq.Expressions;
using System.Reactive;
using System.Reactive.Concurrency;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Reactive.Subjects;
using System.Threading;
@Misterhex
Misterhex / AcquireSessionLockAttribute.cs
Created February 8, 2017 08:12
default readonly session locking and acquiresessionlockattribute on controller action.
[AttributeUsage(AttributeTargets.Method)]
public sealed class AcquireSessionLockAttribute : Attribute
{ }
@Misterhex
Misterhex / gist:b557fb1526fab6d185a7a919a30d8f05
Last active November 29, 2020 08:52
goproxy with custom outgoing ip
package main
import (
"github.com/elazarl/goproxy"
"log"
"net"
"net/http"
)
func main() {
@Misterhex
Misterhex / GetThreadPoolStats
Last active July 4, 2016 15:26
printing the thread pool stats (extracted from stackexchange.redis)
public static int GetThreadPoolStats(out string iocp, out string worker)
{
int maxIoThreads, maxWorkerThreads;
ThreadPool.GetMaxThreads(out maxWorkerThreads, out maxIoThreads);
int freeIoThreads, freeWorkerThreads;
ThreadPool.GetAvailableThreads(out freeWorkerThreads, out freeIoThreads);
int minIoThreads, minWorkerThreads;
ThreadPool.GetMinThreads(out minWorkerThreads, out minIoThreads);
public static class ObservableExtensions
{
public static IObservable<GuidTimestamped<T>> GuidTimestamped<T>(this IObservable<T> source)
{
return Observable.Select(source, i => new GuidTimestamped<T>(i, Guid.NewGuid(), DateTimeOffset.UtcNow));
}
public static IObservable<GuidTimestamped<TResult>> Select<T, TResult>(this IObservable<GuidTimestamped<T>> source, Func<T, TResult> selectFunc)
{
return Observable.Select(source, i => new GuidTimestamped<TResult>(selectFunc(i.Value), i.InstanceId, i.Timestamp));
set nocp
execute pathogen#infect()
syntax on
filetype plugin indent on
set backspace=2
set number