Skip to content

Instantly share code, notes, and snippets.

View tylr's full-sized avatar

Tyler Love tylr

View GitHub Profile
@tylr
tylr / get-revision.js
Created July 16, 2016 22:15
ember-cli-deploy integration with dynamodb
import AWS from 'aws-sdk'
import Promise from 'bluebird'
const env = global.env.env
const ddb = new AWS.DynamoDB({ region: 'us-east-1' })
const TableName = global.env.dynamodb.TableName
const revisionPrefix = global.env.revisionPrefix
const revisionEnv = env === 'development' ? 'beta' : env
export default ({ revision = null } = {}) => {
@tylr
tylr / server.js
Last active January 19, 2016 00:15
Running Ember FastBoot in AWS Lambda
var path = require('path');
var FastBootServer = require('./lib/models/server');
var outputPath = 'fastboot-dist';
var appName = 'dummy';
var server = new FastBootServer({
appFile: findAppFile(outputPath, appName),
vendorFile: findVendorFile(outputPath),
htmlFile: findHTMLFile(outputPath)
});
var elasticsearch = require('elasticsearch');
var client = new elasticsearch.Client();
var eventPattern = /([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*) \"(.*?)\" \"(.*?)\" \"(.*?)\" \"(.*?)\" \"(.*?)\"/;
exports.handler = function(data, context) {
var events = [];
var encodedEvent, rawEvent,
matchedEvent, event, i,
commands;
class BustleModel < Ohm::Model
include ActiveModel::Validations
def save
return false unless valid?
super
end
end
class Channel < BustleModel
redis-cli KEYS *rails-cache* | xargs redis-cli DEL
@tylr
tylr / gist:a5ae2c90de0958991bd1
Created July 16, 2014 05:59
Parse Raw Voyager 1 and 2 Pulse Wave Spectrum Analyzer DAT files
require 'pry'
require 'pry-byebug'
require 'date'
require 'json'
def raw_samples
format = 's7c2s16'
samples = []
open('./sample2.dat', 'rb') do |file|
isPortrait = (
imgAspect > windowAspect
|| (
img.naturalWidth > window.innerWidth
&&
img.naturalHeight < window.innerHeight
)
);
@tylr
tylr / gist:7478762
Last active December 28, 2015 09:28
[alias]
st = status
ci = commit
br = branch
co = checkout
df = diff
lg = log -p
[user]
name = Tyler Love
email =
class Base
attr_reader :name, :config
attr_accessor :operations
def initialize(name, opts={})
@name = name
@config = opts
self.operations = {
@tylr
tylr / dropbox_dialect.rb
Created May 30, 2012 22:21
Pidgin interface prototype
# Example of the Dropbox dialect
# DropboxCredentials inherits from Pidgin::Credentials::Base
# it's basically a store for what each dialect needs specifically to access an API
dialect :dropbox, :credentials_class => DropboxCredentials do
# Filter invoked as soon as a conversation is initialized with this dialect
converse do |credentials|
@session = DropboxSession.new(credentials.consumer_token.key, credentials.consumer_token.secret)
@session.set_access_token(credentials.access_token.key, credentials.access_token.secret)