Skip to content

Instantly share code, notes, and snippets.

View iMerica's full-sized avatar

Michael iMerica

  • Austin, Texas
View GitHub Profile
@iMerica
iMerica / curl_time.sh
Created April 18, 2019 21:45
Quick and dirty Performance Metrics using only Curl
#!/usr/bin/env bash
# I found this in my ZSH profile and I forgot where I got it from. If you wrote it, Thanks!
curl -so /dev/null -w " namelookup: %{time_namelookup}s\n connect: %{time_connect}s\n appconnect: %{time_appconnect}s\n pretransfer: %{time_pretransfer}s\n redirect: %{time_redirect}s\nstarttransfer: %{time_starttransfer}s\n-------------------------\n total: %{time_total}s\n" "$@"
@iMerica
iMerica / README.md
Last active April 2, 2019 01:45
A Pattern for Auth based Routing using Redux, React Router

A Pattern for Auth based Routing using Redux, React Router

Assumptions

  • Token based authentication or JWT. This one is good for Django Rest Authentification.
  • The first line of defense in protecting sensitive data is your REST API and its auth system, not your React SPA. This solution is just for intelligent routing, not protecting sensitive data.
  • Redux or equivalent state management framework that allows you to easily connect components to a single source of truth state.

Summary

If you're familiar with the React concept of "lifting state up",

@iMerica
iMerica / fizz-buzz.sh
Last active December 20, 2018 23:09
CLI Fizz Buzz One Liner
#!/usr/bin/env bash
# MIT License
# Copyright (c) 2018 @iMerica (Michael)
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
@iMerica
iMerica / functional-utils.js
Created December 11, 2018 18:25 — forked from bendc/functional-utils.js
A set of pure ES2015 functions aimed to make functional JavaScript more idiomatic.
// array utils
// =================================================================================================
const combine = (...arrays) => [].concat(...arrays);
const compact = arr => arr.filter(Boolean);
const contains = (() => Array.prototype.includes
? (arr, value) => arr.includes(value)
: (arr, value) => arr.some(el => el === value)
@iMerica
iMerica / authentication.py
Last active September 7, 2018 00:27
Custom Auth for Django/DRF that allows for multiple API Tokens per user.
from rest_framework.authentication import TokenAuthentication
from .models import RESTAPIToken
class CustomRestAPIAuthentication(TokenAuthentication):
""" Custom Authentication """
def get_model(self):
return RESTAPIToken
@iMerica
iMerica / identify_focus_issue.py
Created February 11, 2014 02:59
Identify which app or process is stealing focus on OSX
#!/usr/bin/python
from AppKit import NSWorkspace
import time
t = range(1,100)
for i in t:
time.sleep(3)
activeAppName = NSWorkspace.sharedWorkspace().activeApplication()['NSApplicationName']
print activeAppName
@iMerica
iMerica / filter.js
Last active July 30, 2018 06:35
Work At A Startup Job Filter
const findJobs = (remote, min_salary) => {
return window.TOP_LEVEL_PROPS.companies.filter(
company => company.jobs.filter(
job => ((job.remote_ok === remote) && (job.salary_max >= min_salary))
).length > 0
)
}
@iMerica
iMerica / job_offer_decider.py
Created July 20, 2018 15:29
Job Offer Decision Making Framework
from dataclasses import dataclass
from typing import Sequence
""""
This is a proof of concept framework for selecting job offers.
The general idea is to remove emotions from the decision
making process and first think about whats important to you, then
compare each offer against those factors.
@iMerica
iMerica / .gitlab-ci.yml
Last active July 18, 2018 23:18
Automated Deployments of Create React Apps to Cloudfront using Scotty JS.
image: docker:latest
services:
- docker:dind
stages:
- build
- push
- deploy
@iMerica
iMerica / .gitlab-ci.yml
Created June 15, 2018 01:13
Docker based Gitlab CI workflow for Django
image: docker:latest
services:
- docker:dind
stages:
- build
- test
- push