Skip to content

Instantly share code, notes, and snippets.

@stesie
stesie / index.html
Created April 1, 2016 22:28
AWS IoT-based serverless JS-Webapp Pub/Sub demo
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>AWS IoT Pub/Sub Demo</title>
</head>
<body>
<h1>AWS IoT Pub/Sub Demo</h1>
<form>
<button type="button" id="connect">connect!</button>
{
"Version": "2012-10-17",
"Statement": [{
"Action": "ec2:*",
"Effect": "Allow",
"Resource": "*",
"Condition": {
"StringEquals": {
"ec2:Region": [
"us-east-1",
@vasanthk
vasanthk / System Design.md
Last active November 14, 2024 11:31
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
* cofnig origin ref: http://serverfault.com/questions/235669/how-do-i-make-rabbitmq-listen-only-to-localhost
Bugs:
* epmd stays up after rabbitmq-server is stopped. It's shared amond all Erlang instances, so maintainers feel not one packake should kill it.
https://bugzilla.redhat.com/show_bug.cgi?id=1104843
* Erlang has a bug requiring ERL_EPMD_ADDRESS to be specified as IPv6. It seems that, if epmd is built with ipv6, it looses ability to bind with ipv4. Fix traversing from upstream.
https://bugs.launchpad.net/ubuntu/+source/erlang/+bug/1374109
https://github.com/erlang/otp/compare/maint...msantos:epmd-IPv6-node-reg
We run R16B03-1/3.2.4-1
@eldondev
eldondev / cmd
Last active December 4, 2023 16:33
Because everyone needs a good preseed
wget -nc http://ftp.debian.org/debian/dists/jessie/main/installer-amd64/current/images/netboot/debian-installer/amd64/linux
wget -nc http://ftp.debian.org/debian/dists/jessie/main/installer-amd64/current/images/netboot/debian-installer/amd64/initrd.gz
cp -nv ~/.ssh/id_rsa.pub .
qemu-system-x86_64 -machine accel=kvm -kernel linux -initrd initrd.gz -m 1G -smp 2 -append "blacklist=vga16fb fb=false video=false vga=normal auto=true url=http://10.0.2.10:8080/debian-preseed.txt hostname=otto domain=" -net user,guestfwd=:10.0.2.10:8080-cmd:"/bin/busybox httpd -i" -hda /dev/shm/deb.img -net nic -display none
@floer32
floer32 / _socket_toggle.py
Last active December 18, 2019 20:31
Disable the internet in Python. With py.test hooks. (Disable socket.socket.) GREAT for unit testing.
from __future__ import print_function
import socket
import sys
_module = sys.modules[__name__]
def disable_socket():
""" disable socket.socket to disable the Internet. useful in testing.
.. doctest::
@flavianmissi
flavianmissi / postgresql.conf
Created April 14, 2015 09:48
postgresql sample edited conf
shared_buffers = 512MB
work_mem = 16MB
fsync = off
synchronous_commit = off
wal_buffers = 64MB
checkpoint_segments = 36
checkpoint_timeout = 10min
random_page_cost = 2.0
effective_cache_size = 1024MB
@floer32
floer32 / quick_punycode_encode_decode_example.py
Last active December 24, 2019 15:30
[Regarding Python 2 - in Python 3 just use normal strings that are always Unicode.] // quick example of encoding and decoding a international domain name in Python (from Unicode to Punycode or IDNA codecs and back). Pay attention to the Unicode versus byte strings
# INCORRECT! DON'T DO THIS!
>>> x = "www.alliancefrançaise.nu" # This is the problematic line. Forgot to make this a Unicode string.
>>> print x
www.alliancefrançaise.nu
>>> x.encode('punycode')
'www.Alliancefranaise.nu-h1a31e'
>>> x.encode('punycode').decode('punycode')
u'www.Alliancefran\xc3\xa7aise.nu'
>>> print x.encode('punycode').decode('punycode')
www.alliancefrançaise.nu
@floer32
floer32 / centos_python_env_setup
Last active May 2, 2022 03:47 — forked from stantonk/doit
CentOS 6: Install Python 2.7.4, pip, virtualenv, and virtualenvwrapper on CentOS (plus some bonus items at the end if you want). You should probably run with `sudo`.
#!/bin/bash
# Source: http://toomuchdata.com/2012/06/25/how-to-install-python-2-7-3-on-centos-6-2/
# Install stuff #
#################
# Install development tools and some misc. necessary packages
yum -y groupinstall "Development tools"
yum -y install zlib-devel # gen'l reqs