Skip to content

Instantly share code, notes, and snippets.

Avatar

Chris Frohoff frohoff

View GitHub Profile
@telent
telent / gist:9742059
Last active May 13, 2023 10:52
12 factor app configuration vs leaking environment variables
View gist:9742059
App configuration in environment variables: for and against
For (some of these as per the 12 factor principles)
1) they are are easy to change between deploys without changing any code
2) unlike config files, there is little chance of them being checked
into the code repo accidentally
3) unlike custom config files, or other config mechanisms such as Java
@erickok
erickok / SelfSignedCrtCertificate.java
Last active May 11, 2023 14:25
Loading a self-signed SSL certificate .crt file and packaging it into a SSLSocketFactory for use with a HttpsURLConnection.
View SelfSignedCrtCertificate.java
// Usage example...
HttpsURLConnection connection = (HttpsURLConnection) new URL("https://someurl.com").openConnection();
connection.setSSLSocketFactory(buildSslSocketFactory());
private static SSLSocketFactory buildSslSocketFactory(Context context) {
// Add support for self-signed (local) SSL certificates
// Based on http://developer.android.com/training/articles/security-ssl.html#UnknownCa
try {
@P7h
P7h / jdk_download.sh
Last active January 19, 2023 07:22
Script to download JDK / JRE / Java binaries from Oracle website from terminal / shell / command line / command prompt
View jdk_download.sh
##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### #####
### Shell script to download Oracle JDK / JRE / Java binaries from Oracle website using terminal / command / shell prompt using wget.
### You can download all the binaries one-shot by just giving the BASE_URL.
### Script might be useful if you need Oracle JDK on Amazon EC2 env.
### Script is updated for every JDK release.
### Features:-
# 1. Resumes a broken / interrupted [previous] download, if any.
# 2. Renames the file to a proper name with including platform info.
@n0ts
n0ts / get_oracle_jdk_x64.sh
Last active June 14, 2021 23:05
Get latest Oracle JDK package bash shell script for linux/osx/windows
View get_oracle_jdk_x64.sh
#!/bin/bash
# You must accept the Oracle JDK License Update
# https://www.oracle.com/java/technologies/javase-downloads.html
# usage: get_oracle_jdk_x64.sh <jdk_version> <platform> <ext>
# jdk_version: 14
# platform: linux or osx or windows
# ext: rpm or dmg or tar.gz or exec
jdk_version=${1:-14}
@eirnym
eirnym / sqlalchemy_exists_patch.py
Last active March 23, 2021 18:32
SQLAlchemy 'if exists' patch
View sqlalchemy_exists_patch.py
import re
from sqlalchemy.ext.compiler import compiles
from sqlalchemy.schema import CreateTable, DropTable, \
CreateSequence, DropSequence, CreateIndex, DropIndex
from sqlalchemy.dialects.postgresql import DropEnumType
patches = (
(CreateTable, 'visit_create_table', "^\s*CREATE TABLE", "CREATE TABLE IF NOT EXISTS"),
(CreateIndex, 'visit_create_index', "^\s*CREATE INDEX", "CREATE INDEX IF NOT EXISTS"),
@brikis98
brikis98 / Cache.scala
Last active February 1, 2021 05:24
A quick hack to wrap Java's ConcurrentHashMap with a slightly more scala-friendly API. Scala's built-in ConcurrentMap does the same thing, but its getOrElseUpdate is NOT atomic. Hopefully, the getOrElseUpdate in the version below works correctly :)
View Cache.scala
package com.linkedin.playplugins.common.util
import Cache._
import play.api.Configuration
import java.util.concurrent.ConcurrentHashMap
import collection.JavaConverters._
/**
* A Scala wrapper for a Java's ConcurrentHashMap (CHM). Exposes the basic underlying methods of CHM and adds a
* getOrElseUpdate(key, value) method that lazily evaluates the value parameter only if the key is not already present
@viktorklang
viktorklang / InterruptibleCancellableFuture.scala
Last active June 1, 2020 13:45
Interruptible-Cancellable-scala.concurrent.Future
View InterruptibleCancellableFuture.scala
/*
Copyright 2018 Viktor Klang
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@arschles
arschles / scalaConcurrentPatterns.scala
Last active August 23, 2018 15:00
examples of common concurrency patterns that you can achieve with the scala.concurrent package
View scalaConcurrentPatterns.scala
import scala.concurrent._
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext.Implicits.global
import scala.util.Random
import java.util.{Timer, TimerTask}
object Util {
sealed trait BaseResponse
case class Response1(res: Int) extends BaseResponse
case class Response2(res: String) extends BaseResponse
@andrewconner
andrewconner / FutureGoodies.scala
Last active May 4, 2016 11:34
SafeFuture, TimeoutFuture, CancelableFuture implementations. See https://eng.42go.com/future-safefuture-timeout-cancelable for further explanation.Thanks to @bretthoerner for spotting an error!
View FutureGoodies.scala
/* We've run into a few common pitfalls when dealing with Futures in Scala, so I wrote these three helpful
* classes to give some baked-in functionality.
*
* I'd love to hear about other helpers you're using like these, or if you have improvement suggestions.
* github@andrewconner.org / @connerdelights
*/
import scala.concurrent.{ExecutionContext, CanAwait, Awaitable, Future, Promise}
import scala.concurrent.duration.Duration
import scala.util.Try