Skip to content

Instantly share code, notes, and snippets.

View ajsharp's full-sized avatar

Alex Sharp ajsharp

View GitHub Profile
@ajsharp
ajsharp / email_example.rb
Last active August 29, 2015 14:01
This describes two potential API for running jobs in the future. One is a simple, abstract job, where the logic lives in your application, and is triggered via a webhook at the scheduled time. The other is a SMS notification that is due to fire at some point in the future.
# Often times we need to send emails on a delayed basis. We could make this really easy on the client
# side by automatically mounting an endpoint with rack middleware, and firing the mailer with the
# arguments supplied.
#
# Under the hood, this would use the same architecture as an abstract job, where a webhook is hit
# at the specified time, but by focusing on the email / action mailer use case the client doesn't need
# to write any boilerplate code.
Tick::EmailJob.create!(
:at => appointment.start_time - 1.hour,
:message => "Don't forget, your appointment starts in 1 hour!",
CREATE TABLE IF NOT EXISTS Timelines(
name text,
parent_id text,
event_id uuid,
PRIMARY KEY((parent_id, name), event_id)
) WITH CLUSTERING ORDER BY (event_id DESC)
class UserDecorator < Draper::Decorator
delegate_all
def display_name
"#{first_name} #{last_name}"
end
end
# app/controllers/users_controller.rb
class UsersController < ApplicationController
.. container:: tab-content
.. container:: tab-pane active
:name: tokenize-js
.. code-block:: javascript
var callback = function(response) {
switch (response.status) {
case 201:
diff --git a/overview/conf.py b/overview/conf.py
index dedd5d5..0fffc9b 100644
--- a/overview/conf.py
+++ b/overview/conf.py
@@ -235,7 +235,10 @@ htmlhelp_basename = 'Balanceddoc'
# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'
+import pygments.lexers.jvm
import pygments.lexers.web
$ ./configure --cc=/usr/bin/llvm-gcc-4.2 --prefix=~/rbx/
...
$ rake install
GEN vm/gen/config_variables.h
/Users/ajsharp/.rvm/rubies/ruby-1.9.3-p392/bin/ruby vm/codegen/config_vars.rb vm/gen/config_variables.h
mkdir -p /Users/ajsharp/code/rubinius/staging//lib/encoding/converter
/Users/ajsharp/.rvm/rubies/ruby-1.9.3-p392/bin/ruby vm/codegen/field_extract.rb vm/builtin/basic_object.hpp vm/builtin/object.hpp vm/builtin/integer.hpp vm/builtin/fixnum.hpp vm/builtin/array.hpp vm/builtin/bignum.hpp vm/builtin/executable.hpp vm/builtin/access_variable.hpp vm/builtin/alias.hpp vm/builtin/block_environment.hpp vm/builtin/block_as_method.hpp vm/builtin/byte_array.hpp vm/builtin/io.hpp vm/builtin/channel.hpp vm/builtin/module.hpp vm/builtin/constant_table.hpp vm/builtin/class.hpp vm/builtin/compiled_code.hpp vm/builtin/data.hpp vm/builtin/dir.hpp vm/builtin/exception.hpp vm/builtin/float.hpp vm/builtin/immediates.hpp vm/builtin/iseq.hpp vm/builtin/list.hpp vm/builtin/lookup_table.hpp vm/builtin/ffi_pointer.hpp vm/bui
checking for gcc... /usr/bin/gcc-4.2
checking whether the C compiler works... no
configure: error: in `/Users/ajsharp/code/rubinius/vendor/libffi':
configure: error: C compiler cannot create executables
See `config.log' for more details
make: *** [config.status] Error 77
Error: make
Debugger entered--Lisp error: (wrong-type-argument integer-or-marker-p open)
read-kbd-macro(open)
#[(keys) "\301^H!\207" [keys read-kbd-macro] 2 1648419](open)
(kbd open)
(define-key js2-mode-map (kbd open) (ilam (js2r--self-insert-wrapping open close semicolonp)))
js2r--setup-wrapping-pair("(" ")" js2r--needs-semi)
eval-buffer(#<buffer *load*> nil "/Users/ajsharp/.emacs.d/setup-js2-mode.el" nil t) ; Reading at buffer position 3604
load-with-code-conversion("/Users/ajsharp/.emacs.d/setup-js2-mode.el" "/Users/ajsharp/.emacs.d/setup-js2-mode.el" nil t)
require(setup-js2-mode)
(lambda nil (require (quote setup-js2-mode)))()
@ajsharp
ajsharp / rerun_migrations.rb
Created June 18, 2013 22:38
rake db:migrate:rerun VERSION=123
namespace :db do
namespace :migrate do
desc "Re-run a migration that's already been run"
task :rerun => [:environment, :load_config] do
class ActiveRecord::Migrator
def rerun
target = migrations.detect { |m| m.version == @target_version }
raise UnknownMigrationVersionError.new(@target_version) if target.nil?
target.migrate(:up)
end
@ajsharp
ajsharp / memory_leak.rb
Last active December 18, 2015 04:39
Run using ruby 1.9.3p392
def object_report(type = nil)
if type
puts "number of (#{type}) objects in memory = #{ObjectSpace.each_object(type).count}"
else
puts "number of objects in memory = #{ObjectSpace.each_object.count}"
end
end
def full_report
ObjectSpace.each_object.to_a.inject(Hash.new(0)) do |h,o|