Skip to content

Instantly share code, notes, and snippets.

View nmccready's full-sized avatar

nmccready nmccready

View GitHub Profile
@nmccready
nmccready / email-via-scala-ProcessBuilder.scala
Last active March 6, 2018 08:52
Cool way to send email via Scala executing bash / shell.
import sys.process._
val body = "junk email body"
val subject = "test email subject"
val commaDelimitedEmails = "test1@gmail.com,test2@gmail.com"
//goal is to execute the same bash command without loading a file
//script would be identical to: echo body | mail -s subject addresses
Seq("echo", body) #| Seq("mail", "-s %s".format(subject), commaDelimitedEmails) !
@nmccready
nmccready / lamda_locust.py
Created May 3, 2013 13:37
locust via lamda?
from locust import Locust, TaskSet
urls = ["someurl1", "someurl2"]
lamda_set = {}
for url in urls:
lamda_set[lambda l: l.client.get(url)] = 1
import sys
import simplejson
import requests
import random
from urllib import quote
# pass in a single argument of a url that returns a json list of urls [ "url1","url2"]
def main(argv):
@nmccready
nmccready / start_locust
Created May 9, 2013 13:32
start script to kick off a master and then slaves via ssh across multiple machines
#!/bin/bash
#start script to kick off a master and then slaves via ssh across multiple machines
RUN_AS=${1:-$(whoami)}
SLAVE_CMD="nohup locust -f /opt/swarm//app1/some_locust_script.py --slave --master-host=testbox1.locust.com --host=http://someurlToHammer:9000 &>/dev/null &"
MASTER_CMD="nohup locust -f /opt/swarm/app1/some_locust_script.py --master --host=http://someurlToHammer:9000 &>/dev/null &"
start_instances()
{
@nmccready
nmccready / init_d_logg
Created May 16, 2013 03:52
Showing the possibilities of having a log friendly init.d script. At the same time this script still shows instant output as well if run directly. Overrides default echo and functions success and failure.
#!/bin/sh
. /etc/init.d/functions
successVar="-ne \t\t\t\t\t[ \033[32mOK\033[0m ]\n"
failureVar="-ne \t\t\t\t\t[ \033[31mFailed\033[0m ]\n"
function success(){
echo $successVar
}
function failure(){
echo $failureVar
@nmccready
nmccready / Java Future to Scala Future in Ning
Created June 7, 2013 13:48
Convert Ning AsyncHandler to Scala Future with AsyncHttpClient
trait IHttpClient[T] {
def host: String
def port: Int
def get(uri: String): Future[T]
}
trait NingHttpClient extends IHttpClient[Response] {
@nmccready
nmccready / gist:5730187
Created June 7, 2013 15:37
HttpClient interface with multiple implementations Akka to use a TestActorRef, Spray and Ning
import akka.actor._
import scala.concurrent.duration._
import scala.concurrent.Future
import spray.http._
import spray.can.client._
trait SprayHttpClient extends IHttpClient[HttpResponse] {
val httpClient = DefaultHttpClient(system)
while (1) { toEcho=$(lsof -i:16868 | grep 16868); echo $toEcho; sleep 1 }
@nmccready
nmccready / find_awk.sh
Created June 25, 2013 11:52
find and awk combination to search for a file
find . -name "*.pid" -print -exec awk '$9 != "" && n < 10 {print; n++}' {} \;
@nmccready
nmccready / puma.sh
Created September 27, 2013 13:25 — forked from runlevel5/puma.sh
#!/usr/bin/env bash
# Simple move this file into your Rails `script` folder. Also make sure you `chmod +x puma.sh`.
# Please modify the CONSTANT variables to fit your configurations.
# The script will start with config set by $PUMA_CONFIG_FILE by default
PUMA_CONFIG_FILE=config/puma.rb
PUMA_PID_FILE=tmp/pids/puma.pid
PUMA_SOCKET=tmp/sockets/puma.sock