Skip to content

Instantly share code, notes, and snippets.

@flimshaw
flimshaw / jquery.animateCss.plugin.js
Created July 23, 2012 20:41
Little jQuery plugin for calling CSS3 animations and attaching callbacks to them
// Generated by CoffeeScript 1.3.3
//
// animateCss jQuery Plugin by Charlie Hoey <charlie.hoey@gmail.com>
//
// DESCRIPTION: Apply a CSS3 animation class, and and a callback to fire
// when it's done. Works well with animate.css (http://daneden.me/animate/)
// but custom css styles work just fine too.
//
// USAGE: $("#divID").animateCss({ startAnimation: "bounceOutRight", callback: function() { console.log("Done!"); });
//
@flimshaw
flimshaw / twitterColumbo.py
Created July 24, 2012 15:00
A python script that prints out all tweets mentioning Columbo
import tweetstream
import time
# receipt printer driver
import printer as rp
printer = rp.RPrinter()
print "TwitterFeed!"
s3.getObject(params).createReadStream()
.pipe(zlib.createGunzip())
.pipe(csv())
.pipe(starValidator)
.pipe(toCsv)
.pipe(upload)
var AWS = require('aws-sdk'),
fs = require('fs'),
awsCredentialsPath = './aws.credentials.json',
sqsQueueUrl = 'SQS_QUEUE_URL',
http = require('http'),
sqs;
// Load credentials from local json file
AWS.config.loadFromPath(awsCredentialsPath);
if(this.chunkCounter > this.torrent.pieces.length) {
this.chunkCounter = 0;
this.loading = false;
}
if(this.torrent.store.store.chunks[this.chunkCounter] !== undefined && this.torrent.pieces[this.chunkCounter] === null) {
let a = this.torrent.store.store.chunks[this.chunkCounter];
// fire off an anon function that contains a reference to the chunk id we're sending
// probably shoudl be a promise someday
(() => {
var cc = Math.floor(this.chunkCounter);
updateGeometry(buf, offset, count) {
if(this.offsetsProcessed.indexOf(offset) === -1) {
if(buf.length !== count) {
console.log("Invalid packet, rejecting");
}
this.offsetsProcessed.push(offset);
var _buf = buf;
var _offset = offset / 4;
var _count = count / 4;
function processFile(file) {
fs.createReadStream(file) // open the gzipped csv file and start sending chunks of it downstream
.pipe(zlib.createGunzip()) // once you get a chunk, decompress it and pass it downstream
.pipe(csv()) // convert the decompressed chunk into individual rows and values
.on('data', processRow(row)) // if a row has a parallax measurement, calculate its position and write it to a new file
}
// get the given filename from the path given
http.get({
hostname: 'cdn.gea.esac.esa.int',
port: 80,
path: `/Gaia/gaia_source/csv/${filename}`,
agent: false // create a new agent just for this one request
}, (res) => {
// stream-upload the file to Amazon S3 as it comes in
res.pipe(upload);
});
const DEG2RAD = Math.PI / 180;
fs.createReadStream(file)
.pipe(zlib.createGunzip())
.pipe(csv())
.on('data', d => {
// assume the first row is a list of headers, we can use this to do easy lookups of rows later
if(!headers) {
headers = d;
} else {
// only process rows that have a measurement for parallax
'use strict'
// by Charlie Hoey <me@charliehoey.com>
//
// script for processing a folder full of gzipped CSV files into a single filtered CSV file.
// specifically this calculates x/y/z positions and distances for stars that contain a parallax measurement
// ......
var csv = require('fast-csv')
var fs = require('fs')
const zlib = require('zlib');
var glob = require('glob');