Skip to content

Instantly share code, notes, and snippets.

@jrom
jrom / nginx.conf
Created February 7, 2012 17:14
nginx hack for multiple conditions
if ($request_uri = /) {
set $test A;
}
if ($host ~* teambox.com) {
set $test "${test}B";
}
if ($http_cookie !~* "auth_token") {
set $test "${test}C";
@UniIsland
UniIsland / SimpleHTTPServerWithUpload.py
Created August 14, 2012 04:01
Simple Python Http Server with Upload
#!/usr/bin/env python
"""Simple HTTP Server With Upload.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
"""
@pongstr
pongstr / README.md
Last active February 21, 2020 22:07
Display Google Docs Spreadsheet as JSON.

Google Docs Spreadsheet as JSON

This code is taken from DJ's Weblog, thanks a lot for this!

How to use:

  1. You'll need the key of your spreadsheet, the url format should be like this: https://docs.google.com/spreadsheet/ccc?key=**YOUR-KEY-HERE**=drive_web#gid=0 and also the sheet number (i.e., Sheet 1).
  2. In your document file menu, you'll find File Menu > Tools > Script Editor (you will be redirected to Google's script editor.
  3. Create a new Script file, and paste the content of the SheetAsJSON.js to the editor stage, and save it.
@hoitomt
hoitomt / log_request.go
Created January 30, 2015 12:56
Golang: Log HTTP Requests in Go
package main
import (
"fmt"
"log"
"net/http"
"os"
)
func main() {
@redmoses
redmoses / app.py
Last active July 2, 2020 09:29
Using Flask to run shell commands
from flask import Flask
from flask import request
import subprocess
app = Flask('flaskshell')
ip_whitelist = ['192.168.1.2', '192.168.1.3']
query_success = "SELECT COUNT(*) FROM flasktest.tasks WHERE task_status='Success'"
query_pending = "SELECT COUNT(*) FROM flasktest.tasks WHERE task_status='Pending'"
query_failed = "SELECT COUNT(*) FROM flasktest.tasks WHERE task_status='Failed'"
@pierrejoubert73
pierrejoubert73 / markdown-details-collapsible.md
Last active November 16, 2024 22:55
How to add a collapsible section in markdown.

How to add a collapsible section in markdown

1. Example

Click me

Heading

  1. Foo
  2. Bar
    • Baz
  • Qux
@acobaugh
acobaugh / git-crypt-list-keys.sh
Created September 29, 2017 15:23
List git-crypt gpg keys
for key in .git-crypt/keys/default/0/* ; do gpg -k $(echo $(basename $key) | sed -e 's/.gpg//') ; done ;
@mholt
mholt / macapp.go
Last active November 8, 2024 20:51
Distribute your Go program (or any single binary) as a native macOS application
// Package main is a sample macOS-app-bundling program to demonstrate how to
// automate the process described in this tutorial:
//
// https://medium.com/@mattholt/packaging-a-go-application-for-macos-f7084b00f6b5
//
// Bundling the .app is the first thing it does, and creating the DMG is the
// second. Making the DMG is optional, and is only done if you provide
// the template DMG file, which you have to create beforehand.
//
// Example use:
@kvudata
kvudata / label-ns.yaml
Created June 27, 2018 20:20
Use Helm hook to add labels to a namespace before chart installation
# This hook depends on helm creating the target namespace if it doesn't exist
# before the hook is called. This is the case on Helm v2.9.1
apiVersion: batch/v1
kind: Job
metadata:
name: label-ns
namespace: kube-system
labels:
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}