Skip to content

Instantly share code, notes, and snippets.

@toddlers
toddlers / Dockerfile
Created July 27, 2016 11:24
using envsubst in Dockerfile
FROM ubuntu:trusty
RUN \
apt-get update \
&& apt-get -y install gettext-base \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
ENV VALUE=foo
ENV VALUE1=boo
COPY config.txt source_config.txt
@mgaebler
mgaebler / gist:055a08827cdfb95fa84a4a5d7ef2255b
Last active June 16, 2024 05:50
NGINX: Custom JSON status page with stub_status
# Make sure the ngx_http_stub_status_module is installed correctly.
location /status {
add_header Content-Type application/json;
return 200 '{\r
"connections_active": $connections_active,\r
"connections_reading": $connections_reading,\r
"connections_writing": $connections_writing,\r
"connections_waiting": $connections_waiting
}';
}
@hirobert
hirobert / flask_abort_example.py
Created January 13, 2016 20:38
flask abort as json
from flask import abort, make_response, jsonify
abort(make_response(jsonify(message="Message goes here"), 400))
@nicolaiarocci
nicolaiarocci / validate_objects.py
Created January 5, 2015 10:09
Validating complex user objects with Cerberus
import copy
from cerberus import Validator
from cerberus import errors
from collections import Mapping, Sequence
class ObjectValidator(Validator):
def __init__(self, *args, **kwargs):
@luiscoms
luiscoms / copypublickey.sh
Last active August 29, 2015 14:02
Generate and copy ssh publickey to remote host
#!/bin/bash
# replace config
REMOTEUSER="luiscoms"
REMOTEHOST="example.com"
# generate ssh key if not exits
if [ ! -f ~/.ssh/id_dsa.pub ];then
ssh-keygen -t dsa
fi
@luiscoms
luiscoms / .gitconfig
Last active January 30, 2023 00:59
My gitconfig
[user]
name = Luis Fernando Gomes
email = [email protected]
[core]
ignorecase = false
[push]
default = current
@davidchua
davidchua / non-us-s3-buckets
Created March 15, 2013 07:20
Modify ~/.s3cfg after installing s3cmd and running s3cmd --configure. This solves Errno 32: Broken Pipe error when trying to push a file to a non-US S3 bucket.
# in ~/.s3cfg
# modify host_base and host_bucket to the proper endpoints
host_base = s3-ap-southeast-1.amazonaws.com
host_bucket = %(bucket)s.s3-ap-southeast-1.amazonaws.com
@jwebcat
jwebcat / gist:5122366
Last active January 23, 2025 05:43 — forked from lemenkov/gist:1674929
Properly download from github using wget and curl
wget --no-check-certificate --content-disposition https://github.com/joyent/node/tarball/v0.7.1
# --no-check-cerftificate was necessary for me to have wget not puke about https
curl -LJO https://github.com/joyent/node/tarball/v0.7.1
@iros
iros / API.md
Created August 22, 2012 14:42
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

@hagenburger
hagenburger / javascript_loader.js
Created July 30, 2010 15:28
Dynamically load JavaScript files with callback when finished
// Example:
JavaScript.load("/javascripts/something.js");
// With callback (that’s the good thing):
JavaScript.load("http://www.someawesomedomain.com/api.js", function() {
API.use(); // or whatever api.js provides ...
});