Skip to content

Instantly share code, notes, and snippets.

View patmaddox's full-sized avatar
🤔
Trying to figure out how to look up comments I've left

Pat Maddox patmaddox

🤔
Trying to figure out how to look up comments I've left
View GitHub Profile
@patmaddox
patmaddox / environments_production.rb
Last active August 29, 2015 13:57
<srbaker>SOLVED</srbaker>
default_attributes chef_user: "ubuntu"
default_attributes { ... a whole mess of other stuff which apparently blows away the first line. whoops }
@patmaddox
patmaddox / gist:9100174
Created February 19, 2014 19:50
how to stop twitter from spamming your iPhone
Hi, your instructions kind of suck but I figured it out. Here's how to actually do it:
From the iOS app...
1) Go to the Me tab, tap the gear icon, then click settings
2) Tap on the account name to open the notifications settings for that account (critical missing piece of info)
3) Disable "Recommendations" "news" and "other"
Pat
[1] pry(main)> hash = {a: 1, b: 2, c: 3}
=> {:a=>1, :b=>2, :c=>3}
[2] pry(main)> class Hash
[2] pry(main)* def retrieve_keys(*keys)
[2] pry(main)* self.reduce({}) { |h, (k, v)|
[2] pry(main)* keys.include?(k) ? h.merge!({k => v}) : h
[2] pry(main)* }
[2] pry(main)* end
[2] pry(main)* end
=> nil
something = case option_type
when OptionType then "do this"
when String then "do this thing"
else "how about this"
end
something = if option_type.class == OptionType
"do this"
elsif option_type.class == String
"do this thing"
require 'timeout'
class SearchesController
def post
search = Search.create! params[:search]
begin
timeout(3) do
while result.nil?
result = Cache.fetch(search.results_id)
end
@patmaddox
patmaddox / example.rb
Created January 3, 2014 01:15
for Casey
class ApplicationController
def require_login
unless current_user
session[:return_to] = request.uri
redirect_to login_path
end
end
end
class LoginsController
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAzZE5kpRiXxpiSndA/lf+0fcirZB+YUb5RUMdyU0Y/kWK7U1TiAvblfGtThJCjq5lkogEFupuDfG4vSO9z1qPNawDlvwqGjwPL5NMKL7aaFlJVzejY2wvGhZ1++rr0JeEFWGkZaIwtp9ywcXOBkGcuF8inzvtEXiCNzexjp1mWebSg5xg62kd5AfZUf7u/bxrDG+LMe2bk2xLVwp3Fnto+eCNMt938ingsOZIMGu8wplr6f6tELm3zQNRsd1cu1WPzyGZqeenmG/PmGGtZauLcWpkLVSWKuMkd/cK4n7EmBBsDkIre7wN5SGAihI7pB4YfkBG1fFHTA0LLrCYrikbBQ== patmaddox@me.com
TestCase < #SUnitTest.
- test
self testRun.
- testRun
| test |
test := WasRun newWithName: 'testMethod'.
Transcript show: '!!!!!!!!!!'; show: test log; cr.
self assert: test log size equals: 0 withMessage: 'test log should be empty'.
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:297)
at java.lang.Thread.run(Thread.java:679)
Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to java.util.ArrayList
at st.redline.core.PrimObject.p220(PrimObject.java:541)
at st.redline.core.SequenceableCollection$M2.invoke(st/redline/core/SequenceableCollection.st:8)
Object < #STestCase
instanceVariableNames: 'name'.
+ newWithName: aString
^ self new name: aString; yourself.
- name: aString
name := aString.
- run