Skip to content

Instantly share code, notes, and snippets.

@dsoike
dsoike / deploy-to-aws-s3.js
Created April 12, 2019 21:18
Deploy Static Website to AWS S3
const AWS = require('aws-sdk')
const fs = require('fs')
const path = require('path')
const mime = require('mime')
const chalk = require('chalk')
const s3 = new AWS.S3()
const s3Bucket = 'my-s3-bucket.com'
const directoryName = 'build'
@dsoike
dsoike / custom_sort.py
Created March 20, 2019 20:01
Custom Sort Function in Python
# sort things by highest priority & lowest time
thing1 = {'id': 1, 'priority': 1, 'time': 500}
thing2 = {'id': 2, 'priority': 5, 'time': 400}
thing3 = {'id': 3, 'priority': 5, 'time': 600}
thing4 = {'id': 4, 'priority': 10, 'time': 100}
things = [thing1, thing2, thing3, thing4]
def sort_things(thing1, thing2):
if thing1['priority'] > thing2['priority']:
@dsoike
dsoike / release.js
Created March 6, 2019 18:15
Release Script
const chalk = require('chalk')
const exec = require('child_process').exec
const fs = require('fs')
const readline = require('readline')
const spawn = require('child_process').spawn
const repoName = 'MyRepo'
const repoUrl = `https://github.com/MyOrg/${repoName}`
const checkMark = chalk.green('\u2713')
@dsoike
dsoike / run_unit_tests.py
Created March 5, 2019 20:47
Run Python Unit Tests
import os
import sys
import imp
import inspect
import re
import unittest
PWD = os.environ.get('PWD')
@dsoike
dsoike / MyTabBarController.swift
Last active March 7, 2023 07:57
Swift UITabBarController with Custom Transition Animation
import UIKit
class MyTabBarController: UITabBarController {
override func viewDidLoad() {
super.viewDidLoad()
delegate = self
}
}
@dsoike
dsoike / otto-server.conf
Last active June 19, 2017 20:51
Upstart Script for Otto Server
# Upstart Script for Otto Server
# - file location: /etc/init/otto-server.conf
description "otto-server"
start on started mountall
stop on shutdown
# Automatically Respawn
respawn
@dsoike
dsoike / CustomEnum.java
Created May 15, 2017 19:51
Custom Enum - Android/Java
package com.my_domain.app_name;
/**
* Custom Enumeration
* - Custom implementation enables overriding an enum's value.
* - http://stackoverflow.com/questions/9662170/override-valueof-and-tostring-in-java-enum
*/
public enum CustomEnum {
// ---------------------------------------------------------------------------------------------