Skip to content

Instantly share code, notes, and snippets.

View jackphelps's full-sized avatar

Jack Phelps jackphelps

View GitHub Profile
@jackphelps
jackphelps / diceware
Created November 14, 2022 04:01
friendly diceware words
from https://www.eff.org/files/2016/07/18/eff_large_wordlist.txt
11111 abacus
11112 abdomen
11113 abdominal
11114 abide
11115 abiding
11116 ability
11121 ablaze
11122 able
// https://twitter.com/settings/your_twitter_data/twitter_interests
// Right click on the page -> click "Inspect"
// click the "Console" tab
// Paste the below into the console text field that appears
// Due to rate limiting (or just twitter errors -- unclear), we leave a hefty timeout between requests
// This can take forever, leave the tab open and go for a walk or something
// Twitter also regularly adds more topics and auto-selects them
// There is no winning, only triage, but I've found this helps a bit with the rate of annoying interest suggestions
@jackphelps
jackphelps / CharacterFade.cs
Last active February 6, 2020 19:46
CharacterFade
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
namespace RPG.FX {
public class CharacterFade : MonoBehaviour
{
public static void Out(GameObject target, Materials dissolveMaterialToUse, Action callback, float duration = 1.5f)
@jackphelps
jackphelps / ahoy_event_ids
Created July 26, 2017 14:48
ahoy event ids with mismatching school_id / user.school_id
This file has been truncated, but you can view the full file.
```
skipped = 0
aes = []
Ahoy::Event.includes(:user).where("time > ?", 3.months.ago).find_each do |ae|
if ae.school_id.nil? || ae.user.nil? || (ae.user.school_id == ae.school_id)
skipped += 1
puts "skipped: #{skipped}"
else
aes << ae.id
puts "added: #{aes.size}"
Usage:
class MyModel
include ListAttributeHelper
KINDS = %w( stripe paypal )
scopes_and_identities :kind, KINDS
end
MyModel.paypal.size
=> 999
MyModel.stripe.last.stripe?
=> true
# Rails Controller Style Guide
## Table of Contents
1. [Authorizing Actions](#authorizing-actions)
1. [Action Patterns](#action-patterns)
1. [Request Formats](#request-formats)
1. [Response Codes](#response-codes)
## Authorizing Actions
@jackphelps
jackphelps / publicize_methods_for_debugging
Last active January 13, 2016 18:48
Make all of a class's private instance methods public (for debugging only, obviously)
class Object
def self.publicize_methods_for_debugging
list = private_instance_methods(false).map{|name| ":" + name.to_s}.join(", ")
eval("class #{self.name}; public #{list}; end")
end
end
# User.publicize_methods_for_debugging
@jackphelps
jackphelps / 1_intro_to_subject.rb
Created January 12, 2016 16:10 — forked from knzconnor/1_intro_to_subject.rb
A pattern for testing class methods in ruby with rspec explicit subjects
# RSpec's subject method, both implicitly and explicitly set, is useful for
# declaratively setting up the context of the object under test. If you provide a
# class for your describe block, subject will implicitly be set to a new instance
# of this class (with no arguments passed to the constructor). If you want
# something more complex done, such as setting arguments, you can use the
# explicit subject setter, which takes a block.
describe Person do
context "born 19 years ago" do
subject { Person.new(:birthdate => 19.years.ago }
it { should be_eligible_to_vote }

Keybase proof

I hereby claim:

  • I am jackphelps on github.
  • I am allworknoplay (https://keybase.io/allworknoplay) on keybase.
  • I have a public key whose fingerprint is 8787 ED80 BD69 D454 14E5 D1C1 8FDE 446C E8D2 C723

To claim this, I am signing this object:

@jackphelps
jackphelps / Rakefile
Last active August 29, 2015 14:22 — forked from jimweirich/Rakefile
#!/usr/bin/env ruby
require 'rake/clean'
require 'rake/testtask'
task :default => [:spec, :test]
task :spec do
sh "rspec ."
end