Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am jrichter on github.
  • I am jrichter (https://keybase.io/jrichter) on keybase.
  • I have a public key whose fingerprint is D527 3F3F EDB4 AC06 F20F E573 4E75 DD5F 50A9 12B9

To claim this, I am signing this object:

def self.read_files_and_create_reports
@filenames = []
pids = []
dir = "public/txt_reports"
Dir.foreach(dir) do |entry|
if entry.include? ".txt"
@filenames << entry
end
end
do_work_concurrently(@filenames, dir, 2)
This is neat. Here is my erb file.
<% content_for :sidebar do %>
<%= link_to 'New user', new_user_path %>
<% end %>
<h1>Listing users</h1>
<% @users.each do |user| %>
<% if user.sessions.size > 0 %>
<p class="logged_in">
@jrichter
jrichter / erb.lang
Created October 3, 2009 22:04
For erb text highlighting in gedit. put it here: /usr/share/gtksourceview-2.0/language-specs/
<?xml version="1.0" encoding="UTF-8"?>
<!--
This is a smashup by Justin Richter of html.lang and ruby.lang
html.lang
Authors: Marco Barisione, Emanuele Aina
Copyright (C) 2005-2007 Marco Barisione <barisione@gmail.com>
Copyright (C) 2005-2007 Emanuele Aina
ruby.lang
Author: Archit Baweja <bighead@users.sourceforge.net>
Copyright (C) 2004 Archit Baweja <bighead@users.sourceforge.net>
@jrichter
jrichter / my_emacs_keys
Created December 29, 2010 21:50
my emacs key combos
Emacs Rails
C-c n Goto Mailer
C-c z '' RSpec Fixture
C-c x '' Fixture
C-c c '' Controller
C-c g '' Migration
C-c r '' RSpec
C-c u '' Unit Test
C-c m '' Model
@jrichter
jrichter / TimeTest.rb
Created January 4, 2011 02:26
This is simply to test tracking the time of method calls
#---
# Excerpted from "Programming Ruby 1.9",
# published by The Pragmatic Bookshelf.
# Copyrights apply to this code. It may not be used to create training material,
# courses, books, articles, and the like. Contact us if you are in doubt.
# We make no guarantees that this code is fit for any purpose.
# Visit http://www.pragmaticprogrammer.com/titles/ruby3 for more book information.
#---
# I modified this code a little
@jrichter
jrichter / forked.rb
Created January 6, 2011 00:30
How I took advantage of concurrency. I found this somewhere and modified it. I don't remember where.
def do_work_concurrently(number_of_workers = 5)
config = ActiveRecord::Base.remove_connection
max = number_of_workers
pids = []
any_work = true
while any_work do
# Don't forget to set any_work to false to exit the loop
pids << fork_with_new_connection(config) {
@jrichter
jrichter / justin.el
Created August 26, 2012 13:54
my emacs file
;; Load a custom theme
(load-theme 'sanityinc-tomorrow-eighties t)
;; Make compilation window not steal a buffer
(setq special-display-buffer-names
'("*compilation*"))
(setq special-display-function
(lambda (buffer &optional args)
(split-window)
@jrichter
jrichter / justin.zsh
Created December 2, 2012 01:22
My zsh theme
# justin.zsh-theme
# Most of this was taken from
# http://blog.andrewhays.net/love-your-terminal which was taken from
# http://stevelosh.com/blog/2010/02/my-extravagant-zsh-prompt/
# Also some of this was taken from josh.zsh-theme
# Determine what character to use in place of the '$' for my prompt.
function repo_char {
git branch >/dev/null 2>/dev/null && echo "%(?,%{%F{green}%},%{%F{red}%})∩%{$reset_color%}" && return
echo "%(?,%{%F{green}%},%{%F{red}%})⚡%{$reset_color%}"
@jrichter
jrichter / Ruby Notepad Bookmarklet
Last active December 11, 2015 22:38 — forked from jakeonrails/Ruby Notepad Bookmarklet
This was based off of this, "data:text/html, <html contenteditable>" from this thread, https://coderwall.com/p/lhsrcq, and forked from a different gist in the comments of that thread.
data:text/html, <title>Ruby Mode Text Editor</title><style type="text/css">#e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div id="e"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("e");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/ruby");</script>