Skip to content

Instantly share code, notes, and snippets.

View mcabrams's full-sized avatar
🤙
Wherever you go... there you are

Matthew Abrams mcabrams

🤙
Wherever you go... there you are
View GitHub Profile
@xtavras
xtavras / kubernetes_add_service_account_kubeconfig.sh
Created November 25, 2019 10:54
create kubernetes service account and corresponding kubeconfig
#!/usr/bin/env bash
# script was taken from https://gist.github.com/innovia/fbba8259042f71db98ea8d4ad19bd708 and adjusted with "apply_rbac" function and colorized output
set -e
set -o pipefail
# Colors
RED="\e[01;31m"
@ryanpcmcquen
ryanpcmcquen / darkify_slack.sh
Last active February 23, 2023 16:08
Darkify your Slack.
#!/bin/sh
# Darkify Slack on Mac OS or Linux.
# curl https://gist.githubusercontent.com/ryanpcmcquen/8a7ddc72460eca0dc1f2dc389674dde1/raw/darkify_slack.sh | sh
if [ "`uname -s`" = "Darwin" ]; then
SLACK_INTEROP_JS="/Applications/Slack.app/Contents/Resources/app.asar.unpacked/dist/ssb-interop.bundle.js"
else
SLACK_INTEROP_JS="/usr/lib/slack/resources/app.asar.unpacked/dist/ssb-interop.bundle.js"
fi
@ashwoods
ashwoods / celery.py
Last active December 8, 2018 00:10
Sentry Django & Celery >=4.0 integration
# If following the official celery documentation for integration django
# you might have a `celery.py` file that looks like this.
from __future__ import absolute_import, unicode_literals
import os
import logging
from celery import Celery
# from celery.utils.log import get_task_logger
from celery import signals
@mbrochh
mbrochh / 01_utils.py
Last active September 24, 2023 10:45
Using pagination with Django, graphene and Apollo
from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator
# First we create a little helper function, becase we will potentially have many PaginatedTypes
# and we will potentially want to turn many querysets into paginated results:
def get_paginator(qs, page_size, page, paginated_type, **kwargs):
p = Paginator(qs, page_size)
try:
page_obj = p.page(page)
except PageNotAnInteger:
@jylopez
jylopez / stripe_country_codes.js
Last active May 2, 2024 16:35
Stripe Country Codes
[
{ country: 'Australia', code: 'AU' },
{ country: 'Austria', code: 'AT' },
{ country: 'Belgium', code: 'BE' },
{ country: 'Brazil', code: 'BR' },
{ country: 'Bulgaria', code: 'BG' },
{ country: 'Canada', code: 'CA' },
{ country: 'Croatia', code: 'HR' },
{ country: 'Cyprus', code: 'CY' },
{ country: 'Czech Republic', code: 'CZ' },
@innovia
innovia / kubernetes_add_service_account_kubeconfig.sh
Last active January 29, 2024 23:00
Create a service account and generate a kubeconfig file for it - this will also set the default namespace for the user
#!/bin/bash
set -e
set -o pipefail
# Add user to k8s using service account, no RBAC (must create RBAC after this script)
if [[ -z "$1" ]] || [[ -z "$2" ]]; then
echo "usage: $0 <service_account_name> <namespace>"
exit 1
fi
@gdekefir
gdekefir / requests.spec.ts
Created April 14, 2017 20:24
Mocking Observable.ajax.get
jest.mock('./process-env');
import Mock = jest.Mock;
import {Observable} from 'rxjs';
import {get} from './requests';
import {getProcessEnv} from './process-env';
describe('get', () => {
const originalAjaxGet = Observable.ajax.get;
@mpneuried
mpneuried / Makefile
Last active May 4, 2024 13:46
Simple Makefile to build, run, tag and publish a docker containier to AWS-ECR
# import config.
# You can change the default config with `make cnf="config_special.env" build`
cnf ?= config.env
include $(cnf)
export $(shell sed 's/=.*//' $(cnf))
# import deploy config
# You can change the default deploy config with `make cnf="deploy_special.env" release`
dpl ?= deploy.env
include $(dpl)
@MarkTiedemann
MarkTiedemann / README.md
Last active July 18, 2021 11:42
An Easier Way to Enforce Required Parameters in ES6

An Easier Way to Enforce Required Parameters in ES6

Expands on Handling required parameters in ECMAScript 6 by Axel Rauschmayer.

The idea (which is credited to Allen Wirfs-Brock) is, in essence, to use default parameter values to call a function which throws an Error if the parameter is missing:

const throwIfMissing () => { throw new Error('Missing parameter') }
@tomchuk
tomchuk / google_login.py
Created December 23, 2015 00:16
Google OAuth2 Authentication with Flask & requests-oauthlib
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
A simple flask app to authenticate with Google's OAuth 2.0 API
Requirements:
Flask>=0.10.0
requests-oauthlib>=0.5.0
To install, run: "pip install Flask>=0.10.0 requests-oauthlib>=0.5.0"