This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# Growing Object Oriented Software | |
# Tell, don't ask approach | |
# Tested and learned the principle | |
class SomeProgram | |
def self.runit | |
# Printer is the main purpose | |
# Later I might want to Log, IM, Email or Ping something about the printing result. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# place in config/initalizers | |
module ActiveRecord | |
class Base | |
# Establishes a connection to the database that's used by all Active Record objects. | |
def self.mysql2_connection(config) | |
config[:username] = 'root' if config[:username].nil? | |
if Mysql2::Client.const_defined? :FOUND_ROWS | |
config[:flags] = Mysql2::Client::FOUND_ROWS | Mysql2::Client::MULTI_STATEMENTS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'active_ldap' | |
ActiveLdap::Base.setup_connection( | |
:host => 'ldap.example.com', | |
:base => 'dc=example,dc=com', | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## conduce - be conducive to; "The use of computers in the classroom lead to better writing" | |
# | |
# a model+view component for rails that combines the conductor and presenter | |
# pattern via a model capable of generating view-centric methods | |
# | |
module Conducer | |
# base class | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% flash.each do |type, message| %> | |
<div class="alert <%= bootstrap_class_for(type) %> fade in"> | |
<button class="close" data-dismiss="alert">×</button> | |
<%= message %> | |
</div> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// layout file | |
<body> | |
<div class="container"> | |
<%= flash_messages %> | |
<%= yield %> | |
</div><!-- /container --> | |
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import { render } from "react-dom"; | |
const ParentComponent = React.createClass({ | |
getDefaultProps: function() { | |
console.log("ParentComponent - getDefaultProps"); | |
}, | |
getInitialState: function() { | |
console.log("ParentComponent - getInitialState"); | |
return { text: "" }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def stub_request | |
faraday_stub = Faraday.new do |builder| | |
builder.adapter :test do |stub| | |
stub.post('/api/service', {id: '111', data: {'a': 1}}) {|env| [200, {}, mock_response]} | |
stub.get('/api/another_service', {query: 'foo'}) {|env| [200, {}, second_mock_response]} | |
end | |
end | |
Service::Something.stubs(:connection).returns(faraday_stub) | |
end |