Skip to content

Instantly share code, notes, and snippets.

View jem's full-sized avatar

Jacob Mattingley jem

View GitHub Profile
@jem
jem / gist:1083800
Created July 15, 2011 00:27
multi-threaded shell scripting
ls | xargs -P2 -I% echo "This file is [%]"
# -I replstr
@jem
jem / devise.rb
Created September 22, 2011 23:48 — forked from larsthegeek/devise.rb
Devise configuration to allow username or email address for sign_in, confirmation, unlock, forgot password instructions.
################################################################
# For views/migrations etc. check http://tinyurl.com/3xfx3zm #
################################################################
# File : RAILS_APP/config/initializers/devise.rb
# Change the following only. Rest can stay same
# NOTE : You must use devise master or any version released after Mar 13, 2011 to get everything mentioned here working.
config.authentication_keys = [ :login ]
config.confirmation_keys = [ :login ]
config.unlock_keys = [ :login ]
@jem
jem / gist:1399348
Created November 28, 2011 06:25
include url helpers
# To play with routes in the rails console from rails 3.1, use the following:
include Rails.application.routes.url_helpers
default_url_options[:host] = 'localhost:3000' # or whatever
# Now, can freely play with routes.
>> url_for User.first
=> "http://localhost:3000/users/7"
>> url_for [Pod.first, :tasks]
=> "http://localhost:3000/pods/8/tasks"
# etc.
@jem
jem / gist:1443669
Created December 7, 2011 17:21
search in git history
git log -S 'command :cp'
@jem
jem / gist:2646744
Created May 9, 2012 17:04
configure ubalo for java
export PACKAGESITE=http://ubalo.io.s3.amazonaws.com/packages/public
sudo pkg update
sudo pkg info -e java/openjdk6 || sudo pkg install -y java/openjdk6
javac hello.java
@jem
jem / gist:2783772
Created May 24, 2012 19:40
Ancient (2009) code for IMAP idle in Ruby
SERVER = 'imap.gmail.com'
USERNAME = 'XXX'
PW = 'XXX'
require 'net/imap'
require 'net/smtp'
require 'tmail'
require 'maruku'
def to_markdown(text)
Maruku.new(text).to_html
.hll { background-color: #ffffcc }
.c { color: #408080; font-style: italic } /* Comment */
.err { border: 1px solid #FF0000 } /* Error */
.k { color: #008000; font-weight: bold } /* Keyword */
.o { color: #666666 } /* Operator */
.cm { color: #408080; font-style: italic } /* Comment.Multiline */
.cp { color: #BC7A00 } /* Comment.Preproc */
.c1 { color: #408080; font-style: italic } /* Comment.Single */
.cs { color: #408080; font-style: italic } /* Comment.Special */
.gd { color: #A00000 } /* Generic.Deleted */
data = ubalo.recv()
ubalo.map("analyze", data)
ubalo.send(final_result)
require 'rest-client'
require 'json'
site = "https://api.mmx.io"
path = "/query/summary"
token = $TOKEN # be sure to set this in your command line environment.
url = "https://api.mmx.io/query/summary"
body = {
datasource: "demoexchange",
@jem
jem / moon.rb
Created November 8, 2022 04:59 — forked from nofxx/moon.rb
#
# Lunar/Moon phases ruby class
#
# Code is based upon Bradley E. Schaefer''s moon phase algorithm.
# Ruby version based on JavaScript Phase Calculator by Stephen R. Schmitt
class Moon
attr_reader :epoch, :phase, :days, :icon, :dist, :ll, :emoji
# Return the current (or input a date) moon.
# Moon.new