Skip to content

Instantly share code, notes, and snippets.

View RichardBronosky's full-sized avatar

Bruno Bronosky RichardBronosky

View GitHub Profile
// number to string, pluginized from http://stackoverflow.com/questions/5529934/javascript-numbers-to-words
window.num2str = function (num) {
return window.num2str.convert(num);
}
window.num2str.ones = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'];
window.num2str.tens = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'];
window.num2str.teens = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'];
@RichardBronosky
RichardBronosky / comment
Last active May 22, 2018 02:29
ipython ipshell pattern
"""
if you pass arguments to django-admin.py (like --settings=...) they also get
passed to IPShell, unless you explicitly specify argv to contain an empty list.
The oneliner below works. It has a short url of http://j.mp/ipshell
pull it into vim with...
:r!curl -sL j.mp/ipshell
"""
@evu
evu / aws.sh
Created January 10, 2019 14:53
#!/bin/bash
role_name=`curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/`
creds=`curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/$role_name`
current_region=`curl -s http://169.254.169.254/latest/dynamic/instance-identity/document | jq -c -r .region`
export AWS_ACCESS_KEY_ID=`printf "%s" "$creds" | jq -r .AccessKeyId`
export AWS_SECRET_ACCESS_KEY=`printf "%s" "$creds" | jq -r .SecretAccessKey`
export AWS_SESSION_TOKEN=`printf "%s" "$creds" | jq -r .Token`
export AWS_DEFAULT_REGION=$current_region
@antichris
antichris / about.md
Created October 21, 2013 14:55
Fork your own Gist

Fork your own Gist

This is a bookmarklet that adds a fully functional Fork button to your own Gist.

If a Fork button is already present in the page, this bookmarklet will set focus to it instead of adding another one.

The change is temporary and the button will disappear as soon as you navigate away from that Gist (clicking the Fork button does this for you as well).


@datagrok
datagrok / git-serve.md
Last active April 21, 2023 07:33
How to easily launch a temporary one-off git server from any local repository, to enable a peer-to-peer git workflow.
@caraboides
caraboides / backup-mongodb-to-s3.sh
Last active August 2, 2023 06:11
Simple script to backup MongoDB to S3, without waste diskspace for temp files. And a way to restore from the latest snapshot.
#!/bin/sh
set -e
HOST=localhost
DB=test-entd-products
COL=asimproducts
S3PATH="s3://mongodb-backups-test1-entd/$DB/$COL/"
S3BACKUP=$S3PATH`date +"%Y%m%d_%H%M%S"`.dump.gz
S3LATEST=$S3PATH"latest".dump.gz
/usr/bin/aws s3 mb $S3PATH
@e7d
e7d / sample.sh
Last active December 10, 2023 10:45
Bash "try catch"
#!/bin/bash
export AnException=100
export AnotherException=101
# start with a try
try
( # open a subshell !!!
echo "do something"
[ someErrorCondition ] && throw $AnException
@kennwhite
kennwhite / multi_key_crypto.sh
Last active January 16, 2024 15:47
OpenSSL command line recipe for multi-public key file encryption. Any single private key paired to one of the public keys can decrypt the file.
#!/usr/bin/env bash
#
# Example of multiple key AES encryption for text files using the openssl v. 0.9.8+ command line utility
# Uses n public certs as key for MIME PKCS envelope, any individual private key can decrypt.
#
# If standard RSA ssh keys exist, these can be converted to public certs as well (and ssh keys can decrypt)
#
# To sign (and verify) the encrypted file, one of the private keys is required, see:
# http://www.openssl.org/docs/apps/smime.html#EXAMPLES for openssl smime examples
# or http://www.openssl.org/docs/apps/cms.html#EXAMPLES for cms utility (OpenSSL v. 1.0+)
@RichardBronosky
RichardBronosky / Nutrichef Sous Vide Cooker Instructions.txt
Last active January 20, 2024 23:57
Simple instructions for the inexpensive sous vide with the terrible interface that everyone hates. I've owned it for over 2 years and I still have to open this every time I use it!
Plug in cooker.
Cooker powers on momentarily and is unusable.
Fill water to MAX port.
Touch POWER button for 5 seconds.
Cooker powers on and is usable.
Touch POWER and SET.
SET TEMP field flashes.
Units toggle between °C & °F.
Turn wheel.
Field value changes.
@joyrexus
joyrexus / README.md
Last active January 21, 2024 21:51 — forked from btoone/curl.md
curl tutorial

An introduction to curl using GitHub's API.

Basics

Makes a basic GET request to the specifed URI

curl https://api.github.com/users/caspyin

Includes HTTP-Header information in the output