Skip to content

Instantly share code, notes, and snippets.

View README.md

Rough cert-manager GKE install instructions:

export PROJECT_ID="cert-manager-$(openssl rand -hex 6)"
export EMAIL=abe@abevoelker.com

gcloud projects create --set-as-default $PROJECT_ID
gcloud compute addresses create ipv4-address --global --ip-version IPV4
gcloud services enable compute.googleapis.com
gcloud services enable container.googleapis.com
@abevoelker
abevoelker / one_signal.rb
Last active Aug 7, 2018
OneSignal Ruby notifications
View one_signal.rb
require "typhoeus"
class OneSignal
class << self
[:app_id, :api_key, :timeout, :connecttimeout].each do |opt|
define_method(:"#{opt}=") {|val| instance_variable_set(:"@#{opt}", val)}
define_method(opt) { begin; instance_variable_get(:"@#{opt}"); rescue NameError; nil; end }
end
end
View neat postgres topics.md
  • Constraints - super important for ensuring data integrity (bad data can't get into the DB)

  • Indexes - i

@abevoelker
abevoelker / TypeFamily.hs
Created Jan 8, 2016 — forked from deech/TypeFamily.hs
Searching a type level list using typeclasses vs. closed type families.
View TypeFamily.hs
{-
This code shows how to check if a type-level list contains a given type.
It first shows the approach required for older versions of GHC (< 7.6.x)
and then a version using closed type families supported in GHC 7.8.1 and greater.
-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
View SSLCommunications.scala
import java.security._
import java.net.URL
import javax.net.ssl.{KeyManagerFactory, TrustManagerFactory}
import org.apache.http.conn.ssl.SSLSocketFactory
import org.apache.http.conn.scheme.Scheme
import dispatch._
// Gist trait for doing SSL with mutual certificate exchange using dispatch.
// This works without having to set up global JDK-wide keystore and truststore files.
//
View algebraic_data_type.hs
data Tree = Empty
| Leaf Int
| Node Tree Tree
View fun with scala
scala> val scores = Map("a" -> 100, "b" -> 101)
scores: scala.collection.immutable.Map[String,Int] = Map(a -> 100, b -> 101)
scala> scores.filter { case (_, i) => i > 100 }
java.lang.AssertionError: assertion failed: List(value _2$mcI$sp, value _2$mcI$sp, value _2$mcI$sp, value _2$mcI$sp, value _2$mcI$sp, value _2$mcI$sp, value _2$mcI$sp, value _2$mcI$sp, value _2$mcI$sp, value _2$mcI$sp, value _2$mcI$sp, value _2$mcI$sp, value _2$mcI$sp, value _2$mcI$sp, value _2$mcI$sp, value _2$mcI$sp, value _2$mcI$sp, value _2$mcI$sp, value _2$mcI$sp, value _2$mcI$sp, value _2$mcI$sp, value _2$mcI$sp, value _2$mcI$sp, value _2$mcI$sp, value _2$mcI$sp, value _2$mcI$sp, value _2$mcI$sp, value _2$mcI$sp, value _2$mcI$sp, value _2$mcI$sp, value _2$mcI$sp, value _2$mcI$sp, value _2$mcI$sp, value _2$mcI$sp, value _2$mcI$sp, value _2$mcI$sp)
at scala.reflect.internal.Symbols$Symbol.suchThat(Symbols.scala:1916)
at scala.tools.nsc.transform.SpecializeTypes$$anon$2.matchingSymbolInPrefix$1(SpecializeTypes.scala:1460)
at scala.t
View gist:d39802b42b602762fe2a
### Keybase proof
I hereby claim:
* I am abevoelker on github.
* I am abevoelker (https://keybase.io/abevoelker) on keybase.
* I have a public key whose fingerprint is 7C75 A5F5 E608 E133 4314 7A24 65A8 0811 BC6A 8D92
To claim this, I am signing this object:
View rails_annoyance.md

How annoying is it that Rails doesn't do what you tell it, but tries to be smart? Trying to use custom DB logic in a Rails migration:

create_table :foos do |t|
  t.timestamp :inserted_time, null: false, default: 'now()'
end

Results in this:

View haproxy.cfg
# This is an example of the Stack Exchange Tier 1 HAProxy config
# The only things that have been changed from what we are running are:
# 1. User names have been removed
# 2. All Passwords have been remove
# 3. IPs have been changed to use the example/documentation ranges
# 4. Rate limit numbers have been changed to randome numbers, don't read into them
userlist stats-auth
group admin users $admin_user
user $admin_user insecure-password $some_password