Skip to content

Instantly share code, notes, and snippets.

@wrtsprt
wrtsprt / db_fixtures_dump.rake
Created January 18, 2021 14:08 — forked from ecleel/db_fixtures_dump.rake
Rails 5: Dump Rails db to fixtures
# 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.'
task :dump => :environment do
models = Dir.glob(Rails.root + 'app/models/**.rb').map do |s|
@wrtsprt
wrtsprt / ruby-bitbar-template.10m.rb
Last active August 13, 2019 06:28
Template for a ruby BitBar plugin
#!/usr/bin/env /Users/<myusernamehere>/.rbenv/shims/ruby
#
# <bitbar.title></bitbar.title>
# <bitbar.version>v0.1</bitbar.version>
# <bitbar.author></bitbar.author>
# <bitbar.author.github></bitbar.author.github>
# <bitbar.desc></bitbar.desc>
# <bitbar.dependencies></bitbar.dependencies>
# <bitbar.abouturl></bitbar.abouturl>
@wrtsprt
wrtsprt / itiy.1h.rb
Last active May 24, 2017 07:37
BitBar plugin to indicate if DJ Trump was impeached yet
#!/usr/bin/ruby
#
# <bitbar.title>Is Trump Impeached Yet?</bitbar.title>
# <bitbar.version>v0.1</bitbar.version>
# <bitbar.author>Raphael H. Doehring</bitbar.author>
# <bitbar.author.github>wrtsprt</bitbar.author.github>
# <bitbar.desc>Plugin polling http://istrumpimpeachedyet.com to check if the thumbgs-down image is there</bitbar.desc>
# <bitbar.dependencies>ruby</bitbar.dependencies>
# <bitbar.abouturl>https://gist.github.com/wrtsprt/9ec6519a866035ab9982b02005ac00b0</bitbar.abouturl>
@wrtsprt
wrtsprt / imdb-seagull.html
Created April 28, 2017 08:36
Chart the development of IMDB scores of Steven Seagull movies - POC
<html>
<head>
<script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.bundle.js"></script>
<script type="text/javascript">
var realData = [{y: 3.7, x: 2016},
,{y: 3.9, x: 2016}
,{y: 3.2, x: 2016}
,{y: 3.4, x: 2016}
@wrtsprt
wrtsprt / steven.html
Last active February 13, 2017 22:10
IMDB ratings plotting
<html>
<head>
<script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.5.0/Chart.bundle.js"></script>
<script type="text/javascript">
var realData = [{y: 3.7, x: 2016},
,{y: 3.9, x: 2016}
,{y: 3.2, x: 2016}
,{y: 3.4, x: 2016}
Date: Sat, 11 Jun 2016 13:52:58 +0200
From: no-reply@mydigipass.com
To: foo@bar2332.com
Message-ID: <575bfb9ae753a_14d6f3fd52a5d27c83271e@rmb13.lan.mail>
Subject: Your invitation to identity validation for Acme of Acme corp.
Mime-Version: 1.0
Content-Type: multipart/related;
boundary="--==_mimepart_575bfb9ae3ac1_14d6f3fd52a5d27c832615";
charset=UTF-8
Content-Transfer-Encoding: 7bit

Commands examples

If the namespace is not used then the commands will perform on top of the default database. bundle exec rake db:create bundle exec rake db:migrate

By using the namespace we are going to use all the configuration for our alternate DB. bundle exec rake store:db:create bundle exec rake store:db:migrate

@wrtsprt
wrtsprt / Record closing tab.kmmacros
Created April 8, 2014 19:52
Two keyboard maestro macros to emulate continuous undo of closed tabs / windows in Safari (initial attempt)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>Activate</key>
<string>Normal</string>
<key>IsActive</key>
<true/>
<key>Macros</key>
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Oct 23 2012 13:50:52)
Compiled by root@apple.com
Normal version without GUI. Features included (+) or not (-):
-arabic +autocmd -balloon_eval -browse +builtin_terms +byte_offset +cindent -clientserver -clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments -conceal +cryptv +cscope +cursorbind +cursorshape +dialog_con +diff +digraphs -dnd -ebcdic -emacs_tags +eval +ex_extra +extra_search -farsi +file_in_path +find_in_path +float +folding -footer +fork() -gettext
-hangul_input +iconv +insert_expand +jumplist -keymap -langmap +libcall +linebreak +lispindent +listcmds +localmap -lua +menu +mksession +modify_fname +mouse -mouseshape -mouse_dec -mouse_gpm -mouse_jsbterm -mouse_netterm -mouse_sysmouse +mouse_xterm +multi_byte +multi_lang -mzscheme +netbeans_intg -osfiletype +path_extra -perl +persistent_undo +postscript
+printer -profile +python/dyn -python3 +quickfix +reltime -rightleft +ruby/dyn +scrollbind +signs +smartindent -sniff +startuptime +statusline -
@wrtsprt
wrtsprt / remove_file_from_git_hist.sh
Created May 18, 2011 09:44
remove file from git history
#!/bin/bash
set -o errexit
# Original from David Underhill @ http://dound.com/2009/04/git-forever-remove-files-or-folders-from-history/
# Script to permanently delete files/folders from your git repository. To use
# it, cd to your repository's root and then run the script with a list of paths
# you want to delete, e.g., git-delete-history path1 path2
if [ $# -eq 0 ]; then