Skip to content

Instantly share code, notes, and snippets.

View wshirey's full-sized avatar

Wally S wshirey

  • Shipt
View GitHub Profile
@lancscoder
lancscoder / Connection.cs
Created February 14, 2012 19:28
Dapper Getting Started
public class ConnectionFactory {
public static DbConnection GetOpenConnection() {
var connection = new SqlConnection("MyConnectionString");
connection.Open();
return connection;
}
}
@phette23
phette23 / current-dir-in-iterm-tab-title.sh
Last active January 4, 2024 10:20
Set the iTerm tab title to the current directory, not full path.
# put this in your .bash_profile
if [ $ITERM_SESSION_ID ]; then
export PROMPT_COMMAND='echo -ne "\033];${PWD##*/}\007"; ':"$PROMPT_COMMAND";
fi
# Piece-by-Piece Explanation:
# the if condition makes sure we only screw with $PROMPT_COMMAND if we're in an iTerm environment
# iTerm happens to give each session a unique $ITERM_SESSION_ID we can use, $ITERM_PROFILE is an option too
# the $PROMPT_COMMAND environment variable is executed every time a command is run
# see: ss64.com/bash/syntax-prompt.html
@pglombardo
pglombardo / gist:7630100
Last active May 24, 2022 19:14
How to open your private Github repository and still keep a couple things under wrap

We're happy to say that we recently released the code for the TraceView Ruby instrumentation on Github as Open Source. There are a ton of benefits for AppNeta (and the community) in doing this so making the decision was easy... but the process of actually opening the repository and still keeping a few things private was slightly trickier. Here's the route we took that has worked out really well.

The Situation and Strategy

The Ruby instrumentation has always been sheltered on Github - albeit always in a private Github repository. We used the issues, pull requests and wiki pages extensively for everything from new employee resources to hosting screenshots, customer issues, internal discussions and links to other project and management tools (e.g. Asana).

Outside of the commits and the code, everything else was either of little use to the public or potentially company or customer confidential - stuff that shouldn't or couldn't be shared publicly. So this put us

@dieseltravis
dieseltravis / CryptoHelper.cs
Last active October 31, 2023 07:26
sample app that uses PGP Encryption using Bouncy Castle's C# API
// Assembly BouncyCastle.Crypto, Version=1.8.1.0
using Org.BouncyCastle.Bcpg;
using Org.BouncyCastle.Bcpg.OpenPgp;
using Org.BouncyCastle.Security;
using System;
using System.IO;
using System.Text;
namespace EncryptionSample
{
@kevin-smets
kevin-smets / iterm2-solarized.md
Last active June 1, 2024 14:20
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k

@deandob
deandob / gist:8943268
Created February 11, 2014 20:19
Streaming MP4 to HTML5 clients
--------------- FFMPEG command line
ffmpeg = child_process.spawn("ffmpeg", [
"-i", rtsp , "-vcodec", "copy", "-f", "mp4", "-f", "segment", "-segment_time", recSeg, "-segment_wrap", 2, "-map", "0", "-segment_format", "mp4", "-reset_timestamps", "1", "-y", "plugins/security/videos/" + camName + "/rec-%01d.mp4"
], {detached: false});
---------------- Node.JS streamer
// Stream mp4 video file based on URL request from client player. Accept request for partial streams
// Code attribution: https://github.com/meloncholy/vid-streamer/blob/master/index.js (MIT license)
var recStream = function (req, resp) {
var stream;
@thejuan
thejuan / IIS Logstash Grok
Created February 21, 2014 18:16
A Logstash Grok filter for IIS (W3C default fields + bytes sent)
filter{
grok {
match => ["message", "%{TIMESTAMP_ISO8601:log_timestamp} %{WORD:iisSite} %{IPORHOST:site} %{WORD:method} %{URIPATH:page} %{NOTSPACE:querystring} %{NUMBER:port} %{NOTSPACE:username} %{IPORHOST:clienthost} %{NOTSPACE:useragent} %{NOTSPACE:referer} %{NUMBER:response} %{NUMBER:subresponse} %{NUMBER:scstatus} %{NUMBER:bytes:int} %{NUMBER:timetaken:int}"]
}
}
@deandob
deandob / livestream
Created February 26, 2014 22:31
Node.JS function to remux mp4/h.264 video from an IP camera to a HTML5 video tag using FFMPEG
// Live video stream management for HTML5 video. Uses FFMPEG to connect to H.264 camera stream,
// Camera stream is remuxed to a MP4 stream for HTML5 video compatibility and segments are recorded for later playback
var liveStream = function (req, resp) { // handle each client request by instantiating a new FFMPEG instance
// For live streaming, create a fragmented MP4 file with empty moov (no seeking possible).
var reqUrl = url.parse(req.url, true)
var cameraName = typeof reqUrl.pathname === "string" ? reqUrl.pathname.substring(1) : undefined;
if (cameraName) {
try {
cameraName = decodeURIComponent(cameraName);
@staltz
staltz / introrx.md
Last active June 3, 2024 11:21
The introduction to Reactive Programming you've been missing

##Self-hosted HTTP service in C# with Nancy and TopShelf

I found myself in need of a standalone, self-hosted HTTP Service for a REST-backend at work the other day. I like my services to be flexible and easy to deploy with a low footprint. Here's the catch: At work we write in .Net and I truly hate IIS. I kinda like C#, but I don't want my webservices to be tightly locked onto the platform-specific overhead hell that is IIS. Thanks to OWIN, Nancy and TopShelf it easy to write a self-hosted HTTP service (Ruby or Node.js style!) in C# and have it run as a standalone application or as a Windows Service. Here is a super duper easy example using Nancys Self-Host and TopShelf.

###The Code First of all we need som packages from NuGet:

	Install-Package Nancy.Hosting.Self 

Install-Package Topshelf