Skip to content

Instantly share code, notes, and snippets.

View drush's full-sized avatar

Darren Rush drush

View GitHub Profile
drush / db_export.rake
Created February 2, 2024 20:40
Rails Task to export a DB to mockdb.json compatible ith React-admin fakerest provider
# Utility for applications
# Will export your current DB to a single JSON file that can be consumed directly
# by React-admin Fakerest adapter
# lib/tasks/db_export.rake
namespace :db do
desc 'Export all tables to a single JSON file, database-agnostic'
task export: :environment do
require 'json'
# Define an array of tables to exclude
drush /
Created August 5, 2021 23:46 — forked from mrbar42/
bash scripts to create VOD HLS stream with ffmpeg almighty (tested on Linux and OS X)


bash beach.mkv

will produce:

      |- playlist.m3u8
 |- 360p.m3u8
drush /
Last active January 14, 2020 16:51
Find the Command Line Utilities You Use the Most
history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n20
drush / chantest.go
Last active January 22, 2018 19:51
Buffered vs Unbuffered channel behavior in golang
package main
import (
func main() {
// Bufferered channel. Remove the 50 to see how an unbuffered channel behaves differently
drush / gist:4590dd2c7057b1d807c3
Created July 28, 2015 20:55
Elasticsearch Scan & Scroll Proto
require 'mechanize'
a =
body ='http://localhost:9200/sbir_dom/Firm/_search?search_type=scan&scroll=1m', {
"query": {
"query_string": { "query": "name:z*" }
"_source": false, "fields": ["_id"], "size": 10
drush / delayed_job_threads.rb
Last active July 13, 2020 13:17
Run Delayed Job Worker as a Thread in Web Process
# Only run in server process, not console or rake tasks
if !Rails.const_defined?('Console') && !($0 =~ /rake$/) && !Rails.env.test?
Rails.application.config.after_initialize do
(1..2).each do |thread_id| {
Thread.current[:thread_name] = "DJ Web Worker Thread #{thread_id}"
ActiveRecord::Base.connection_pool.with_connection do |conn|
dj =
Rails.logger.warn "Starting #{Thread.current[:thread_name]}"
drush / heroku-dynos.rb
Last active September 11, 2017 17:05
Show a report of the current number of web and worker dynos and the stack used across all your Heroku apps.
apps = `heroku apps`.split("\n\n")[0].lines[1..-1].collect{|l| l.strip }
printf("%-20s %4s %4s\n", 'APP', 'WEB', 'BG')
astats = `heroku ps -a #{a}`
info = `heroku apps:info -a #{a}`
access = `heroku access -a #{a}`
stack = info.scan(/Stack:\s+(.*)/).first.last rescue 'NA'
web, workers = (astats.match(/web\.\d/).size rescue 0), (astats.match(/worker\.\d/).size rescue 0)
printf("%-20s %4s %4s %20s\t#{access}\n", a, web, workers, stack)
drush /
Last active December 13, 2015 23:19 — forked from rajraj/
Install elasticsearch on a fresh Centos6 box
cd ~
sudo yum update
sudo yum install java-1.7.0-openjdk.i686 unzip wget -y
wget -O
export ES_HOME=/opt/elasticsearch
sudo unzip -d $ES_HOME
drush / Crosstab for Ruby
Created March 8, 2010 21:15
A helper to convert model arrays into crosstab reports
# Crosstab module for ruby. This class allows you to iterate through an
# array of models (rows) and refactor the data to a crosstab format.
# This takes one of the columns and makes it your row-key, another column
# and makes it column-keys, then sums all cell values where these two
# keys interesect.
# Currently only a single column can be used for row-keys and column-keys
# but this may be expanded in the future with the addition of 'row grouping'