Skip to content

Instantly share code, notes, and snippets.

@giannafusaro
giannafusaro / install_ffmpeg.sh
Last active September 8, 2018 06:54
ffmpeg install for brew
#!/bin/bash
brew install ffmpeg \
--with-chromaprint \
--with-fdk-aac \
--with-fontconfig \
--with-freetype \
--with-frei0r \
--with-game-music-emu \
--with-libass \
--with-libbluray \
@giannafusaro
giannafusaro / paperclip_reprocess_worker.rb
Created November 6, 2016 18:17
Worker to take a group of records and reprocess all attachments
class PaperclipReprocessWorker
include Sidekiq::Worker
sidekiq_options retry: true
def perform(klass, group)
group.each do |id|
klass.constantize.attachment_definitions.keys.each do |attachment|
begin
klass.constantize.find(id).send(attachment).reprocess!
@giannafusaro
giannafusaro / reprocess_paperclip_attachments.rake
Created November 6, 2016 18:16
Rake task to reprocesses all attachments for given class
namespace :paperclip do
desc "Reprocesses all attachments for given class"
# rake paperclip:reprocess[User,800,'where','some_sort_of_scope_or_filter IS true']
task :reprocess, [:class, :batch_size, :where, :clause] => :environment do |t, args|
klass = args[:class].constantize
batch_size = args[:batch_size]&.to_i || 100
records = klass.all
records = klass.send(args[:where], args[:clause]) if args[:where] && args[:clause]
records.find_in_batches(batch_size: batch_size) do |group|

Keybase proof

I hereby claim:

  • I am giannafusaro on github.
  • I am gianna (https://keybase.io/gianna) on keybase.
  • I have a public key whose fingerprint is 4EAA D6C7 7856 D19B 7200 1E58 28F8 2FD0 D02D 874A

To claim this, I am signing this object:

require 'active_record'
ActiveRecord::Base.establish_connection(
:adapter => 'sqlite3',
:database => 'benchmark.db'
)
# ActiveRecord::Migration.class_eval do
# create_table :users do |t|
# t.string :email
# t.string :name
source "https://rubygems.org"
gem "rails", "4.2.5.2"
gem "sqlite3"
require 'capybara'
require 'capybara/poltergeist'
class Scraper
include Capybara::DSL
attr_accessor :text, :document, :metas, :title, :session, :globals, :globals_script
# settings for poltergeist driver
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new app,
js_errors: false,
# # # # # # # # # # # # # # # # # # #
# HeapNode
# # # # # # # # # # # # # # # # # # #
@HeapNode = class HeapNode
constructor: (trie_node, heap_index) ->
@trie_node = trie_node
@trie_node.heap_index = heap_index
@frequency = trie_node.data['frequency']
@word = trie_node.data['word']
@giannafusaro
giannafusaro / erlang_program_in_ruby.rb
Last active October 21, 2015 04:53
translation of erlang_program.prompt.erl to ruby
#############################################################################
# title: erlang_program_in_ruby.rb
# desc: translation of erlang_program.prompt.erl to ruby
# author: gianna fusaro
# date: october 20, 2015
#############################################################################
# WeightItem: item with label, weight, and unit
class WeightItem
@giannafusaro
giannafusaro / sf-street-sweep-map.html
Last active October 18, 2015 03:00
d3 street sweep map
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<title>San Francisco Street Sweep Routes</title>
<head>
<link rel="stylesheet" href="sf-sweep.css" />
<script src="javascript/d3.v3.min.js"></script>
<script src="javascript/topojson.js"></script>
<script src="javascript/queue.v1.min.js"></script>