Skip to content

Instantly share code, notes, and snippets.

@ankane
ankane / elasticsearch.rb
Last active March 27, 2024 13:42
searchkick-knn
require "active_record"
require "disco"
require "elasticsearch"
require "searchkick"
ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"
ActiveRecord::Schema.verbose = false
ActiveRecord::Schema.define do
create_table :movies do |t|
t.string :name
@dypsilon
dypsilon / frontendDevlopmentBookmarks.md
Last active March 27, 2024 06:36
A badass list of frontend development resources I collected over time.
@be9
be9 / paginate.rb
Created September 5, 2013 04:18
kaminari + JSON API pagination helper
def paginate(scope, default_per_page = 20)
collection = scope.page(params[:page]).per((params[:per_page] || default_per_page).to_i)
current, total, per_page = collection.current_page, collection.num_pages, collection.limit_value
return [{
pagination: {
current: current,
previous: (current > 1 ? (current - 1) : nil),
next: (current == total ? nil : (current + 1)),
@coopermaruyama
coopermaruyama / vendor-ffmpeg-heroku
Created October 27, 2012 08:39
Install FFMpeg on heroku (Rails)
## Get FFMpeg working on heroku by building binaries using vulcan
gem install vulcan
vulcan create foo
git clone --depth 1 git://source.ffmpeg.org/ffmpeg
cd ffmpeg
@aseemk
aseemk / README.md
Last active February 14, 2018 16:41
A bookmarklet for "selecting all" (technically, "toggling all") checkboxes on the Amazon AWS S3 console.
@kalmanh
kalmanh / converter_script.rb
Last active October 24, 2016 19:34
Ruby script to convert .mdb db file into .csv
# Export data from Microsoft Access .mdb database into .csv files
# using https://github.com/brianb/mdbtools
# Install with homebrew - "brew install mdbtools"
class ConverterScript
tables = `mdb-tables -d , your_db_name.mdb`.chop.split(",")
tables.each do |table|
exists = system("mdb-export your_db_name.mdb '#{table}'")
`mdb-export your_db_name.mdb '#{table}' > #{table.gsub(" ", "_")}.csv` if exists