Skip to content

Instantly share code, notes, and snippets.

(function() {
var lastSeen = (new Date()).getTime();
var engagedTime = 0;
var idleTimeout = 5000;
$(document).ready(function() {
$(window).on('focus click scroll mousemove touchstart touchend touchcancel touchleave touchmove', function() {
lastSeen = (new Date()).getTime();
});
});
<script async src="https://www.themarshallproject.org/pixel.js"></script>
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;
require 'elasticsearch'
url = `heroku config --app <heroku-app-name> | grep "SEARCHBOX_SSL_URL:"`.split(": ").last.strip
client = Elasticsearch::Client.new(url: url)
# https://github.com/elasticsearch/elasticsearch-ruby/issues/49
scan_response = client.search(index: 'pixels', search_type: 'scan', scroll: '5m', size: 10)
while response = client.scroll(scroll_id: scan_response['_scroll_id'], scroll: '5m') and !response['hits']['hits'].empty? do
puts response['hits']['hits'].map { |r| r['_source'] }
def pmap(items)
queue = Queue.new
threads = items.map do |item|
Thread.new do
queue.push yield(item)
end
end
threads.map &:join
output = []
output << queue.pop until queue.empty?
@ivarvong
ivarvong / gist:af7e9427b31d9a4e18d4
Created December 12, 2014 21:46
mailchimp ruby api, copy-pasted for highlighting
# https://bitbucket.org/mailchimp/mailchimp-api-ruby/raw/fc745199610bc00ecb42388a241c8018e20cc4a1/lib/mailchimp/api.rb
module Mailchimp
class Folders
attr_accessor :master
def initialize(master)
@master = master
Your bundle is complete!
Gems in the groups development and test were not installed.
It was installed into ./vendor/bundle
Bundle completed (1.42s)
Cleaning up the bundler cache.
!
! Command: 'set -o pipefail; curl --fail --retry 3 --retry-delay 1 --connect-timeout 3 --max-time 30 http://nodejs.org/dist/v0.10.30/node-v0.10.30-linux-x64.tar.gz -s -o - | tar zxf - node-v0.10.30-linux-x64/bin/node' failed unexpectedly:
!
! gzip: stdin: invalid compressed data--format violated
! tar: Unexpected EOF in archive
require 'sinatra'
require 'aws-sdk'
require 'digest/md5'
require 'dotenv'
Dotenv.load
$project_name = 'no-country'
$input_file = './index.html'
class S3Upload
class Document < ActiveRecord::Base
include HTTParty
format :json
base_uri "https://www.documentcloud.org"
debug_output $stdout # optional
def update_published_url
self.class.put("/api/documents/#{self.dc_id}.json",
basic_auth: {
username: ENV['DOCUMENTCLOUD_USERNAME'],