Skip to content

Instantly share code, notes, and snippets.

@maruks
maruks / aws_lambda.py
Created July 21, 2015 11:23
AWS gateway / lambda function invocation
# AWS Version 4 signing example
# This version makes a POST request and passes request parameters
# in the body (payload) of the request. Auth information is passed in
# an Authorization header.
import sys, os, base64, datetime, hashlib, hmac
import requests # pip install requests
method = 'POST'
service = 'execute-api'
@thom-nic
thom-nic / Dockerfile
Last active August 13, 2020 14:35
Dockerfile that attempts to run the app as non-root user. This creates a `node` user & sets permissions on app files. Note you cannot `chown` files in a docker 'volume' during the build process, but you can at runtime (as part of your `CMD`) but in that case you can't use the `USER` command to change the UID before `CMD` runs.
###
# Node.js app Docker file
#
# Some basic build instructions:
# ```
# # you should delete node_modules b/c you don't want that copied during 'ADD'
# docker build -t thom-nic/node-bootstrap .
# # run a shell in the container to inspect the environment (as root):
# docker run --rm -itu root thom-nic/node-bootstrap /bin/bash
# ```
@brandonb927
brandonb927 / osx-for-hackers.sh
Last active March 27, 2024 06:33
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
#!/bin/sh
###
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx
@utaal
utaal / app.js
Created October 23, 2011 14:08
server health page (node & socket.io)
var http = require('http');
var connect = require('connect');
var socketio = require('socket.io');
var fs = require('fs');
var os = require('os');
var exec = require('child_process').exec;
var util = require('util');
var $ = require('underscore');
var load_data_in_mem_count = 3000;
import Queue as _oldQueue
import heapq
from time import mktime, time as _time
class PriorityQueue(_oldQueue.PriorityQueue):
'''
This class extends Python's Queue.PriorityQueue by allowing it to
evict lower priority items in order to make room. This avoids a
starvation problem where low-priority items fill the queue and prevent
a high-priority item from being inserted.