Skip to content

Instantly share code, notes, and snippets.

View cdarne's full-sized avatar
🏠
Working from home

Cédric Darne cdarne

🏠
Working from home
View GitHub Profile
@enricofoltran
enricofoltran / main.go
Last active April 1, 2024 00:17
A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
package main
import (
"context"
"flag"
"fmt"
"log"
"net/http"
"os"
"os/signal"
@kachayev
kachayev / concurrency-in-go.md
Last active March 11, 2024 11:27
Channels Are Not Enough or Why Pipelining Is Not That Easy
# 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"
# edit all commit messages
git rebase -i --root
# clone all your repos with gh cli tool
gh repo list --json name -q '.[].name' | xargs -n1 gh repo clone
@chorrell
chorrell / add-node.sh
Created May 29, 2012 14:02
Add new version of nodejs to a nodejs or no.de SmartMachine
#!/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 }
@tomash
tomash / metal.rb
Created October 21, 2010 13:28
Metal Lorem Ipsum preview
# 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(" "))