Skip to content

Instantly share code, notes, and snippets.

nmccready nmccready

Block or report user

Report or block nmccready

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@nmccready
nmccready / email-via-scala-ProcessBuilder.scala
Last active Mar 6, 2018
Cool way to send email via Scala executing bash / shell.
View email-via-scala-ProcessBuilder.scala
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) !
View lamda_locust.py
from locust import Locust, TaskSet
urls = ["someurl1", "someurl2"]
lamda_set = {}
for url in urls:
lamda_set[lambda l: l.client.get(url)] = 1
View RandomUrlGenerator.py
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
start script to kick off a master and then slaves via ssh across multiple machines
View start_locust
#!/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
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.
View init_d_logg
#!/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 Jun 7, 2013
Convert Ning AsyncHandler to Scala Future with AsyncHttpClient
View Java Future to Scala Future in Ning
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 Jun 7, 2013
HttpClient interface with multiple implementations Akka to use a TestActorRef, Spray and Ning
View gist:5730187
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)
View polling_lsof.sh
while (1) { toEcho=$(lsof -i:16868 | grep 16868); echo $toEcho; sleep 1 }
@nmccready
nmccready / find_awk.sh
Created Jun 25, 2013
find and awk combination to search for a file
View find_awk.sh
find . -name "*.pid" -print -exec awk '$9 != "" && n < 10 {print; n++}' {} \;
View 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
You can’t perform that action at this time.