Skip to content

Instantly share code, notes, and snippets.

@mrgcohen
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": [
"organizations:*",
"aws-portal:*Billing",
"awsbillingconsole:*Billing",
@mrgcohen
mrgcohen / flush-redis-telnet.sh
Created September 4, 2019 16:00
flush redis telnet
telnet 127.0.0.1 11211
flush_all
quit
@mrgcohen
mrgcohen / MySQL_macOS_Sierra.md
Created August 13, 2019 21:04 — forked from nrollr/MySQL_macOS_Sierra.md
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 https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • 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
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 (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"crypto/sha256"
"encoding/base64"
"fmt"
"io"
@mrgcohen
mrgcohen / export-db-query-to-file.sh
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
mrgcohen / multipart.swift
Created September 6, 2018 16:09 — forked from DejanEnspyra/multipart.swift
Alamofire 4 — Multipart file upload with Swift 3 (http://theappspace.com/multipart-file-upload/)
func requestWith(endUrl: String, imageData: Data?, parameters: [String : Any], onCompletion: ((JSON?) -> Void)? = nil, onError: ((Error?) -> Void)? = nil){
let url = "http://google.com" /* 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
mrgcohen / python_pymysql_notes.md
Created August 27, 2018 13:23 — forked from simonrw/python_pymysql_notes.md
Notes about pymysql connections

Database transactions

pymysql

  • Defaults to autocommit=False
connection = pymysql.connect(user='user', db='test')
cursor = connection.cursor()
cursor.execute('insert into test (value) values (10)')
@mrgcohen
mrgcohen / README.md
Created July 20, 2018 13:49 — forked from twolfson/README.md
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
mrgcohen / postgres-to-elastic-search.md
Last active March 25, 2021 08:11
Postgres to elasticsearch

Logstash Postgres to Elastic

input {
    jdbc {
        jdbc_connection_string => "jdbc:postgresql://127.0.0.1:5432/db"
        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
mrgcohen / serverless.yml
Created March 30, 2018 15:15 — forked from DavidWells/serverless.yml
DynamoDB custom index serverless.yml example
service: service-name
provider:
name: aws
runtime: nodejs6.10
functions:
myfunc:
handler: handler.myfunc