Skip to content

Instantly share code, notes, and snippets.

View rewinfrey's full-sized avatar
🏄‍♂️
fix f = let x = f x in x

Rick Winfrey rewinfrey

🏄‍♂️
fix f = let x = f x in x
View GitHub Profile
@rewinfrey
rewinfrey / gist:5991867
Created July 13, 2013 19:13
Three things for Alfonzo
1. Seperate all input and output from your core classes and push those methods into an IOGame class
2. Use methods or functions to determine state, rather than always maintaining state with explicit set methods
3. Use attr_reader rather than attr_accessor, and define your initialize contract for classes to take in all the data needed, rather than setting that data after instantiating an object
ex.
this is preferable:
player1 = Human.new("X", io_object)
rather than:
player1 = Human.new
@rewinfrey
rewinfrey / gist:6008987
Created July 16, 2013 14:03
How to test IO in Ruby
class GameIO
attr_reader :game_input, :game_output
def initialize(input = $stdin, output = $stdout)
@game_input = input
@game_output = output
end
def output(msg)
game_output.puts msg
@rewinfrey
rewinfrey / rails_console
Created July 18, 2013 15:09
Useful Rails Console
Use app:
>> app.project_path(Project.first)
=> "/projects/130349783-with-attachments"
>> app.get "/735644780/projects/605816632-bcx.atom"
=> 200
>> app.response.body
=> "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<feed xml:lang=\"en-US\" ...
@rewinfrey
rewinfrey / configuration_example
Created July 22, 2013 16:51
Configuration example
class BGCCronInterval
def initialize(options)
@completion_reminder = options[:background_check_completion_reminder]
validate_options!
end
def cron_interval
@completion_reminder[:cron_interval]
end
@rewinfrey
rewinfrey / gist:6250580
Created August 16, 2013 14:50
Email with quoted text
Hi,
On Tue, 2011-03-01 at 18:02 +0530, Abhishek Kona wrote:
> Hi folks
>
> What is the best way to clear a Riak bucket of all key, values after
> running a test?
> I am currently using the Java HTTP API.
You can list the keys for the bucket and call delete for each. Or if you
put the keys (and kept track of them in your test) you can delete them
@rewinfrey
rewinfrey / dependency_injection
Created August 22, 2013 19:32
Dependency Injection Example
class Something
def injectable(injected_object)
injected_object.must_respond_to_this
end
end
class SomethingElse
def injectable(injected_object)
injected_object.must_respond_to_this
end
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@rewinfrey
rewinfrey / goog.fx event types
Created September 18, 2013 20:44
goog.fx drag drop events
goog.fx.AbstractDragDrop.EventType = {
DRAGOVER: 'dragover',
DRAGOUT: 'dragout',
DRAG: 'drag',
DROP: 'drop',
DRAGSTART: 'dragstart',
DRAGEND: 'dragend'
};
source: http://docs.closure-library.googlecode.com/git/closure_goog_fx_abstractdragdrop.js.source.html#line184
@rewinfrey
rewinfrey / es_configuration
Created October 16, 2013 15:43
ES configuration
configuration file changes:
1. index.store.type: mmapfs
- memory mapped files utilize OS caches better
2. indices.memory.index_buffer_size: 30%
- more buffers allow ES to hold and handle more data horizontally (increases from default 10%)
3. index.refresh_interval: 5s
@rewinfrey
rewinfrey / java_proxy_log
Created October 28, 2013 19:36
java proxy log
% ./gradlew tomcatRun -Des.configFile=elasticsearch.yml
To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: http://gradle.org/docs/1.8/userguide/gradle_daemon.html.
The ConfigurationContainer.add() method has been deprecated and is scheduled to be removed in Gradle 2.0. Please use the create() method instead.
The TaskContainer.add() method has been deprecated and is scheduled to be removed in Gradle 2.0. Please use the create() method instead.
:QueryRelevancyProxy:compileJava UP-TO-DATE
:QueryRelevancyProxy:processResources UP-TO-DATE
:QueryRelevancyProxy:classes UP-TO-DATE
:QueryRelevancyProxy:tomcatRun
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/vagrant/.gradle/wrapper/dists/gradle-1.8-bin/vruqmccc8532n7gr46qavsii8/gradle-1.8/lib/logback-classic-1.0.9.jar!/org/slf4j/impl/StaticLoggerBinder.class]