Skip to content

Instantly share code, notes, and snippets.

View MonadicT's full-sized avatar

Praki Prakash MonadicT

  • San Francisco Bay Area
View GitHub Profile
@MonadicT
MonadicT / foo.txt
Created June 20, 2018 03:11
Obtain auth0 token for API
import json
# Get auth0 access token for API
def getAccessToken(connUrl, api_id, client_id, client_secret):
conn = http.client.HTTPSConnection("foobar.auth0.com")
payload = f'''{{"grant_type": "client_credentials",
"client_id": "{client_id}",
"client_secret": "{client_secret}",
"audience": "{api_id}"}}
'''
@MonadicT
MonadicT / foo.txt
Created June 20, 2018 02:41
pg - Accessing Postgres from Python
import psycopg2
import psycopg2.extras
end_point="foobar.baaz.us-west-2.rds.amazonaws.com"
dbname="exampledb"
username="someuser"
password="somepassword"
def getDbConn():
@MonadicT
MonadicT / foo.txt
Created June 20, 2018 02:34
alg - Generate a random string of specified length
def random_string(n):
return ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(n))
#random_string(10)
@MonadicT
MonadicT / foo.txt
Created June 8, 2018 03:04
css - flexbox vertical&horz centering
<div style="background-color:red;height:200px;display:flex;flex-direction: column;align-items:center;justify-content:center">
<div>
Foo
</div>
<div>
BarJar
</div>
</div>
@MonadicT
MonadicT / dev-env.sh
Created May 27, 2018 00:36
tmux dev servers setup
#!/bin/bash
# Setup devlopment environment
tmux new-session -s dev -n servers -d
tmux new-session -s notebook -d
tmux new-session -s webdriver -d
tmux send-keys -t dev 'cd ~/e/evvemi-new-backend-development' C-m
tmux split-window -h -t dev
tmux split-window -v -t dev
@MonadicT
MonadicT / .tmux.conf
Created May 25, 2018 04:25
tmux conf
set -g base-index 1
# remap prefix to Control + a
set -g prefix C-a
# bind 'C-a C-a' to type 'C-a'
bind C-a send-prefix
unbind C-b
# Window spliiting commands
927ce59... 05/22/18 15:44 public Hammerspoon configuration
474b0be... 05/19/18 17:19 public Tikz text along circle
b808c01... 05/19/18 16:44 public Tikz box alignment
2ed760c... 05/19/18 14:08 public Minimal Tikz document
bf1f666... 05/19/18 14:03 public Tikz block diagram
10894297 04/16/14 08:29 public What is this?
9182004 02/23/14 20:33 public
8695437 01/29/14 11:43 public
8681911 01/28/14 20:36 public
8655216 01/27/14 11:01 public
@MonadicT
MonadicT / init.lua
Created May 22, 2018 22:44
Hammerspoon configuration
--
---------------------------------------
-- Hotkeys to launch and focus to apps
-- Hotkey to toggle fullscreen mode
-- Hotkey to toggle Hammerspoon console
---------------------------------------
--
local log = hs.logger.new('mymodule','debug')
local hyper = {"ctrl", "alt", "cmd"}
@MonadicT
MonadicT / minimal.tex
Created May 20, 2018 00:19
tex - Tikz text along circle
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.misc, positioning, backgrounds, fit}
\usetikzlibrary{decorations.text}
\begin{document}
\begin{tikzpicture}[node distance=1 and 1]
\draw (0,0) circle (3cm);
\draw (0,0) [decorate, decoration={text along path,
@MonadicT
MonadicT / minimal.tex
Created May 19, 2018 23:44
tex - Tikz box alignment
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.misc, positioning, backgrounds, fit}
\begin{document}
\begin{tikzpicture}[node distance=1 and 1]
\draw[help lines, very thin] (-1,-3) grid (5, 1);
% Drawing boxes left aligned
\node at (0,0) [rectangle,white,fill=red] (D) {D};