Skip to content

Instantly share code, notes, and snippets.

@roylee0704
roylee0704 / dockergrep.sh
Created December 9, 2016 08:24
how to grep docker log
docker logs nginx 2>&1 | grep "127."
# ref: http://stackoverflow.com/questions/34724980/finding-a-string-in-docker-logs-of-container
@quiver
quiver / README.md
Last active April 3, 2024 15:47
Who says PostgreSQL can't Pub/Sub like Redis?

Pub/Sub pattern with PostgreSQL's LISTEN/NOTIFY command

This is a simple chat-like program using pub-sub pattern, backed by PostgreSQL's LISTEN/NOTIFY command.

Publish

publish message to foo channel from user nickname.

$ python pub.py foo nickname
PUBLISH to channel #foo
@sergiotapia
sergiotapia / md5-example.go
Last active December 5, 2023 03:53
Golang - How to hash a string using MD5.
import (
"crypto/md5"
"encoding/hex"
)
func GetMD5Hash(text string) string {
hasher := md5.New()
hasher.Write([]byte(text))
return hex.EncodeToString(hasher.Sum(nil))
}
@rbq
rbq / docker.yaml
Last active October 19, 2023 11:57
Install Docker CE on Ubuntu using Ansible
---
- hosts: all
tasks:
- name: Install prerequisites for Docker repository
apt:
name: ['apt-transport-https', 'ca-certificates', 'curl', 'gnupg2', 'software-properties-common']
update_cache: yes
- name: Add Docker GPG key
apt_key:
@darconeous
darconeous / dh.pem
Last active June 23, 2023 11:09
Getting FreeRadius set up on EdgeRouter
-----BEGIN DH PARAMETERS-----
MIIBCAKCAQEAq5/y4YW0hozeF0bQw86uDaDO0o+68DjAch61bc3nwyVC77e6JYUT
5F9x+mn9j25KhbcNGBcZvO/TFHsPf4bx4fojNKD2T5nZATJRtGuepnyjz5XEpPe2
ojAsjYpPg/0HZou/tyPM1OGTi5qlVUHa+GHrpX5419NDdOCU5IRr1kkIOMaT7+co
OFAlGCr8fiLTArGWbZDed3N0EvXE1JaIlOmQmVxLP8EycZsbjnCWB9b7DfQW2TeB
9Qp3PjfpAH/VPc3xrMqrXLlGR3h6PA5FfanN2e1XWISOYQe9N/K5uN6lze+HoAk6
Kusp+bLFxWX5EDxK1XXW+4L5JwNwUDMZCwIBAg==
-----END DH PARAMETERS-----
@kvnsmth
kvnsmth / example-subtree-usage.md
Last active March 5, 2023 21:58
A real world usage for git subtrees.

Let's say you have an iOS project, and you want to use some external library, like AFNetworking. How do you integrate it?

With submodules

Add the project to your repo:

git submodule add git@github.com:AFNetworking/AFNetworking.git Vendor/AFNetworking

or something to that effect.

@mplewis
mplewis / flask-uwsgi-nginx-primer.md
Last active October 24, 2022 19:20
Flask + uWSGI + nginx Primer. I've been having trouble with serving a Flask app via uWSGI and nginx, so I thought I'd put together some of the basics to help out others.

Flask + uWSGI + nginx Primer

I've been having trouble with serving a Flask app via uWSGI and nginx, so I thought I'd put together some of the basics to help out others.

How this shit works

  • Flask is managed by uWSGI.
  • uWSGI talks to nginx.
@max-mapper
max-mapper / readme.md
Last active May 21, 2022 11:02
ffmpeg youtube live event rtmp stream from raspberry pi with raspi camera (raspivid)
  1. compile ffmpeg for arm https://github.com/fiorix/ffmpeg-arm
  2. create youtube 'live event'. get rtmp url + session id
  3. run this:
raspivid -o - -t 0 -vf -hf -fps 30 -b 6000000 | ffmpeg -re -ar 44100 -ac 2 -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero -f h264 -i - -vcodec copy -acodec aac -ab 128k -g 50 -strict experimental -f flv rtmp://a.rtmp.youtube.com/live2/<SESSION>

you can tweak -b and -fps to your liking. the settings above work well for 1080p. by not specifying width or height we get the full 1920x1080 resolution from the raspi camera

@ju-popov
ju-popov / timestamp.py
Last active April 7, 2021 16:09
Python DateTime / Timestamp Convertion
######################################################################
# CURRENT AWARE LOCAL DATETIME
######################################################################
from datetime import datetime
from tzlocal import get_localzone
local_tz = get_localzone()
local_dt = datetime.now(local_tz)
@ah-cog
ah-cog / Using the Terminal to Upload an Arduino Sketch to the Teensy 3.1.md
Last active April 16, 2020 01:00
Upload to the Teensy 3.1 from Terminal on OS X with Arduino 1.6.1 and Teensyduino 1.21.

Uploading Arduino Sketches to the Teensy 3.1 from the Terminal

First, install Arduino 1.6.1 from http://arduino.cc/en/Main/Software. I followed the Mac OS X for Java 6 link to download arduino-1.6.1-macosx.zip. Install Arduino by unzipping the Arduino file and moving it to /Applications/Arduino. Open Arduino to make sure it works and so it can finish setting up the environment for use. Next, install Teensyduino 1.21 from https://www.pjrc.com/teensy/td_download.html. I followed Macintosh OS-X Installer to download teensyduino.dmg. Open and proceed through the Teensyduino installer, and when prompted to locate Arduino, select /Applications/Arduino, then continue to the next step in the installer.

At this point, you should be ready to upload a sketch. Follow the instructions below.

To upload from the terminal, enter the following command:

/Applications/Arduino.app/Contents/MacOS/JavaApplicationStub --board teensy:avr:teensy31 --port /dev/tty.usbmodem573061 --upload /Users/mokogobo/Checkout