Skip to content

Instantly share code, notes, and snippets.

@rbialek
rbialek / config
Created June 7, 2011 13:32
ssh/.config
Host github.com
User git
Hostname github.com
PreferredAuthentications publickey
IdentityFile /home/user/.ssh/id_rsa
@crazyfool2100
crazyfool2100 / Host Add-In
Created September 7, 2011 05:34
A host ExcelDna add-in loading and unloading another add-in
<DnaLibrary Name="Host Add-In" Language="CS" RuntimeVersion="v4.0">
<Reference AssemblyPath="System.Windows.Forms.dll"/>
<Reference Name="Microsoft.Office.Interop.Excel" />
<![CDATA[
using System;
using ExcelDna.Integration;
using System.Windows.Forms;
using Excel = Microsoft.Office.Interop.Excel;
public class HostAddIn: IExcelAddIn
@mxpv
mxpv / ProcessUtil.cs
Created September 28, 2012 09:31
Process start helper utility with CancellationToken and async output reading support
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Threading;
using Microsoft.Win32.SafeHandles;
namespace ConsoleApplication
{
public class ProcessUtil : IDisposable
{
@jrusbatch
jrusbatch / AvailablePorts.cs
Created December 5, 2012 02:17
Find an Available Port with C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.NetworkInformation;
using System.Net;
namespace AvailablePort
{
class Program
# taken from http://www.piware.de/2011/01/creating-an-https-server-in-python/
# generate server.xml with the following command:
# openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes
# run as follows:
# python simple-https-server.py
# then in your browser, visit:
# https://localhost:4443
import BaseHTTPServer, SimpleHTTPServer
import ssl
@alexland
alexland / serialize-numpy-array.py
Last active November 28, 2023 07:12
serialize, persist, retrieve, and de-serialize a NumPy array as a binary string (any dimension, any dtype); exemplary use case: a web app calculates some result--eg, from a Machine Learning algorithm, using NumPy and the result is a NumPy array; it is efficient to just return that result to rather than persist the array then retrieve it via query
import time
import numpy as NP
from redis import StrictRedis as redis
# a 2D array to serialize
A = 10 * NP.random.randn(10000).reshape(1000, 10)
# flatten the 2D NumPy array and save it as a binary string
array_dtype = str(A.dtype)
@AndrianBdn
AndrianBdn / git-sparse-clone.sh
Last active May 4, 2022 23:06
git-sparse-clone.sh
#!/bin/sh
#
# This script can clone/checkout a single folder from git repository
# - Might be used for checking out micro-services from monolithic git repository
#
# - You can even do checkout into home directory, for example
# git-sparse-clone.sh [email protected]:readdle/fluix-web.git /home/login login
#
# This will cause the shell to exit immediately if a simple command exits with a nonzero exit value.
@gluck
gluck / FromEventBenchmark.cs
Last active October 15, 2021 09:03
Benchmark showing performance increase using FromEvent with conversion over FromEventPattern, using BenchmarkDotNet library
[BenchmarkTask(platform: BenchmarkPlatform.X86, jitVersion: BenchmarkJitVersion.LegacyJit)]
[BenchmarkTask(platform: BenchmarkPlatform.X64, jitVersion: BenchmarkJitVersion.LegacyJit)]
[BenchmarkTask(platform: BenchmarkPlatform.X64, jitVersion: BenchmarkJitVersion.RyuJit)]
public class FromEventBenchmark
{
readonly Control control = new Control();
[Benchmark]
public void FromEventPattern()
{
Observable.FromEventPattern<EventHandler, EventArgs>(h => control.SizeChanged += h, h => control.SizeChanged -= h).Select(p => p.EventArgs)
@martinrusev
martinrusev / piping.go
Created October 1, 2015 08:09 — forked from kylelemons/piping.go
piping exec.Cmd in golang (example sorts all regular files under a directory by their extension)
package main
import (
"bytes"
"exec"
"log"
"os"
)
// Pipeline strings together the given exec.Cmd commands in a similar fashion
@datakurre
datakurre / connection.py
Last active September 22, 2023 11:13
Python 3.5 async / await example with HTTP-AMQP -bridge and Nix based development environment
# -*- coding: utf-8 -*-
import aioamqp
connection = None
protocol = None
async def disconnected(exception):
global connection, protocol