... or Why Pipelining Is Not That Easy
Golang Concurrency Patterns for brave and smart.
By @kachayev
| package main | |
| import ( | |
| "context" | |
| "flag" | |
| "fmt" | |
| "log" | |
| "net/http" | |
| "os" | |
| "os/signal" |
... or Why Pipelining Is Not That Easy
Golang Concurrency Patterns for brave and smart.
By @kachayev
| # alias to edit commit messages without using rebase interactive | |
| # example: git reword commithash message | |
| reword = "!f() {\n GIT_SEQUENCE_EDITOR=\"sed -i 1s/^pick/reword/\" GIT_EDITOR=\"printf \\\"%s\\n\\\" \\\"$2\\\" >\" git rebase -i \"$1^\";\n git push -f;\n}; f" | |
| # completely wipe git history | |
| wipe-history = "!f() { git add . && git reset --soft $(git rev-list --max-parents=0 HEAD) && git commit --amend -m \"${1:-sup}\" && git push --force; }; f" | |
| # squash the last N commits | |
| squash = "!f(){ git reset --soft HEAD~${1} && git commit --edit -m\"$(git log --format=%B --reverse HEAD..HEAD@{1})\"; };f" |
| #!/usr/bin/env bash | |
| # | |
| # Add new version of nodejs to a nodejs or no.de SmartMachine | |
| # | |
| # Check to see if script is being run as the root user | |
| if [[ $EUID -ne 0 ]]; then | |
| echo "This script must be run as root. Aborting..." 1>&2 | |
| exit 1 |
| require 'date' | |
| require 'benchmark' | |
| puts "patchlevel: #{RUBY_PATCHLEVEL}, release_date: #{RUBY_RELEASE_DATE}, ruby_version: #{RUBY_VERSION}, ruby_platform: #{RUBY_PLATFORM}" | |
| puts '*'*80 | |
| Benchmark.bm(10) do |bm| | |
| bm.report("Date.today") do | |
| 500_000.times { Date.today } |
| # Returns a randomly generated sentence of lorem ipsum text. | |
| # The first word is capitalized, and the sentence ends in either a period or | |
| # question mark. Commas are added at random. | |
| def sentence | |
| # Determine the number of comma-separated sections and number of words in | |
| # each section for this sentence. | |
| sections = [] | |
| 1.upto(rand(5)+1) do | |
| sections << (WORDS.sort_by{rand}.slice(0...(rand(9)+3)).join(" ")) |