Skip to content

Instantly share code, notes, and snippets.

require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "activerecord", require: "active_record"
gem "activejob", require: "active_job"
gem "sqlite3"
gem "searchkick", git: "https://github.com/ankane/searchkick.git"
end
@itsmikeq
itsmikeq / db_fixtures_dump.rake
Last active July 8, 2020 15:26 — forked from ecleel/db_fixtures_dump.rake
Rails 5: Dump Rails db to fixtures
# frozen_string_literal: true
# Original from http://snippets.dzone.com/posts/show/4468 by MichaelBoutros
#
# Optimized version which uses to_yaml for content creation and checks
# that models are ActiveRecord::Base models before trying to fetch
# them from database.
namespace :db do
namespace :fixtures do
desc "Dumps all models into fixtures."
@itsmikeq
itsmikeq / rdd.md
Created October 29, 2015 01:48 — forked from kenchung/rdd.md
Resume Driven Development Challenge

Resume Driven Development Challenge

Using the Github Archive API, create a command-line tool to find popular repos to add lots of hipster acronyms to your resume!

It should support a date range in the past in case time travel becomes possible and you decide to go back and learn different things.

You should use Ruby or Javascript based on the role you are being considered for.

Given the date range, you'll collect event data from the Github Archive and give each repo a popularity score.

@itsmikeq
itsmikeq / live_database_dump.rb
Last active September 11, 2015 20:01 — forked from njakobsen/live_database_dump.rb
Live stream a database dump (or any other STDOUT) using Rails 4. Why would you want this? If you have a large database dump and want to avoid storing it in memory as Rails streams it. This allows pipe the dump directly into the http response instead of storing it as a file, sending it, and then deleting it. Let me know what you think! I've teste…
class DatabaseController < ApplicationController
def database_dump
database = Rails.configuration.database_configuration[Rails.env]["database"]
send_file_headers!(:type => 'application/octet-stream', :filename => "#{database}_#{Time.now.to_s(:human)}.backup")
pipe = IO.popen("pg_dump '#{database}' -F c")
stream = response.stream
while (line = pipe.gets)
stream.write line
sleep 0.0001 # HACK: Prevent server instance from sleeping forever if client disconnects during download
@itsmikeq
itsmikeq / API.swift
Last active August 29, 2015 14:12 — forked from higepon/API.swift
//
// API.swift
//
// Created by Taro Minowa on 6/10/14.
// Copyright (c) 2014 Higepon Taro Minowa. All rights reserved.
//
import Foundation
typealias JSONDictionary = Dictionary<String, AnyObject>