Skip to content

Instantly share code, notes, and snippets.

View danielberkompas's full-sized avatar

Daniel Berkompas danielberkompas

View GitHub Profile
@danielberkompas
danielberkompas / gist:3185576
Created July 27, 2012 01:13
A sample interactor for Jamon
# app/interactors/admin/automated_tasks.rb
class Admin::AutomatedTasks
def self.run
Oem.all.each do |oem|
Admin::SendOemDataDump.run(oem)
end
end
end
# app/interactors/admin/send_oem_data_dump.rb
@danielberkompas
danielberkompas / best_practices.md
Created December 14, 2012 15:21
An article about the best way to use Rspec.

Best Practices

How to Test Classes

  require "spec_helper"
  
  describe ClassName do
  
    # Describe each method on your class.
    # Note that the `describe` call limits the scope
require 'active_record'
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
ActiveRecord::Schema.define(:version => 1) do
create_table :posts do |t|
t.string :title
t.timestamps
end
end
@danielberkompas
danielberkompas / deploy.rb
Last active December 1, 2018 23:40
A deployment script for Ruby/Rails on Heroku. Includes automatic running of migrations, custom branches and custom remotes.
# -----------------------------------------------------
# Ruby/Rails Heroku Deployment Script
# @author Daniel Berkompas
#
# After downloading, run `ruby deploy.rb --help` to
# get usage instructions.
#
# MIT License
# -----------------------------------------------------
require 'optparse'
def pbcopy(str)
IO.popen('pbcopy', 'r+') {|io| io.puts str }
output.puts "-- Copy to clipboard --\n#{str}"
end
Pry.config.commands.command "hiscopy", "History copy to clipboard" do |n|
pbcopy _pry_.input_array[n ? n.to_i : -1]
end
Pry.config.commands.command "copy", "Copy to clipboard" do |str|

Sublime Text 2 – Useful Shortcuts (PC)

Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.

Editing

Ctrl+C copy current line (if no selection)
Ctrl+X cut current line (if no selection)
Ctrl+⇧+K delete line
Ctrl+↩ insert line after
# configuration for osx clipboard support
set-option -g default-command "reattach-to-user-namespace -l sh"
var pubsub = {};
(function(q) {
var topics = {}, subUid = -1;
q.subscribe = function(topic, func) {
if (!topics[topic]) {
topics[topic] = [];
}
var token = (++subUid).toString();
topics[topic].push({
token: token,
@danielberkompas
danielberkompas / problem.html
Created March 30, 2014 02:47
This is my problem
<html data-ember-extension="1"><head><script type="text/javascript" async="" src="https://d2rcp9ak152ke1.cloudfront.net/assets/javascripts/squatch.min.js"></script><script type="text/javascript" async="" src="https://cdn.heapanalytics.com/js/heap.js"></script><script type="text/javascript">var NREUMQ=NREUMQ||[];NREUMQ.push(["mark","firstbyte",new Date().getTime()]);</script>
<!-- iOS Home Screen Icons -->
<link rel="apple-touch-icon" sizes="57x57" href="/assets/mentor/lead_simple_mark_ios_57.png">
<link rel="apple-touch-icon" sizes="72x72" href="/assets/mentor/lead_simple_mark_ios_72.png">
<link rel="apple-touch-icon" sizes="114x114" href="/assets/mentor/lead_simple_mark_ios_114.png">
<link rel="apple-touch-icon" sizes="144x144" href="/assets/mentor/lead_simple_mark_ios_144.png">
<!-- jQuery -->
<script src="//code.jquery.com/jquery-1.9.1.min.js"></script>
@danielberkompas
danielberkompas / gist:fec3369ae7603d709850
Created August 22, 2014 13:45
Install 1.9.3 with Rails Express Patches
ruby-install -p https://raw.github.com/skaes/rvm-patchsets/master/patches/ruby/1.9.3/p547/railsexpress/01-fix-make-clean.patch -p https://raw.github.com/skaes/rvm-patchsets/master/patches/ruby/1.9.3/p547/railsexpress/02-railsbench-gc.patch -p https://raw.github.com/skaes/rvm-patchsets/master/patches/ruby/1.9.3/p547/railsexpress/03-display-more-detailed-stack-trace.patch -p https://raw.github.com/skaes/rvm-patchsets/master/patches/ruby/1.9.3/p547/railsexpress/04-fork-support-for-gc-logging.patch -p https://raw.github.com/skaes/rvm-patchsets/master/patches/ruby/1.9.3/p547/railsexpress/05-track-live-dataset-size.patch -p https://raw.github.com/skaes/rvm-patchsets/master/patches/ruby/1.9.3/p547/railsexpress/06-webrick_204_304_keep_alive_fix.patch -p https://raw.github.com/skaes/rvm-patchsets/master/patches/ruby/1.9.3/p547/railsexpress/07-export-a-few-more-symbols-for-ruby-prof.patch -p https://raw.github.com/skaes/rvm-patchsets/master/patches/ruby/1.9.3/p547/railsexpress/08-thread-variables.patch -p https://raw.g