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 / 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 / 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 / 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 / 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
var setCryptData = function (data) {
window.cryptData = data.crypto_key;
};
var submitFormWithCrypto = function (form, callback) {
$.getScript('/profiles/crypto_key?callback=setCryptData', function () {
var queryData = {
key_id: cryptData.id,
encrypted: teaEncrypt($(form).serialize(), cryptData.key)
};
@pftg
pftg / Move instructions
Created March 28, 2012 20:21
Move /home to it’s own partition
mkdir /mnt/newhome
sudo mount -t ext3 /dev/hda5 /mnt/newhome
cd /home/
find . -depth -print0 | cpio –null –sparse -pvd /mnt/newhome/
sudo umount /mnt/newhome
sudo mv /home /old_home
sudo mkdir /home
@pftg
pftg / torrentsync.rb
Created April 6, 2012 11:04 — forked from ohac/torrentsync.rb
transmission-remote for ruby
#!/usr/bin/ruby
require 'rubygems'
require 'nokogiri'
require 'net/http'
require 'json'
require 'timeout'
require 'fileutils'
require 'open-uri'
require 'base64'
require 'choice'
@pftg
pftg / client.rb
Created September 11, 2012 07:24
Rails Isolation snippet with Faraday
#lib/client.rb
require 'faraday_middleware'
module Client
def connection
@connection ||= Faraday.new url: APP_URL do |faraday|
=begin
Some Faraday Builder's code
class BlogsController < ApplicationController
before_filter :setup
def replace
# For some reason we need only mark for destructions old article with name: "My First Article"
blog.articles.each(&:mark_for_destruction)
# params[:articles_attributes] => { name: "My First Article" }
blog.articles.build(params[:articles_attributes])
blog.save! # => raise exception!
@pftg
pftg / test_should_destroy_marked_childs_before_new_child_savings_for_postgres.out
Last active December 15, 2015 02:19
test_should_destroy_marked_childs_before_new_child_savings results output
ruby -Itest:lib /Users/pftg/dev/rails/activerecord/test/cases/autosave_association_test.rb --name=test_should_destroy_marked_childs_before_new_child_savings
Testing started at 11:45 AM ...
Using postgresql
Run options: --name=test_should_destroy_marked_childs_before_new_child_savings --seed 7999
# Running tests:
E
Finished tests in 0.097594s, 10.2465 tests/s, 0.0000 assertions/s.