Skip to content

Instantly share code, notes, and snippets.

View pizycki's full-sized avatar

Paweł Iżycki pizycki

View GitHub Profile
@pizycki
pizycki / Install-Spotify.ps1
Last active February 4, 2019 11:28
Spotify install script
iex ((New-Object System.Net.WebClient).DownloadString("https://gist.githubusercontent.com/pizycki/949a0b2dde34bdb7bcb71c0226d3f107/raw/SpotifyInstall.ps1"))
@pizycki
pizycki / Main.cs
Created March 13, 2019 21:31
MSDI alternative for Autofac service resolving with parameter
using System;
using Microsoft.Extensions.DependencyInjection;
using Xunit;
namespace InjectDependencyWithProperty.src
{
public class UsersStorage
{
public void Create(object user)
{
@pizycki
pizycki / Program.fs
Last active March 27, 2019 18:03
NanoWebServer.fs
open Suave
open Argu
type Args =
| [<EqualsAssignment>] IP of host:string
| [<EqualsAssignment>] Port of port:int
with
interface IArgParserTemplate with
member s.Usage =
match s with
@pizycki
pizycki / ProcessRunner.cs
Created April 10, 2019 08:06
Helper class for runnsing new processes
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using CSharpFunctionalExtensions;
namespace Common
{
public class ProcessRunner
{
private const int PROCESS_TIMEOUT = 1000 * 60; // ms
@pizycki
pizycki / DivideResult.cs
Created April 10, 2019 08:54
Discriminated Union in C#
// Discriminated Union
public abstract class DivideResult
{
public class Success : DivideResult
{
public double Value { get; }
private Success(double value)
{
@pizycki
pizycki / ghost_index.js
Created May 5, 2019 18:19 — forked from troykelly/ghost_index.js
Adding HSTS to Ghost Blog
// # Ghost Startup
// Orchestrates the startup of Ghost when run from command line.
var ghost = require('./core'),
express = require('express'),
errors = require('./core/server/errors'),
parentApp = express(),
hsts = require('hsts'),
express_enforces_ssl = require('express-enforces-ssl');
@pizycki
pizycki / QuickStart.fs
Created June 29, 2019 15:15
MySQL, Dapper and F#
// Place this in .fsproj
// <ItemGroup>
// <PackageReference Include="Dapper.Contrib" Version="1.60.1" />
// <PackageReference Include="MySqlConnector" Version="0.56.0" />
// </ItemGroup>
open Dapper
open MySql.Data.MySqlClient
// CREATE TABLE `8833_rw_dev`.`Releases` (
@pizycki
pizycki / ActivePattern.fsx
Last active July 18, 2019 19:55
Unwrap value from DU in F#
// Based on https://stackoverflow.com/a/24293478/864968
@pizycki
pizycki / Client.cs
Last active November 20, 2024 09:19
RabbitMQ RPC Direct Reply-To in C#
using System;
using System.Collections.Concurrent;
using System.Text;
using RabbitMQ.Client;
using RabbitMQ.Client.Events;
namespace Client
{
public class RpcClient
{
@pizycki
pizycki / Get-StaleBranches.ps1
Created September 6, 2019 16:56
Get old branches
param (
[Parameter(Mandatory = $true)] $RepositoryPath,
[Parameter(Mandatory = $true)] $Days
)
function Get-BranchesInRepository([string]$path){
Push-Location
try {
Set-Location $path
$branches = git for-each-ref --sort='-committerdate:iso8601' --format='%(committerdate:iso8601)|%(refname:short)|%(committeremail)|%(committername)' refs/remotes/