Skip to content

Instantly share code, notes, and snippets.

@sjungwirth
sjungwirth / Dockerfile
Last active December 17, 2020 16:00
Mozilla SOPS Docker run command (and Google Cloud SDK)
FROM mozilla/sops:latest
# install google cloud SDK
RUN curl -sSL https://sdk.cloud.google.com | bash
# Usage:
# docker build -t gcloud-sops .
# docker run --rm -v /local/file/to/encrypt.yaml:/encryption-target \
# -e KMS_KEY=projects/YOUR-GCLOUD-PROJECT-ID/locations/global/keyRings/YOUR_KEYRING_ID/cryptoKeys/YOUR_KEY_ID \
# -v ~/.config/gcloud:/root/.config/gcloud \
# -exec gcloud-sops /bin/sh -c "sops --encrypt --gcp-kms \$KMS_KEY /encryption-target" > /my/local/path/output.json
@sjungwirth
sjungwirth / raven-init.js
Created October 14, 2017 01:03
Node Raven (Sentry) prevent duplicate error spam
// Return true if x is a power of 2
function isPow2(x) {
return (x & (x - 1)) === 0;
}
// To keep track of the errors we have seen
const loggedErrors = {};
// Function to tell sentry if it should send the error
function shouldSendCallback(kwargs) {
let errKey;
@sjungwirth
sjungwirth / New Relic BitCode .dSYM file upload script
Created March 6, 2017 22:48 — forked from chrislavender/New Relic BitCode .dSYM file upload script
Script to upload .dSYM files for BitCode enabled apps to New Relic
#!/bin/bash
# Currently New Relic doesn't provide a script to upload .dSYM files for BitCode enabled apps.
# To use this...
# 1) download the dSYM files for a given build from iTunesConnect
# 2) append the file with .zip and then double click to unzip the .dSYMs
# 3) run this script from with in the directory that contains the .dSYM files
count=0
for DSYM in $( ls -d *".dSYM/" ); do
@sjungwirth
sjungwirth / git-whitespace-pre-commit
Created March 19, 2015 17:01
git whitespace pre-commit hook
#!/bin/sh
# Configure whitespace check settings
WHITESPACE_CHECK_OPTIONS='blank-at-eol,trailing-space,space-before-tab,indent-with-non-tab,tabwidth=1'
# Run whitepace checks against source files
WHITESPACE_CHECK_FILES_DEFAULT='(.php|.js|.css|.less|.html|.txt|.xml)$'
# User can override above setting by configuration
WHITESPACE_CHECK_FILES=$(git config hooks.whitespace.filesregex)
@sjungwirth
sjungwirth / js-styleguide.md
Last active August 29, 2015 14:01
Demand Media JavaScript Style Guide

Principles of Writing Consistent, Idiomatic JavaScript

All code in any code-base should look like a single person typed it, no matter how many people contributed.

The following list outlines the practices that we use in all code that we are the original author of; contributions to projects that we have created should follow these guidelines.

We do not intend to impose our style preferences on other people's code or projects; if an existing common style exists, it should be respected.

"Arguments over style are pointless. There should be a style guide, and you should follow it"