Skip to content

Instantly share code, notes, and snippets.

@mrgcohen
mrgcohen / deny-account-key-items.json
Created Sep 13, 2019
aws deny key account items
View deny-account-key-items.json
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenyAdminAccountAndBilling",
"Effect": "Deny",
"Action": [
"organizations:*",
"aws-portal:*Billing",
"awsbillingconsole:*Billing",
View flush-redis-telnet.sh
telnet 127.0.0.1 11211
flush_all
quit
@mrgcohen
mrgcohen / MySQL_macOS_Sierra.md
Created Aug 13, 2019 — forked from nrollr/MySQL_macOS_Sierra.md
Install MySQL on Sierra using Homebrew
View MySQL_macOS_Sierra.md

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 Jul 25, 2019 — forked from willshiao/aes.go
AES 256-CFB in Node.js, Go, and Python
View aes.go
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 Jul 17, 2019
Export db query to file through stdout postgres
View export-db-query-to-file.sh
psql -h host -U username dbname -c "copy (select * from table) TO STDOUT WITH CSV" >> data.csv
@mrgcohen
mrgcohen / multipart.swift
Created Sep 6, 2018 — forked from DejanEnspyra/multipart.swift
Alamofire 4 — Multipart file upload with Swift 3 (http://theappspace.com/multipart-file-upload/)
View multipart.swift
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 Aug 27, 2018 — forked from mindriot101/python_pymysql_notes.md
Notes about pymysql connections
View python_pymysql_notes.md

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 Jul 20, 2018 — forked from twolfson/README.md
Audit logging via sequelize
View README.md

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 Mar 25, 2021
Postgres to elasticsearch
View postgres-to-elastic-search.md

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 Mar 30, 2018 — forked from DavidWells/serverless.yml
DynamoDB custom index serverless.yml example
View serverless.yml
service: service-name
provider:
name: aws
runtime: nodejs6.10
functions:
myfunc:
handler: handler.myfunc