Skip to content

Instantly share code, notes, and snippets.

View nmccready's full-sized avatar

nmccready nmccready

View GitHub Profile
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 = ","
//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 /
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 / start_locust
Created May 9, 2013 13:32
start script to kick off a master and then slaves via ssh across multiple machines
#start script to kick off a master and then slaves via ssh across multiple machines
SLAVE_CMD="nohup locust -f /opt/swarm//app1/ --slave --host=http://someurlToHammer:9000 &>/dev/null &"
MASTER_CMD="nohup locust -f /opt/swarm/app1/ --master --host=http://someurlToHammer:9000 &>/dev/null &"
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.
. /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 / 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 / gist:5730187
Created June 7, 2013 15:37
HttpClient interface with multiple implementations Akka to use a TestActorRef, Spray and Ning
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 /
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 /
Created September 27, 2013 13:25 — forked from runlevel5/
#!/usr/bin/env bash
# Simple move this file into your Rails `script` folder. Also make sure you `chmod +x`.
# Please modify the CONSTANT variables to fit your configurations.
# The script will start with config set by $PUMA_CONFIG_FILE by default