Skip to content

Instantly share code, notes, and snippets.

View patroza's full-sized avatar

Patrick Roza patroza

View GitHub Profile
import * as O from 'fp-ts/Option'
import * as IO from 'fp-ts/IO'
import * as T from 'fp-ts/Task'
import * as A from 'fp-ts/Array'
import { HKT, Kind, URIS } from 'fp-ts/HKT'
import { Monad, Monad1 } from 'fp-ts/Monad'
import { pipe } from 'fp-ts/function'
const _: any = function* (x: any): any {
return yield x
@darrenpmeyer
darrenpmeyer / README.md
Created November 20, 2020 19:35
Automatically start a single instance of ssh-agent for all terminal sessions to share (bash)

Installation

  1. mkdir -p ~/.config && touch ~/.config/ssh-agent.pid
  2. Paste the contents of ssh-agent-manage.sh into your .bashrc or .bash_profile or similar
  3. killall -9 ssh-agent
  4. Start a new terminal session (note: old sessions will not see ssh-agent, only new ones)

Details

This snippet, when included in .bashrc, will ensure that your session has a working ssh-agent with all your ssh keys loaded into it. It does this without creating separate ssh-agent processes by:

@FradSer
FradSer / iterm2_switch_automatic.md
Last active April 23, 2024 02:40
Switch iTerm2 color preset automatic base on macOS dark mode.

The latest beta (3.5) includes separate color settings for light & dark mode. Toggling dark mode automatically switches colors.

Vist iTerm2 homepage or use brew install iterm2-beta to download the beta. Thanks @stefanwascoding.


  1. Add switch_automatic.py to ~/Library/ApplicationSupport/iTerm2/Scripts/AutoLaunch with:
import { right, either, left } from 'fp-ts/lib/Either'
import { HKTAs, HKT2As, HKT2, HKTS, HKT, HKT2S } from 'fp-ts/lib/HKT'
import { Monad } from 'fp-ts/lib/Monad'
import { option, some } from 'fp-ts/lib/Option'
function Do<M extends HKT2S>(m: Monad<M>): <L, A>(generator: () => Iterator<HKT2<M, L, A>>) => HKT2As<M, L, A>
function Do<M extends HKTS>(m: Monad<M>): <A>(generator: () => Iterator<HKT<M, A>>) => HKTAs<M, A>
function Do<M extends HKTS>(m: Monad<M>): <A>(generator: () => Iterator<HKT<M, A>>) => HKT<M, A> {
return <A>(generator: () => Iterator<HKT<M, A>>): HKT<M, A> => {
const iterator = generator()
@yxy
yxy / two-railway-programing-in-python.py
Last active September 16, 2021 17:03
Railway Oriented Programming in python. inspired by https://fsharpforfunandprofit.com/rop/
class Success(object):
def __init__(self, value):
self.value = value
class Error(object):
def __init__(self, value):
self.value = value
class wrapper(object):
def __init__(self, result):
@enricosada
enricosada / fsharp and .net core sdk status.md
Last active March 29, 2020 13:13
.NET Core sdk, msbuild, fsharp, fsc, etc

.NET Core sdk, msbuild, fsharp, fsc, etc

How to finish/polish the integration between msbuild based .net core sdk and f# (fsc, FscTask, etc)

This doc contains current issues i known and a proposed solution (already implemented in a PR, and works) on how to fix these (obv ihmo).

AFAIK all the solution i choose are based on where dotnet/sdk, microsoft/msbuild and dotnet/cli are going with development, and updated to latest release (preview4), and vnext in development now.

TL;DR

using System;
using System.IO;
using System.IO.Compression;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
namespace Middlewares
{
/// <summary>
/// Experimental compression middleware for self-hosted web app
@OlegIlyenko
OlegIlyenko / Event-stream based GraphQL subscriptions.md
Last active February 24, 2024 04:41
Event-stream based GraphQL subscriptions for real-time updates

In this gist I would like to describe an idea for GraphQL subscriptions. It was inspired by conversations about subscriptions in the GraphQL slack channel and different GH issues, like #89 and #411.

Conceptual Model

At the moment GraphQL allows 2 types of queries:

  • query
  • mutation

Reference implementation also adds the third type: subscription. It does not have any semantics yet, so here I would like to propose one possible semantics interpretation and the reasoning behind it.

@ejdyksen
ejdyksen / patch-edid.md
Last active April 6, 2024 15:59
A script to fix EDID problems on external monitors in macOS

patch-edid.rb

A script to fix EDID problems on external monitors in macOS.

Instructions

  1. Connect only the problem display.

  2. Create this directory structure (if it doesn't already exist):