Skip to content

Instantly share code, notes, and snippets.

@garnaat
garnaat / bucket_du.py
Created September 1, 2011 13:15
Get total bytes in a bucket
# Iterates over all the keys in a bucket and totals the bytes used
# NOTE: if you have a lot of keys, this could take a LONG time.
import boto
def bucket_du(bucket_name):
s3 = boto.connect_s3()
bucket = s3.lookup(bucket_name)
total_bytes = 0
for key in bucket:
@hernantz
hernantz / common_fabfile.py
Last active July 14, 2017 06:00
Fabfile with common fabric tasks, featuring virtualenvwrapper, nginx, supervisord, git deployment and some other goodies.
from fabric.api import task, local, sudo, run, prefix, env, cd
from fabric.contrib.files import exists, first
from contextlib import contextmanager, nested
def once(s):
"""Command_prefixes is a list of prefixes"""
if s not in env.command_prefixes:
return s
return 'true'
@masahirosuzuka
masahirosuzuka / .gitignore
Last active March 10, 2019 14:46
gitignore template for KiCad project
# temp files
*.bak
*.bck
*.kicad_pcb-bak
*-cache.lib
# *-rescue.lib
ftp-lib-table
# for external tools
*.dsn
@acherunilam
acherunilam / influxdb.conf
Created May 3, 2016 12:23
Nginx config for InfluxDB HA
http {
client_max_body_size 20M;
upstream influxdb {
server server1:8086;
server server2:8086;
}
upstream relay {
server server1:9096;
server server2:9096;
@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
@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)
@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

@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.
@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.

@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-----