Instantly share code, notes, and snippets.

View foo.tf
provider "helm" {
kubernetes {
config_path = "${local_file.kubeconfig.filename}"
}
}
provider "helm" {
kubernetes {
host = "${aws_eks_cluster.eks_master.endpoint}"
cluster_ca_certificate = "${base64decode(aws_eks_cluster.eks_master.certificate_authority.0.data)}"
View ecr.sh
# Simply ensure repo and return url
aws ecr create-repository --repository-name $1 2>/dev/null || true
echo "$(aws ecr describe-repositories --repository-name $1 | jq '.repositories[0].repositoryUri')"
View p.rb
#!/usr/bin/env ruby
# Modifying Float and Integer for fun.
class Float
def whole?
n = self
!!( n % 1 == 0 )
end
end
class Integer
View main.go
package main
import (
"errors"
"fmt"
"io/ioutil"
"net/http"
"os"
)
View restart.rb
fake_rand = `hostname`.hash % 6
if config["STUNNEL_AUTORESTART"]
cron "stunnel-restart cron job" do
command "/sbin/restart stunnel-mod-gearman-worker-ssl"
minute [0, 15, 30, 45].map { |i| fake_rand + i }.join(", ")
mailto "srtools@heroku.com"
user "root"
action :create
end
else
View date_time_fmt.js
var DotW = [ 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Satruday' ];
var MotY = [ 'January', 'Feburary', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ];
var dig2 = function(n) {
if (n > 9) return n.toString();
return "0" + n;
};
var formatDateUtc = function(date) {
var dddd = DotW[date.getUTCDay()];
var MMMM = MotY[date.getUTCMonth()];
View cool.rb
scope :find_by_eamil, ->(email) do
# Search team.
teams = joins(:team).where(teams: { email: email })
return teams unless teams.empty?
# Search user.
joins(:user).where(users: { email: email })
end
View database_url.rb
unless ENV['DATABASE_URL'].present?
# convert current config/database.yml to ENV['DATABASE_URL'] format
c = ActiveRecord::Base.configurations[Rails.env]
database = c["database"]
username = c["username"]
password = c["password"]
adapter = c["adapter"] || "postgres"
hostname = c["host"] || "localhost"
View prun.sh
# run Procfiles without fore{man,go}
function _procline {
local line=""
if test -z "$1"; then
line=`cat Procfile | head -n1 | awk -F': ' '{ print $2 }'`
else
line=`cat Procfile | grep $1 | awk -F': ' '{ print $2 }'`
fi
echo $line
View sri.go
package sri
import (
"crypto/sha256"
"encoding/base64"
"fmt"
"io/ioutil"
)
func Generate256(file string) (string, error) {