Skip to content

Instantly share code, notes, and snippets.

@markeissler
markeissler / strip-env.sh
Created July 30, 2022 00:07
Strip comments and single quotes from dotenv files
#!/usr/bin/env bash
# SOME_VALUE='my_value'
# SOME_VALUE=my_value
# SOME_ARRAY='["one", "two", "three"]'
# SOME_ARRAY='["one","two","three"]'
# SOME_ARRAY=["one", "two", "three"]
input="${1}"
@markeissler
markeissler / swiftlint-wrapper.sh
Created February 5, 2022 00:08
SwiftLintAppCodeWrapper
#!/bin/bash
# Workaround for SwiftLintAppCode plugin hanging while calling swiftlint.
#
# 1. Drop this into /usr/local/bin/swiftlint-wrapper.sh or some other handy spot.
# 2. Set exec permissions: chmod 0755 /usr/local/bin/swiftlint-wrapper.sh
# 3. Update AppCode SwiftLint settings to point to the wrapper.
#
# This wrapper supports a single file only as an argument. It supports linting
# once a file has been saved (auto trigger) or if specifying the file from the
@markeissler
markeissler / index.js
Created November 25, 2021 22:20 — forked from marcusgadbem/index.js
Middleware to minify HTML output for express template render engines in which supports callbacks
/* app/controllers/index.js */
module.exports.index = function(req, res) {
res.render('index.html');
};
@markeissler
markeissler / downloadFile.js
Created August 11, 2020 23:38 — forked from dreamyguy/downloadFile.js
Download response.data as a file, through Blob()
// 'downloadFile.js', written by blending two solutions:
// 'js-download' https://github.com/kennethjiang/js-file-download
// 'Anders Paulsen' https://blog.jayway.com/2017/07/13/open-pdf-downloaded-api-javascript/
export function downloadFile(data, filename, mime) {
// It is necessary to create a new blob object with mime-type explicitly set
// otherwise only Chrome works like it should
const blob = new Blob([data], {type: mime || 'application/octet-stream'});
if (typeof window.navigator.msSaveBlob !== 'undefined') {
// IE doesn't allow using a blob object directly as link href.
@markeissler
markeissler / md5-example.go
Created April 21, 2020 16:08 — forked from sergiotapia/md5-example.go
Golang - How to hash a string using MD5.
import (
"crypto/md5"
"encoding/hex"
)
func GetMD5Hash(text string) string {
hasher := md5.New()
hasher.Write([]byte(text))
return hex.EncodeToString(hasher.Sum(nil))
}
@markeissler
markeissler / mux_handlers.go
Created April 17, 2020 17:04 — forked from bennAH/mux_handlers.go
gorilla mux - multiple handlers
package main
import (
"fmt"
"github.com/gorilla/mux"
"net/http"
)
func main() {
r := mux.NewRouter()
kubectl get pods | grep Evicted | awk '{print $1}' | xargs kubectl delete pod
@markeissler
markeissler / terraform-kubernetes-docker-macos.md
Created February 25, 2019 16:15 — forked from ivaravko/terraform-kubernetes-docker-macos.md
The simple Terraform and Kubernetes with Docker on macOS

If you'd like to experiment with Terraform and Kubernetes on macOS locally, a great provider for doing so is the Kubernetes provider. You can get set up in a few simple steps, like so:

1. Install Docker

Install Docker for Mac if you have not already.

@markeissler
markeissler / iam-s3-policy.json
Created January 8, 2019 00:50 — forked from lusis/iam-s3-policy.json
A sample AWS IAM json policy file with read-only access to certain S3 buckets
{
"Statement":[{
"Effect":"Allow",
"Action":["s3:ListBucket","s3:GetObject","s3:GetObjectVersion"],
"Resource":["arn:aws:s3:::my_bucket/*","arn:aws:s3:::my_bucket"]
}
],
"Statement":[{
"Effect":"Allow",
"Action":["s3:ListBucket","s3:GetObject","s3:GetObjectVersion"],
@markeissler
markeissler / S3-readonly-bucket.json
Created January 8, 2019 00:50 — forked from patrickbrandt/S3-readonly-bucket.json
IAM Policy for read-only S3 bucket access
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowUserToSeeBucketListInTheConsole",
"Action": [
"s3:ListAllMyBuckets",
"s3:GetBucketLocation"
],
"Effect": "Allow",