Skip to content

Instantly share code, notes, and snippets.

@disco0
disco0 / xclip
Last active June 22, 2023 05:46
xclip-wsl - Windows clipboard xclip for WSL distributions.
#!/usr/bin/env zsh
###
### xclip(-wsl)
###
### Drop in xclip substitute for interacting with the Windows clipboard from
### WSL environment. Attempts to resolve various Windows clipboard interfaces
### on $PATH in order of performance, falling back to powershell executables'
### Get-Clipboard and Set-Clipboard (with priority to pwsh.exe)—
###
@jdh30
jdh30 / upload.sh
Last active May 17, 2021 21:51
Upload files from this machine to another without clobbering.
# Upload files from this machine to another without clobbering.
# Usage:
# ./upload.sh <srcdir> <user@host> <dstdir>
tar -cz $1 | ssh $2 "tar -kzxf - -C ${3}"
@adrianord
adrianord / .dockerignore
Last active September 14, 2021 23:53
Generic DotNet Dockerfile using BuildKit `RUN --mount` directive to keep csproj structure.
# This is an example of what you might have in your .dockerignore. Some items can be omitted like `!/test/**` or added
# like `**/node_modules` if you have a node/frontend project.
*
!/*.sln
!/nuget.config
!/src/**
**/bin
**/obj
@jdhitsolutions
jdhitsolutions / Get-GitConfig.ps1
Created February 1, 2019 16:51
A PowerShell function to get your git configuration. See comment based help for usage examples.
#requires -version 5.1
Function Get-GitConfig {
<#
.SYNOPSIS
Get git configuration settings
.DESCRIPTION
Git stores configurations settings in a simple text file format. Fortunately, this file is structured and predictable. This command will process git configuration information into PowerShell friendly output.
.PARAMETER Scope
@jdh30
jdh30 / JsonParser.fs
Last active January 30, 2024 14:06
Simple JSON parser written in F# using active patterns
type Json =
| Null
| Bool of bool
| Number of float
| String of string
| Array of Json list
| Object of (string * Json) list
type Bracket = Open | Close
@enerqi
enerqi / fsharp-fable-tips.md
Last active May 23, 2024 16:56
Fable F# Notes

Basic Tooling Setup

Fable is an F# language to javascript compiler powered by Babel.

F# is a language that runs on a Microsoft CLR. Using the .NET Core CLR implementation it works on Windows, Mac or Linux.

F# Linux

  • .NET Core SDK - download the latest 2.1 SDK
  • Mono - mono-complete package
  • F# compiler - fsharp package from the mono repository
@Jaykul
Jaykul / ValidateUnique.md
Last active May 7, 2022 01:13
Validating PowerShell class properties

The simplest way to enforce rules on PowerShell class properties is to set the Type of the property, of course. But sometimes you want something a little bit more clever than that. One solution is to use a Validate* attribute, like ValidateRange or ValidateLength or ValidateSet attribute...

However, you can write your own, by just deriving from ValidateArguments() or something that derives from that, like the ValidateEnumeratedArguments class allows you to validate a whole array of items.

For instance, a simple validator would be one that validates uniqueness, based on a specific property. Our validator will be created fresh each time it's used, and then each item in the array will be passed through ValidateElement, so this works:

using namespace System.Collections.Generic
usin
@nottrobin
nottrobin / github-api-create-pull-request-end-to-end.py
Created September 6, 2016 14:30
With Github API v3, create branch, commit a change to a file and open a pull request
#! /usr/bin/env python
from base64 import b64decode
from github import Github
with open('access-token.txt') as token_file:
token = token_file.read().strip()
api = Github(token)
site = api.get_repo('nottrobin/gh-cms-example-site')
@steinwaywhw
steinwaywhw / One Liner to Download the Latest Release from Github Repo.md
Last active July 18, 2024 16:51
One Liner to Download the Latest Release from Github Repo
  • Use curl to get the JSON response for the latest release
  • Use grep to find the line containing file URL
  • Use cut and tr to extract the URL
  • Use wget to download it
curl -s https://api.github.com/repos/jgm/pandoc/releases/latest \
| grep "browser_download_url.*deb" \
| cut -d : -f 2,3 \
| tr -d \" \
@trusktr
trusktr / DefaultKeyBinding.dict
Last active July 17, 2024 05:21
My DefaultKeyBinding.dict for Mac OS X
/* ~/Library/KeyBindings/DefaultKeyBinding.Dict
This file remaps the key bindings of a single user on Mac OS X 10.5 to more
closely match default behavior on Windows systems. This makes the Command key
behave like Windows Control key. To use Control instead of Command, either swap
Control and Command in Apple->System Preferences->Keyboard->Modifier Keys...
or replace @ with ^ in this file.
Here is a rough cheatsheet for syntax.
Key Modifiers