Skip to content

Instantly share code, notes, and snippets.

@koenmetsu
koenmetsu / .bashrc
Last active August 29, 2015 14:21
Bash function: Gitlab replace https with ssh protocol
# Usage:
# fetch git fetch https://git/someuser/somerepo.git somebranch
# will execute instead:
# git fetch git@git:someuser/somerepo.git somebranch
function fetch() {
local old_url="$*"
new_url=$(sed 's#https://git/#git@git:#g' <<< $old_url)
$new_url | sh
}
@koenmetsu
koenmetsu / deploy.fsx
Last active August 29, 2015 14:21
FAKE deploy
// include Fake lib
#r @"FAKE/tools/FakeLib.dll"
open Fake
open System
open System.IO
// param names
let sourceEnvParam = "sourceEnv"
let destinationDirParam = "destinationDir"
namespace Muffin.Pictures.Archiver
open System
module Picture =
type IsOldDefinition = DateTimeOffset -> bool
type TimeTakenRetriever = string -> DateTimeOffset
type PathExistenceChecker = string -> bool
@koenmetsu
koenmetsu / oneargument.fsi
Last active August 29, 2015 14:23
Functional Calisthenics
// multiple param function
let multiply x y =
x * y
// reducing to 1 arg function calls
let multiplyBy2 = multiply 2
let result = multiplyBy2 4
@koenmetsu
koenmetsu / drivewatcher.ps1
Created July 24, 2015 10:41
Ps file to automatically detect usb disk being inserted, calls bat to load vhd and tries to run a script on the newly loaded virtual disk.
#Requires -version 2.0
Register-WmiEvent -Class win32_VolumeChangeEvent -SourceIdentifier volumeChange
write-host (get-date -format s) " Beginning script..."
$DrivesCount = (gwmi -Query "Select * from Win32_LogicalDisk").Count
$Drives = (gwmi -Query "Select * from Win32_LogicalDisk")
do{
$newEvent = Wait-Event -SourceIdentifier volumeChange
$eventType = $newEvent.SourceEventArgs.NewEvent.EventType
$eventTypeName = switch($eventType)
@koenmetsu
koenmetsu / .apmrc
Created July 31, 2015 13:13
Atom apmrc with authenticated proxy
; watch out this is unencrypted!
proxy=http://username:password@proxyurl:proxyport
https-proxy=http://username:password@proxyurl:proxyport
strict-ssl=false
function Update-AppSettings($resourceGroup, $site, $slot, $inputFile)
{
$webApp = Get-AzureRMWebAppSlot -ResourceGroupName $resourceGroup -Name $site -Slot $slot
$appSettingList = $webApp.SiteConfig.AppSettings
$hash = @{}
ForEach ($kvp in $appSettingList) {
$hash[$kvp.Name] = $kvp.Value
}
@koenmetsu
koenmetsu / .bashrc
Created March 7, 2017 10:47
.bashrc script with some git options enabled
env=~/.ssh/agent.env
agent_load_env () { test -f "$env" && . "$env" >| /dev/null ; }
agent_start () {
(umask 077; ssh-agent >| "$env")
. "$env" >| /dev/null ; }
agent_load_env
@koenmetsu
koenmetsu / start_docker_registry.bash
Created October 19, 2017 20:03 — forked from PieterScheffers/start_docker_registry.bash
Start docker registry with letsencrypt certificates (Linux Ubuntu)
#!/usr/bin/env bash
# install docker
# https://docs.docker.com/engine/installation/linux/ubuntulinux/
# install docker-compose
# https://docs.docker.com/compose/install/
# install letsencrypt
# https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-16-04
@koenmetsu
koenmetsu / mass-aggregation-change.sh
Created October 20, 2017 08:34 — forked from kirbysayshi/mass-aggregation-change.sh
quick examples of how to change many many wsp (graphite/whisper) files settings
for f in $(find $1 -iname "*.wsp"); do
if [ -a $f ];
then /opt/graphite/bin/whisper-set-aggregation-method.py $f max;
fi;
done