Skip to content

Instantly share code, notes, and snippets.

@allex
allex / ReadSTDIN.go
Created January 19, 2021 03:54 — forked from AlexMocioi/ReadSTDIN.go
Read big text data from SDIN in Go
package main
import "fmt"
import "bufio"
import "os"
func main() {
f, _ := os.Create("outputgo.txt")
reader := bufio.NewReader(os.Stdin)
for {
line, err := reader.ReadString('\n')
@allex
allex / gcpl.sh
Created August 14, 2020 04:34 — forked from nickboldt/gcpl.sh
git cherry pick latest (or multiple latest) commits
#!/bin/bash
#
#script to make it easier to git cherry-pick the latest commit to another branch
numCommits=1 # but we can cherry-pick more than one if needs be
red="\033[1;31m"
norm="\033[0;39m"
grey="\033[0;37m"
green="\033[0;32m"
@allex
allex / docker-machine-rename
Created April 26, 2020 07:45 — forked from alexproca/docker-machine-rename
Rename docker-machine
#!/usr/bin/env bash
#copy this in a folder from path ex: /usr/local/bin
#usage: docker-machine-rename default my-default
# Authors
#
# alexproca initial script
# eurythmia sed magic
@allex
allex / git-quote-string-multiline
Created March 6, 2020 10:26 — forked from HaleTom/git-quote-string-multiline
Quote a single- or multi-line string for use in git's aliases
#!/bin/bash -eu
# Quote a single- or multi-line string for use in git's aliases
# Copyright (c) 2016 Tom Hale under https://en.wikipedia.org/wiki/MIT_License
quote() {
printf %s "$1" | sed -r 's/(["\\])/\\\1/g';
}
IFS=$(printf '\n')
@allex
allex / json.lua
Created February 11, 2020 09:18 — forked from tylerneylon/json.lua
Pure Lua json library.
--[[ json.lua
A compact pure-Lua JSON library.
The main functions are: json.stringify, json.parse.
## json.stringify:
This expects the following to be true of any tables being encoded:
* They only have string or number keys. Number keys must be represented as
strings in json; this is part of the json spec.
@allex
allex / post-checkout
Created January 7, 2020 11:23 — forked from betorobson/post-checkout
git hook to run a command after `git pull` and `git checkout` if a specified file was change for example, package.json or bower.json
#!/usr/bin/env bash
# fork from https://gist.github.com/jakemhiller/d342ad51505addf78ec628a16fd3280f
changed_files="$(git diff-tree -r --name-only --no-commit-id $1 $2)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
}
check_run package.json "npm prune && npm install"
@allex
allex / README.md
Created March 11, 2019 05:20 — forked from marz619/README.md
Go build LDFlags

Using the -ldflags parameter can help set variable values at compile time.

Using the example provided here:

  1. Running make build will create a build executable. Running it will result in:
$> ./build
no version (Mon YYYY)
$>
/**
* Simple node.js style script loader for modern browsers
**/
function loadScript(src, cb) {
var script = document.createElement('script');
script.async = true;
script.src = src;
script.onerror = function() {
cb(new Error("Failed to load" + src));
#####################################################################
## ALIASES
#####################################################################
[alias]
#################################################
## Simple / Short Aliases
#################################################
@allex
allex / jenkins-git-backup.sh
Created January 15, 2019 10:40 — forked from abayer/jenkins-git-backup.sh
Example of a script for backing up Jenkins config in git.
#!/bin/bash
#
# Copies certain kinds of known files and directories from a given Jenkins master directory
# into a git repo, removing any old ones, adds 'em, commits 'em, pushes 'em.
#
set -ex
if [ $# -ne 2 ]; then
echo usage: $0 root_dir jenkins_master