Skip to content

Instantly share code, notes, and snippets.

View sbusso's full-sized avatar
🤖
Crafting with AI friends

Stéphane Busso sbusso

🤖
Crafting with AI friends
View GitHub Profile
@sbusso
sbusso / unixhttpc.go
Created September 24, 2018 11:23 — forked from teknoraver/unixhttpc.go
HTTP over Unix domain sockets in golang
package main
import (
"context"
"flag"
"fmt"
"io"
"net"
"net/http"
"os"
@sbusso
sbusso / macapp.go
Created September 23, 2018 17:18 — forked from mholt/macapp.go
Distribute your Go program (or any single binary) as a native macOS application
// Package main is a sample macOS-app-bundling program to demonstrate how to
// automate the process described in this tutorial:
//
// https://medium.com/@mattholt/packaging-a-go-application-for-macos-f7084b00f6b5
//
// Bundling the .app is the first thing it does, and creating the DMG is the
// second. Making the DMG is optional, and is only done if you provide
// the template DMG file, which you have to create beforehand.
//
// Example use:
@sbusso
sbusso / GoConcurrency.md
Created September 7, 2018 12:24 — forked from rushilgupta/GoConcurrency.md
Concurrency in golang and a mini Load-balancer

INTRO

Concurrency is a domain I have wanted to explore for a long time because the locks and the race conditions have always intimidated me. I recall somebody suggesting concurrency patterns in golang because they said "you share the data and not the variables".

Amused by that, I searched for "concurrency in golang" and bumped into this awesome slide by Rob Pike: https://talks.golang.org/2012/waza.slide#1 which does a great job of explaining channels, concurrency patterns and a mini-architecture of load-balancer (also explains the above one-liner).

Let's dig in:

Goroutines

MicroService Proxy Gateway Solutions

Kong, Traefik, Caddy, Linkerd, Fabio, Vulcand, and Netflix Zuul seem to be the most common in microservice proxy/gateway solutions. Kubernetes Ingress is often a simple Ngnix, which is difficult to separate the popularity from other things.

Github Star Trend:

Github Star History for Kong vs traefik vs fabio vs caddy vs Zuul

This is just a picture of this link from Feb

@sbusso
sbusso / rails-jsonb-queries
Created August 5, 2018 18:19 — forked from mankind/rails-jsonb-queries
Rails-5 postgresql-9.6 jsonb queries
http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails
#payload: [{"kind"=>"person"}]
Segment.where("payload @> ?", [{kind: "person"}].to_json)
#data: {"interest"=>["music", "movies", "programming"]}
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json)
Segment.where("data #>> '{interest, 1}' = 'movies' ")
Segment.where("jsonb_array_length(data->'interest') > 1")
@sbusso
sbusso / Selection.py
Created June 3, 2018 01:24 — forked from viticci/Selection.py
Selection.py
# coding: utf-8
import sys
import html2text
import clipboard
import webbrowser
webpage = clipboard.get()
text = sys.argv[1]
@sbusso
sbusso / deploy.sh
Created February 12, 2018 09:48 — forked from EwanValentine/deploy.sh
Go + Docker build script example
#!/bin/bash
source ~/.bashrc
echo "Building"
# Build Go binary in Docker image
docker run --rm \
-e "GOPATH=/go" \
-e "CGO_ENABLED=0" \
-e "GOOS=linux" \
@sbusso
sbusso / portainer_traefik_demo.sh
Created February 4, 2018 16:01 — forked from eine/portainer_traefik_demo.sh
Portainer and Traefik demo
#!/bin/sh
mkdir -pv traefik && cd traefik
printf "version: '2' \n\
\n\
services: \n\
traefik: \n\
image: traefik \n\
restart: always \n\
ports: [ '80:80', '8080:8080' ] \n\
@sbusso
sbusso / backup.md
Created July 17, 2017 05:39 — forked from ouyangzhiping/backup.md
Backing Up PostgreSQL With Backup and Whatever Gems with Drobpbox api

create backup project

bundle exec backup generate:model --trigger my_backup --archives --storages='dropbox' --compressors='gzip' --notifiers='mail' --databases="postgresql"

dropbox api

https://www.dropbox.com/developers/apps

@sbusso
sbusso / Gemfile
Created July 17, 2017 05:38 — forked from kavu/Gemfile
How to make Rails + Backup + Whenever + Capistrano (and rbenv) work.
#...
gem 'backup', require: false,
github: 'kavu/backup',
branch: 'bump_fog_version',
ref: 'c3fd8e6eb4f464de1c8'
gem 'whenever', require: false
#...