View mass_alarms.rb
require 'rubygems'
require 'aws-sdk'
puts "\nLoading instances..."
if File.exist?('instances.yaml')
instances_by_id = YAML.load_file('instances.yaml')
puts "Loaded %d instances from instances.yaml" % [instances_by_id.count]
else
instances_by_id = Hash.new
ec2 = AWS::EC2.new
View gist:2975609
Remove:
touch .hushlogin
Get it back:
rm .hushlogin
View FileAsyncIO.scala
import java.io.IOException
import java.nio.ByteBuffer
import java.nio.channels.{AsynchronousFileChannel, CompletionHandler}
import java.nio.file.Paths
import java.nio.file.StandardOpenOption._
import scala.concurrent.{ExecutionContext, Future, Promise}
import scala.util.Try
/**
View crontab
# Nginx - logrotate & upload to S3
0 0 * * * /usr/sbin/logrotate /etc/logrotate.d/nginx
15 0 * * * s3cmd put /var/log/nginx/access.log-`date +"\%Y\%m\%d"`.gz s3://$LOGS_BUCKET_NAME/nginx-access/`date +"dt=\%Y\%m\%d"`/`hostname -s`.access.log-`date +"\%Y\%m\%d"`.gz
View git-patch.sh
git format-patch HEAD~X --stdout > patch
git apply --stat patch
git apply --reject --whitespace=fix patch
View udfs.scala
import spark.implicits._
import org.apache.spark.sql.functions.udf
import org.apache.spark.sql._
import org.apache.spark.sql.functions._
import org.apache.spark.sql.execution.debug._
val u = udf((a: Int) => a)
val df = spark.sparkContext.parallelize(Seq(0)).toDF("0")
val res = (1 until 20).foldLeft(df) { case (d, i) =>
View RecursionSchemes.scala
package rs
import scala.language.higherKinds
import matryoshka.data._
import matryoshka.implicits._
import scalaz._, Scalaz._
trait Expr[A]
case class NumLit[A](value: Int) extends Expr[A]
View Linux
1.
# vim /etc/sysctl.conf
fs.file-max = 999999
net.ipv4.tcp_rmem = 4096 4096 16777216
net.ipv4.tcp_wmem = 4096 4096 16777216
net.ipv4.ip_local_port_range = 1024 65535
2.
# vim /etc/security/limits.conf
root - nofile 999999
View Id64.scala
import scala.util.Random
import java.security.SecureRandom
import java.util.concurrent.atomic.AtomicLong
import org.joda.time.DateTimeUtils
/**
* 64 bit unique id generator
* Features:
* 1. generate ascending or descending ids
* 2. 64 bit id consists of:
View 01-iptables.config
files:
"/etc/init/eb-docker-iptables.conf":
mode: "000644"
content: |
description "Elastic Beanstalk Default Docker Container Iptables"
author "Matthew Tovbin <mtovbin@salesforce.com>"
start on started docker
stop on stopping docker