Skip to content

Instantly share code, notes, and snippets.

@larsch
larsch / install-arch-linux-rpi-zero-w.sh
Created July 6, 2017 06:05
Install Arch Linux ARM for Raspberry Pi Zero W on SD Card (with commands to configure WiFi before first boot).
#!/bin/sh -exu
dev=$1
cd $(mktemp -d)
function umountboot {
umount boot || true
umount root || true
}
# RPi1/Zero (armv6h):
@gyglim
gyglim / tensorboard_logging.py
Last active August 23, 2023 21:29
Logging to tensorboard without tensorflow operations. Uses manually generated summaries instead of summary ops
"""Simple example on how to log scalars and images to tensorboard without tensor ops.
License: BSD License 2.0
"""
__author__ = "Michael Gygli"
import tensorflow as tf
from StringIO import StringIO
import matplotlib.pyplot as plt
import numpy as np
@mjj2000
mjj2000 / get-current-git-tag.sh
Last active April 1, 2024 01:11
[GIT] Get tag of current branch(that is HEAD) or fallback to short commit hash(7 digits) by single shell command
git describe --exact-match --tags 2> /dev/null || git rev-parse --short HEAD
@vxgmichel
vxgmichel / aioudp.py
Last active February 15, 2024 00:12
High-level UDP endpoints for asyncio
"""Provide high-level UDP endpoints for asyncio.
Example:
async def main():
# Create a local UDP enpoint
local = await open_local_endpoint('localhost', 8888)
# Create a remote UDP enpoint, pointing to the first one
@CrimsonGlory
CrimsonGlory / mongo-docker-swarm-mode.txt
Last active September 24, 2021 20:49
MongoDB sharding + Docker Swarm mode
Warnings:
* as 2017-02-24 (Docker version 1.13.1), swarm mode is not officially recommeded from production.
* There are a few bugs like swarm stop working when changing network. https://github.com/docker/docker/issues/29580
* Some kernel options (like ulimit) are still not supported on swarm when creating services https://github.com/docker/docker/issues/25209
* As 2018-09-24 docker swarm is very unstable and definitely not ready for production. Witch each new version of docker, swarm is more unstable than the previous one. I would strongly recommend avoid using swarm all together. (See issues https://github.com/moby/moby/issues/36696 and https://github.com/moby/moby/issues/37725 )
* 2021-09-10: this is an old gist with experimental configuration. Don't use this for production or anything relevant. Trust me. Also mongo versions are quite old. If you are just playing with mongo and docker swarm, go ahead.
Servers are server1 (mongos and configsrv), server2 (shard1), server3(shard2).
-----Step 1. Create swar
import requests
from db import db
"""
The Douban Group API which not display on http://developers.douban.com/wiki/?title=api_v2
Base url: https://api.douban.com/v2
Group info: /group/:id
@MidnightLightning
MidnightLightning / README.md
Created July 27, 2012 01:50
Steganography tools

Steganography: the art of hiding in plain sight. Messages specifically. These are a series of tools that aid in embedding messages in digital files.

While steganography provides obscurity, it does not strictly provide security. Before hiding your message using any of these scripts, it's suggested you encode your message (try PGP/GnuPG encryption or put it in a TrueCrypt container if you're at a loss).

pngload.py

The PNG file format divides the image data into 'chunks', and allows for additional, private chunks to be added by image editors. This script takes the message you wish to embed and saves it as binary data in such an ancillary chunk.

The files being embedded are compressed with bzip2 compression if they're not already a bzip2 archive. This is different from the `

@wheresalice
wheresalice / redisdns.py
Created November 27, 2011 12:56
Python DNS server with Redis backend
# A naive dns server with a Redis backend
# Set keys in Redis you want to be authoritative for (set google.com. 127.0.0.1)
# Tip: Use Redis's ttl functions to have temporary names
# Currently only does A records, feel free to fix that
#
# Licensed under the PSF License
# Thanks to: http://code.activestate.com/recipes/491264-mini-fake-dns-server/
# Author: @Kaerast <alice@kaerast.info>
import socket