Skip to content

Instantly share code, notes, and snippets.

@pquery
pquery / build.sbt
Created July 12, 2016 13:08
Simple Build File for SBT
lazy val root = (project in file(".")).
settings(
name := "helloWorld",
version := "0.1",
scalaVersion := "2.10.6"
)
libraryDependencies ++= Seq(
"com.github.seratch" %% "awscala" % "0.5.+",
"org.scalatest" % "scalatest_2.10" % "2.2.6" % "test",
@pquery
pquery / autoOff.py
Created June 16, 2016 13:36
AWS Python Lambda to automatically turn off instances
import boto3
import botocore
import logging
import requests
# setup simple logging for INFO
logging.basicConfig()
logger = logging.getLogger()
logger.setLevel(logging.INFO)
@pquery
pquery / base_controller.rb
Created June 19, 2015 01:15
API Controller for rails_headlines
module Api
class BaseController < ApplicationController
protect_from_forgery with: :null_session
before_action :set_resource, only: [:destroy, :show, :update]
respond_to :json
private
# Returns the resource from the created instance variable
# @return [Object]
@pquery
pquery / gist:54e0018e9b550c9c899c
Created June 11, 2015 01:19
Initial Headline seed data
## db/seeds.db
#
# Taken from real headlines in 2013
News.create!(title:'Bear Steals Entire Dumpster - Twice', news:'bear story')
News.create!(title:'CarJacker Folied by his own Walker', news:'He couldn\'t make a fast getaway because it took him too long to load his walker into the stolen car!')
News.create!(title:'Giant Purple Chicken Stolen', news:'Three men were arrested in Putnam County, Florida, for stealing a 9-foot-tall purple chicken')
News.create!(title:'Government Agency Smashed Computers to get Rid of Viruses', news:'The destruction not stopped - sparing $3 million of equipment - because the agency had run out of money to pay for destroying the hardware.')
News.create!(title:'Chinese Zoo Displays Dog as Lion', news:'A private zoo in Luohe, Henan province, China, is under fire for trying to pass off a Tibetan mastiff, a particularly hairy dog, as an African lion.')
@pquery
pquery / gist:70394d9fe8036db0918f
Last active August 29, 2015 14:22
Seed data for rental all
# db/seeds.db
# rentals app
Rental.create!(city:'Greenville', state:'SC', price:675, landlord_id:3, email:'rooms@rents.com')
Rental.create!(city:'Greenville', state:'SC', price:875, landlord_id:4, email:'sc_rentals@gmail.com')
Rental.create!(city:'Charleston', state:'SC', price:725, landlord_id:3, email:'sc_properties@yahoo.com')
Rental.create!(city:'Charleston', state:'SC', price:450, landlord_id:2, email:'sc_properties@yahoo.com')
Rental.create!(city:'Greenville', state:'SC', price:500, landlord_id:2, email:'sc_properties@yahoo.com')
@pquery
pquery / checkprocess.sh
Created September 30, 2014 13:45
Checks for a particular process and then sends a binary value to aws cloudwatch
#!/bin/bash
# Checking a custom process and send to
# AWS CloudWatch via a custom metric.
# This can then be complimented with a cloudwatch
# alert and SNS topic.
#
# PreRequisites: You will need to have the
# AWS-CLI installed on the system running this
# script.
# Also the script needs to run as a sudo uses that