Skip to content

Instantly share code, notes, and snippets.

View iMerica's full-sized avatar

Michael iMerica

  • Austin, Texas
View GitHub Profile
@iMerica
iMerica / urls.py
Last active July 27, 2023 17:20
Email verification in Django Rest Framework, Django All-Auth, Django Rest-Auth. Suitable for Single Page Applications
urlpatterns = [
url(r'^rest-auth/registration/account-confirm-email/(?P<key>[-:\w]+)/$', ConfirmEmailView.as_view(), name='account_confirm_email'),
]
@iMerica
iMerica / viscosity-to-ios-connect.rb
Last active July 5, 2023 21:27 — forked from chrisboulton/viscosity-to-ios-connect.rb
Quickly convert all of your Viscosity connections into OVPN configuration files for OpenVPN for iOS (bundles certificates and keys in the files too)
Dir.glob("#{ENV['HOME']}/Library/Application Support/Viscosity/OpenVPN/*/config.conf").each do |file|
certificate_files = ['ca', 'cert', 'key', 'tls-auth']
config_dir = File.dirname(file)
connection_name = nil
new_config = []
File.read(file).lines.each do |line|
line.strip!
if line.start_with?('#viscosity name')
@iMerica
iMerica / docker-compose.yml
Last active May 28, 2021 18:36
Gitlab Docker Runners
version: '2'
services:
dind:
restart: always
privileged: true
volumes:
- /var/lib/docker
image: docker:18.06.0-ce-dind
command:
- --storage-driver=overlay2
@iMerica
iMerica / Dockerfile
Last active March 4, 2020 20:58
Python 3.8 + Alpine + GDAL
FROM python:3.8.0-alpine
EXPOSE 8000
MAINTAINER "iMichael" <imichael@pm.me>
WORKDIR /app
RUN apk add --no-cache \
--repository http://dl-cdn.alpinelinux.org/alpine/edge/testing \
@iMerica
iMerica / Anchor.jsx
Created January 30, 2020 23:54
Fixes Anchor Focus Issue
import React, { forwardRef, useState, cloneElement, useContext, useEffect } from 'react'
import { normalizeColor } from "grommet/utils/colors"
import { Box, ThemeContext } from "grommet"
import { StyledAnchor } from "grommet/components/Anchor/StyledAnchor"
export const Anchor = forwardRef(
(
{
a11yTitle,
children,
@iMerica
iMerica / Button.jsx
Last active January 30, 2020 23:37
Fixes Grommet Focus Issue
import React, { Children, forwardRef, cloneElement, useContext, useState } from "react";
import { StyledButton } from "grommet/components/Button/StyledButton"
import { colorIsDark, normalizeColor } from "grommet/utils/colors"
import { defaultProps } from "grommet"
import { normalizeBackground } from "grommet/utils/background"
import { ThemeContext } from "grommet"
const Button = forwardRef(
(
{
@iMerica
iMerica / app.jsx
Last active January 13, 2020 22:04
Tabs ++ in Grommet
class App extends Component {
state = {
activeTab: 0,
}
setTab = (i) => {
this.setState({activeTab: i})
}
@iMerica
iMerica / index.js
Created December 28, 2018 21:18
Django/DRF File Uploading to S3
const notifyDjango = (url) => {
// Record the URL of the file you've uploaded along with any data
// that is relevent to you.
}
const uploadToS3 = (file, url) => {
// Upload the file here
// See https://git.io/fhIz5 as a great example of handling all S3 upload edge cases.
}
@iMerica
iMerica / upgrade_pip_packages.py
Last active October 9, 2019 17:17 — forked from serafeimgr/upgrade_pip_packages.py
A python script to upgrade all outdated python packages.
"""
This script upgrades all outdated python packages.
"""
from multiprocessing import Pool, cpu_count
from subprocess import PIPE, Popen
def run_command(command):
"""
@iMerica
iMerica / cache_mixin.py
Last active September 28, 2019 19:07
Michael's Django Cache Mixin for CBVs
from django.views.decorators.cache import cache_page
# MIT License
# Copyright (c) 2019 @iMerica
# 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