Skip to content

Instantly share code, notes, and snippets.

View kaeawc's full-sized avatar
🤓
Probably coding

Jason Pearson kaeawc

🤓
Probably coding
View GitHub Profile

#Performing Overlapping Data Migration in MySQL

This example will assume a really simple schema -- users and messages.

CREATE DATABASE data_1;
CREATE DATABASE data_2;

USE data_1;

DROP TABLE IF EXISTS users;

@kaeawc
kaeawc / PlayScalaReturns.scala
Last active December 18, 2015 22:09
Example of using returns in Scala inside a Play! controller action
package controllers
import play.api._
import play.api.mvc._
object Application extends Controller {
def doStuff:Result = {
if (1 != 1) return InternalServerError("Whoa shit")
@kaeawc
kaeawc / PlayScalaJsArray.scala
Last active December 18, 2015 22:09
Play! Scala code demonstrating folding left on a model that is using imperative JSON to create a JavaScript array
import java.util.Date
import play.api.libs.json._
case class Event(name:String,when:Date) extends JsSerializable
object Event extends ((String,Date) => Event) {
implicit val r = Json.reads[Event]()
implicit val w = Json.writes[Event]()
}
@kaeawc
kaeawc / signed_web_request.sh
Created August 25, 2013 19:38
Starting as a nonuser, I sign up for an account at https://www.somewebservice.com https://www.somewebservice.com gives me public and private keys https://www.somewebservice.com generates completely random strings and stores them for user I keep keys in a secure place (not committed in code)
DATA_TO_SIGN = SOME_DATA + PRIVATE_API_KEY
md5 -s "DATA_TO_SIGN"
curl "https://www.somewebservice.com/api/v1/getAwesomeStuff" --data "API_KEY=YOUR_PUBLIC_API_KEY&signature=CALCULATED_SIGNATURE"
@kaeawc
kaeawc / storm-kafka-notes.md
Last active December 21, 2015 18:29
Notes from Storm + Kafka meetup on 08/26/2013

Storm Overview

What are the parts?

A Spout takes some input and decides whether or not that input is worth passing on based on some logic.

Bolts do some intensive operation on a given data, which might be composed together.

creating a spout means just extending BasicSpout

@kaeawc
kaeawc / gist:ea40f7efc3b46ace2794
Created September 16, 2014 16:20
Using subqueries and aliases to create aggregations
SELECT COUNT(a.asdf) as count_of_asdfs FROM (SELECT 2 as asdf ) as a JOIN (SELECT 3 as fdsa) as b ON b.fdsa=3 GROUP BY b.fdsa;
### Keybase proof
I hereby claim:
* I am kaeawc on github.
* I am kaeawc (https://keybase.io/kaeawc) on keybase.
* I have a public key whose fingerprint is 6E7A 3856 CF66 FF0B 848B 723A 3150 F227 277B B2D8
To claim this, I am signing this object:
@kaeawc
kaeawc / decode.sh
Last active September 18, 2020 15:01
Decode base64-encoded gzipped tar file
base64 -D thefile | tar -xz
@kaeawc
kaeawc / mailchimp_subscribe_example.py
Last active August 29, 2015 14:09
Mailchimp Subscription
apikey = 'you_api_key'
list_id = 'your_list_id'
from mailchimp import Mailchimp
mailchimp = Mailchimp(apikey=apikey)
mailchimp.lists.subscribe(id=list_id, email={u"email",u"youremailaddress+testingmailchimp@yourcompany.com"})
mandrill.messages.send_template(template_name='welcome-new-user', template_content=[], message={'to':[{'email': 'kaeawc.farore@gmail.com'}]}, send_at=future_time)
# [{u'_id': u'ae905120f7194c1fb6d9e529db3fc353',
# u'email': u'kaeawc.farore@gmail.com',
# u'reject_reason': None,
# u'status': u'scheduled'}]
mandrill.messages.list_scheduled(to='kaeawc.farore@gmail.com')
# [{u'_id': u'ae905120f7194c1fb6d9e529db3fc353',