Skip to content

Instantly share code, notes, and snippets.

Cameron Hotchkies cameronhotchkies

Block or report user

Report or block cameronhotchkies

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
@cameronhotchkies
cameronhotchkies / alphavantage_sample.py
Created Aug 5, 2019
Simple python script for alphavantage API
View alphavantage_sample.py
#!/usr/bin/env python3
import urllib.request
import urllib.parse
import json
api_key = 'demo'
ticker = 'MSFT'
View keybase.md

Keybase proof

I hereby claim:

  • I am cameronhotchkies on github.
  • I am chotchkies (https://keybase.io/chotchkies) on keybase.
  • I have a public key ASBwcIFwwOHKaDwzi20fYJ7PyirAdi_mBRv7dplUaEzbWAo

To claim this, I am signing this object:

@cameronhotchkies
cameronhotchkies / HappySequence.scala
Created Jun 19, 2015
Like Future.sequence but discards all Future.failure results
View HappySequence.scala
def happySequence[A](source: Seq[Future[A]]) = {
val optioned = source.map { f =>
f.map(Option.apply).recover {
case _ => None
}
}
Future.sequence(optioned).map(_.flatten)
View SlickMapping3.scala
import org.joda.time.DateTime
import play.api.db.slick.DatabaseConfigProvider
import slick.driver.JdbcProfile
import play.api.Play.current
object SlickMapping {
protected val dbConfig = DatabaseConfigProvider.get[JdbcProfile](current)
import dbConfig._
import dbConfig.driver.api._
@cameronhotchkies
cameronhotchkies / SlickMapping.scala
Created Jun 3, 2015
Common Joda DateTime Mapping
View SlickMapping.scala
import play.api.db.slick.Config.driver.simple._
import org.joda.time.DateTime
import java.sql.Timestamp
object SlickMapping {
implicit def jodaDateTimeMapping =
MappedColumnType.base[DateTime, Timestamp](
dt => new Timestamp(dt.getMillis),
ts => new DateTime(ts.getTime))
}
View Md4Digest.scala
package com.semisafe.cryptopals
/*
* Implementation of MD4 in pure Scala
*
* derived from the RSA Data Security, Inc. MD4
* Message-Digest Algorithm (http://tools.ietf.org/html/rfc1320)
*
* This was implemented as part of the Matasano Crypto Challenges
* http://www.matasano.com/articles/crypto-challenges/
View Sha1Digest.scala
package com.semisafe.cryptopals
/*
* Implementation of SHA-1 in pure Scala
*
* This was implemented as part of the Matasano Crypto Challenges
* http://www.matasano.com/articles/crypto-challenges/
*
* Having a native implementation of SHA-1 is required for the
* fourth set of challenges, building your own isn't, so feel
@cameronhotchkies
cameronhotchkies / gist:5620426
Created May 21, 2013
Why you shouldn't go back and forth on UTF-8 strings for binary data
View gist:5620426
// Run in a REPL
val bl : List[Byte] = List(-78,-5,-112,-31,127,-59,1,94,12,7,84,112,82,41,-95,50)
val ba = bl.toArray
val bs = new String(ba, "UTF-8")
bl.length
ba.length
bs.length
// Notice they aren't all equal
You can’t perform that action at this time.