Skip to content

Instantly share code, notes, and snippets.

View josephpconley's full-sized avatar

Joe Conley josephpconley

View GitHub Profile
@josephpconley
josephpconley / README.md
Last active December 8, 2019 16:11 — forked from mfullen/buysideAnswers.py
Please review the README.md for instructions on completing and submitting your codetest

Please fill out buysideAnswers.py so that all the tests in buyside_test.py pass. Submit your entire project zipped via email or provide a link to a Github repo. Please provide instructions on how to run in a README.md, with any additional comments or feedback.

Thanks!

@josephpconley
josephpconley / HadoopWordCount.scala
Created October 9, 2015 15:06
Spark code for following word count text: Betty Botta bought some butter; "But," said she, "this butter's bitter! If I put it in my batter It will make my batter bitter. But a bit o' better butter Will but make my batter better." Then she bought a bit o' butter Better than the bitter butter, Made her bitter batter better. So 'twas better Betty B…
sc.textFile("hdfs://localhost/jconley/input/wc.txt").flatMap(_.trim.split("""[\s\W]+""")).map(w => w -> 1).reduceByKey(_ + _).sortBy(_._2, ascending = false).foreach(println)
@josephpconley
josephpconley / CI
Last active August 29, 2015 14:14
DIY Continuous Integration - Save this script in DataCombinator and create a repo webhook in Github pointing to that script's POST url (populate variables based on your host info)
api(post, https://api.github.com/repos/{{repository.full_name}}/statuses/{{after}}, 4,
{"state": "pending"}
);
ssh(<host>, <user>, <pass>,
"cd {{repository.name}} && git fetch origin && git checkout {{after}} && sbt test"
);
if(this.exitCode == 0,
api(post, https://api.github.com/repos/{{_.0.repository.full_name}}/statuses/{{_.0.after}}, 4,
{"state": "success"}
),
ws(get, https://maps.googleapis.com/maps/api/geocode/json?address={{urlEncode "3401 Market St., Philadelphia, PA 19104"}});
this.body.results[0].geometry.location;
ws(get, "https://api.forecast.io/forecast/<apiKey>/{{lat}}, {{lng}}");
if(this.body.currently.temperature < 40, sms(<joe_cell_num>, "Bring a coat Joe!"));
ws(get, http://www.swingstats.com);
mongo(<host>, <user>, <pass>, "swingstats", "save", this);
if(_.1.status != 200, email(joe.conley@swingstats.com, joe.conley@swingstats.com, "SITE IS DOWN"));
ws(get, http://www.avclub.com/tv/game-of-thrones-experts/).body;
xpath(this, //section[@class='article-list']).section;
tmpl(
<rss version="2.0">
<channel>
<title>AV Club Reviews for Game of Thrones (experts)</title>
<description>AV Club Reviews for Game of Thrones (experts)</description>
{{#article}}
<item>
<title>{{div.h1.title}}</title>
/**
* User: jconley
* Date: 7/14/2014
*/
trait Db {
def name: String
}
class MySQLDb extends Db {
val name = "MySQL"
}
@josephpconley
josephpconley / photos.js
Last active August 29, 2015 14:04
Programmatically click on several links using jquery/javascript
$("a[href^='freedownload']").each(function(a){
window.open($(this).attr("href"));
});
@josephpconley
josephpconley / bookstore.sc
Last active August 29, 2015 13:59
Scala worksheet for play-jsonpath library
//Scala worksheet
import com.josephpconley.jsonpath.JSONPath
import play.api.libs.json.Json
val store = Json.parse("""{"store":{"book":[{"category":"reference","author":"Nigel Rees","title":"Sayings of the Century","price":8.95},{"category":"fiction","author":"Evelyn Waugh","title":"Sword of Honour","price":12.99},{"category":"fiction","author":"Herman Melville","title":"Moby Dick","isbn":"0-553-21311-3","price":8.99},{"category":"fiction","author":"J. R. R. Tolkien","title":"The Lord of the Rings","isbn":"0-395-19395-8","price":22.99}],"bicycle":{"color":"red","price":19.95}}}""")
JSONPath.query("$.store.book[*].author", store)
JSONPath.query("$..author", store)
JSONPath.query("$.store.*", store)
JSONPath.query("$.store..price", store)
JSONPath.query("$..book[2]", store)
object MetaDataFilter extends EssentialFilter{
def apply(next: EssentialAction) = new EssentialAction {
def apply(rh: RequestHeader): Iteratee[Array[Byte], Result] = {
val timeStart = System.currentTimeMillis
def bodyToStr: Enumeratee[Any, String] = Enumeratee.map(s => s.toString)
def addMetadata(result: PlainResult): Result = {
val timeElapsed = System.currentTimeMillis - timeStart
result match {