Skip to content

Instantly share code, notes, and snippets.

View froi's full-sized avatar

Froilán Irizarry Rivera froi

View GitHub Profile
@froi
froi / fetch_parse_json.js
Created October 19, 2018 03:17
Small snippet to parse json string that could be formatted in utf16le and still be able to consume json strings in utf8
const fetch = require('node-fetch');
const encoding = require('encoding');
fetch('https://open.gsa.gov/code.json')
.then(response => response.buffer())
.then(json => {
let text = {};
if(json.indexOf('\uFEFF', 0, 'utf16le') === 0 ) {
text = encoding.convert(json, 'utf8', 'utf16le');
@froi
froi / manage-lets-encrypt-cert-aws-cloudfront.sh
Last active April 17, 2022 23:40
Script to help manage and install Let's Encrypt cert to Cloudfront
#!/usr/bin/env sh
# This code is based on https://eang.it/letsencrypt-with-amazon-cloudfront/
export AWS_ACCESS_KEY_ID=""
export AWS_SECRET_ACCESS_KEY=""
bucket_name=""
region=""
distribution_id=""
domain=""
@froi
froi / decorators.py
Last active August 25, 2016 17:06
Decorator for DRF to mark a view function as excluded from a list of api versions.
from rest_framework.exceptions import NotFound
def not_available_api_version(excluded_api_versions=None):
def decorator(func):
@wraps(func)
def wrapper(x, request, *args, **kwargs):
if excluded_api_versions and request.version in excluded_api_versions:
raise NotFound(detail=None)
return func(x,request, *args, **kwargs)

Keybase proof

I hereby claim:

  • I am froi on github.
  • I am froi (https://keybase.io/froi) on keybase.
  • I have a public key whose fingerprint is 169B C49E D4F6 2C8C BA1C BBA5 BF18 A8C3 89BF B374

To claim this, I am signing this object:

@froi
froi / init.lua
Last active April 28, 2021 16:11
Hammerspoon config
-- Streaming
hs.hotkey.bind({"alt", "ctrl"}, "S", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x
f.y = max.y
f.w = 1920
@froi
froi / README.md
Last active June 30, 2020 05:12
Simple Python Flask app to demonstrate the use of CORS with Flask-restful
@froi
froi / streamline_your_workflow_with_aliases.md
Last active August 29, 2015 14:03
Building for the Web quick tease.

Streamline your Workflow with Aliases

What are Aliases?

A command that lets you replace a word with another string. This let's you rename anything in your system and even lets you "make your own commands".

Why would I care?

Well if you like writing the same string of commands over and over and you like to see your time just fly by just retyping commands then I suspect that you wouldn't care. But if you're like me and hate this then aliases are for you.

Let's seen some examples so you can see what I mean...

@froi
froi / purge_file_git_repo.md
Last active December 30, 2015 10:59
Purge file from git history. Useful if like me you commit/push sensitive data, aka credentials. Command was copied from the excellent Github article: https://help.github.com/articles/remove-sensitive-data

1. Change into repo folder

cd my-repo

2. Change into branch you want to modify if not already in it

git checkout <branch>

3. Purge the file

This is the nuclear option. Have to be sure this is what is wanted! Substitute with the name of the file you want gone!