Skip to content

Instantly share code, notes, and snippets.

View pftg's full-sized avatar
💭
I may be slow to respond.

Paul Keen pftg

💭
I may be slow to respond.
View GitHub Profile
@pftg
pftg / application.rb
Created October 1, 2016 22:19
Rails Initializers Boot Perfromance
# config/application.rb
module RailsApp
class Application < Rails::Application
ActiveSupport::Notifications.subscribe('load_config_initializer.railties') do |*args|
event = ActiveSupport::Notifications::Event.new(*args)
puts "Loaded initializer #{event.payload[:initializer]} (#{event.duration}ms)"
end
end
end
@pftg
pftg / m4a-to-mpr.md
Last active April 24, 2020 08:07
Compress m4a with audio notes
ffmpeg -i tmp/audio-notes.m4a -acodec libmp3lame -aq 9 tmp/audio-notes.mp3
for file in *.m4a ; do ffmpeg -i $file -acodec libmp3lame -aq 9 ${file%.m4a}.mp3 ; done
@pftg
pftg / linux-rubymine.vmoptions
Last active September 16, 2017 07:55
JetBrains IDE Custom VmOptions
# Configuration for Machine with 16G of RAM and Java 8
# Debug options
#-XX:+UnlockDiagnosticVMOptions
#-XX:+PrintFlagsFinal
#-XX:+PrintGCDateStamps -verbose:gc -XX:+PrintGCDetails -Xloggc:"<path to log>"
#-XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M
-da
-server
@pftg
pftg / task.md
Created February 15, 2015 19:00

Please create an Android app that accomplishes the following:

  • Connect to the Github API
  • Find the rails/rails repository
  • Find the most recent commits (choose at least 25 or more of the commits)
  • Create a ListView that groups the recent commits by author in a custom view.
  • Click here for a screenshot mock up of what the final product should look like
@pftg
pftg / Equity.md
Last active August 29, 2015 14:12 — forked from isaacsanders/Equity.md

This is a post by Joel Spolsky. The original post is linked at the bottom.

This is such a common question here and elsewhere that I will attempt to write the world's most canonical answer to this question. Hopefully in the future when someone on answers.onstartups asks how to split up the ownership of their new company, you can simply point to this answer.

The most important principle: Fairness, and the perception of fairness, is much more valuable than owning a large stake. Almost everything that can go wrong in a startup will go wrong, and one of the biggest things that can go wrong is huge, angry, shouting matches between the founders as to who worked harder, who owns more, whose idea was it anyway, etc. That is why I would always rather split a new company 50-50 with a friend than insist on owning 60% because "it was my idea," or because "I was more experienced" or anything else. Why? Because if I split the company 60-40, the company is going to fail when we argue ourselves to death. And if you ju

@pftg
pftg / 1.rb
Last active August 29, 2015 14:00
showing_request.showing_request_notifications.
create!({
recipient: 'listing_agent',
notification_type: 'email',
contact_name: 'John Smith',
contact: 'john@example.com',
token: 'token'
},
without_protection: true)
@pftg
pftg / block.rb
Last active August 29, 2015 13:56
o = Object.new.tap do |o|
o.result
end # => Object.new
o = Object.new.<some method> do |o|
o.result
end # => Object.new.result
o = Object.new
o.result # => Object.new.result
@pftg
pftg / address.rb
Last active January 2, 2016 19:29
class Address
after_commit :schedule_search_location
def schedule_search_location
Address.delay.search_for_location(id) if previous_changes.include?(:address) || location.blank?
end
end
1) Failure:
EagerAssociationTest#test_deep_including_through_habtm [/Users/pftg/dev/rails/activerecord/test/cases/associations/eager_test.rb:1140]:
2 instead of 0 queries were executed.
Queries:
PRAGMA table_info("categories_posts")
PRAGMA table_info("categorizations").
Expected: 0
Actual: 2
@pftg
pftg / Gemfile
Created September 15, 2013 16:54
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'