Skip to content

Instantly share code, notes, and snippets.

View campeterson's full-sized avatar

Cam Peterson campeterson

View GitHub Profile
@campeterson
campeterson / core.cljs
Last active September 19, 2019 05:10
Send email from Clojure AWS API
;;https://github.com/cognitect-labs/aws-api
(require '[cognitect.aws.client.api :as aws])
(def ses (aws/client {:api :email}))
(aws/ops ses)
(keys (aws/ops ses))
(aws/doc ses :SendEmail)
@campeterson
campeterson / m3u8.sh
Created June 9, 2019 04:32
Download an .m3u8 video with ffmpeg
ffmpeg -protocol_whitelist file,http,https,tcp,tls,crypto -i "<.m3u8 file URL>" -c copy <file_name>.mp4
@campeterson
campeterson / gist:9422175
Last active August 29, 2015 13:57
Setup Server for Data Workflow

Install Git

  sudo yum install git

Install JVM

  yum install java-1.7.0-openjdk

Install Leiningen

mkdir bin

response = $.getJSON("/pcr.json");
data = JSON.parse(response.responseText);
newData = {"Printer":{}, "Cutter": {}, "Router": []}
$(data).each( function() {
obj = this;
if (obj.type == "Router") {
newData[obj.type].push(obj.make);
} else {
if (!newData[obj.type][obj.make]) {
from __future__ import division
import numpy
import shlex
from uuid import uuid1
class d3object:
def __init__(self,
height=100,
width=100,
topHtml='',
bottomHtml='',
@campeterson
campeterson / data-sets.md
Last active November 1, 2022 23:59
Data sets
class SimpleLinearRegression
def initialize(xs, ys)
@xs, @ys = xs, ys
if @xs.length != @ys.length
raise "Unbalanced data. xs need to be same length as ys"
end
end
def y_intercept
mean(@ys) - (slope * mean(@xs))
@campeterson
campeterson / nucleotides.rb
Created November 6, 2012 04:35
codeupper2
#!/usr/bin/env ruby
input = ARGV[0]
a = input.count('A');
c = input.count('C');
g = input.count('G');
u = input.count('U')
p "#{a} #{c} #{g} #{u}"
@campeterson
campeterson / nucleotides.rb
Created November 6, 2012 04:33
codeupper1
#!/usr/bin/env ruby
contents = File.read('1.dataset')
A = contents.gsub(/[CcGgTt]/,'')
C = contents.gsub(/[AaGgTt]/,'')
G = contents.gsub(/[AaCcTt]/,'')
T = contents.gsub(/[AaCcGg]/,'')
puts "#{A.length} #{C.length} #{G.length} #{T.length}"
@campeterson
campeterson / screenshot.js
Created November 5, 2012 17:18 — forked from javan/screenshot.js
Create a screenshot of any URL using phantomjs (headless webkit)
//
// Example usage: phantomjs screenshot.js http://yahoo.com /tmp/yahoo.png
//
var system = require('system');
var url = system.args[1];
var filename = system.args[2];
var page = new WebPage();
page.open(url, function (status) {