Skip to content

Instantly share code, notes, and snippets.

mrgcohen / deny-account-key-items.json
Created September 13, 2019 16:18
aws deny key account items
"Version": "2012-10-17",
"Statement": [
"Sid": "DenyAdminAccountAndBilling",
"Effect": "Deny",
"Action": [
mrgcohen /
Created September 4, 2019 16:00
flush redis telnet
telnet 11211
mrgcohen /
Created August 13, 2019 21:04 — forked from nrollr/
Install MySQL on Sierra using Homebrew

Install MySQL on macOS Sierra

This procedure explains how to install MySQL using Homebrew on macOS Sierra 10.12

Install Homebrew

  • Installing Homebrew is effortless, open Terminal and enter :
    $ /usr/bin/ruby -e "$(curl -fsSL"
  • Note: Homebrew will download and install Command Line Tools for Xcode 8.0 as part of the installation process.

Install MySQL

At this time of writing, Homebrew has MySQL version 5.7.15 as default formulae in its main repository :

mrgcohen / aes.go
Created July 25, 2019 12:21 — forked from willshiao/aes.go
AES 256-CFB in Node.js, Go, and Python
package main
import (
mrgcohen /
Last active July 17, 2019 16:51
Export db query to file through stdout postgres
psql -h host -U username dbname -c "copy (select * from table) TO STDOUT WITH CSV" >> data.csv
mrgcohen / multipart.swift
Created September 6, 2018 16:09 — forked from DejanEnspyra/multipart.swift
Alamofire 4 — Multipart file upload with Swift 3 (
func requestWith(endUrl: String, imageData: Data?, parameters: [String : Any], onCompletion: ((JSON?) -> Void)? = nil, onError: ((Error?) -> Void)? = nil){
let url = "" /* your API url */
let headers: HTTPHeaders = [
/* "Authorization": "your_access_token", in case you need authorization header */
"Content-type": "multipart/form-data"
Alamofire.upload(multipartFormData: { (multipartFormData) in
mrgcohen /
Created August 27, 2018 13:23 — forked from simonrw/
Notes about pymysql connections

Database transactions


  • Defaults to autocommit=False
connection = pymysql.connect(user='user', db='test')
cursor = connection.cursor()
cursor.execute('insert into test (value) values (10)')
mrgcohen /
Created July 20, 2018 13:49 — forked from twolfson/
Audit logging via sequelize

We prefer to have audit logging in our services that leverage databases. It gives us clarity into sources of where ACL issues might originate as well as gives us a general timeline of activity in our application.

Audit logging is tedious to set up so this gist contains our latest iteration of audit logging support for a sequelize based service.

mrgcohen /
Last active March 25, 2021 08:11
Postgres to elasticsearch

Logstash Postgres to Elastic

input {
    jdbc {
        jdbc_connection_string => "jdbc:postgresql://"
        jdbc_user => "username"
        jdbc_password => "password"
        jdbc_driver_library => "/Users/user/JDBC/postgresql-42.2.2.jar"
        jdbc_driver_class => "org.postgresql.Driver"
        statement => 'SELECT id, first_name, last_name, email from users'
mrgcohen / serverless.yml
Created March 30, 2018 15:15 — forked from DavidWells/serverless.yml
DynamoDB custom index serverless.yml example
service: service-name
name: aws
runtime: nodejs6.10
handler: handler.myfunc