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
require "payment_service/authorize_payment" # This defines PaymentService::AuthorizePayment class | |
require "payment_service/authorization_error" # This defines PaymentService::AuthorizatonError class | |
require "payment_service/successful_authorization_workflow" # This defines PaymentService::SuccessfulAuthorizationWorkflow class | |
require "payment_service/payment_repository" # This defines PaymentService::PaymentRepository class | |
module PaymentService | |
def self.authorize_payment(token) | |
response = AuthorizePayment.new(token).execute | |
if response.success? |
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
# This is similar to a controller in rails | |
# each method represents a verb/action from rest | |
class User < Resource | |
include JsonRendering | |
def options | |
end | |
def head |
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
#!/bin/bash | |
# install homebrew | |
echo "installing homebrew" | |
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | |
echo "install homebrew bundle" | |
brew tap Homebrew/bundle | |
# pull down a brewfile |
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
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D | |
echo " deb http://apt.dockerproject.org/repo debian-jessie main" | sudo tee /etc/apt/sources.list.d/docker.list | |
echo " deb http://cdn.rawgit.com/sebglazebrook/debian-pkg-repo/0bc3575813da95c899b72a8a91b06e9c8e6d35e4 jessie main" | sudo tee /etc/apt/sources.list.d/sebglazebrook.list | |
sudo apt-get update | |
sudo apt-get install --yes --force-yes seb-dev-env |
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
let file_path = "my.test".to_string(); | |
let mut file = File::create(file_path).unwrap(); | |
file.write_all("ls".as_bytes()); | |
let mut process = Command::new("source") | |
.arg(file_path) | |
.spawn() | |
.unwrap_or_else(|e| { panic!("failed to execute child: {}", e) }); |
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
struct Foo<'a> { | |
collection: Vec<usize>, | |
matches: Vec<&'a usize>, | |
} | |
impl<'a> Foo<'a> { | |
pub fn new() -> Self { | |
Foo { collection: vec![1,2,3,4,5,6] , matches: vec![] } | |
} |
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
use std::sync::{Arc, Mutex}; | |
use std::sync::mpsc::*; | |
fn main() { | |
let (tx, rx):(Sender<_>, Receiver<_>) = channel(); | |
} | |
src/main.rs:21:18: 21:42 error: unable to infer enough type information about `_`; type annotations or generic parameter binding required [E0282] | |
src/main.rs:21 let (tx, rx):(Sender<_>, Receiver<_>) = channel(); //??????? | |
^~~~~~~~~~~~~~~~~~~~~~~~ |
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
fn main() { | |
let monitors = monitor_factory::create_all(); | |
for monitor in monitors.iter() { | |
let current_monitor = monitor.clone(); | |
thread::spawn(move || { | |
current_monitor.run(); | |
}).join(); | |
} | |
} |
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
require 'active_support' | |
# To use this make sure you add `include MethodLogger` at the END of your class definition | |
# Otherwise the methods you want aliased are not declared yet. | |
module MethodLogger | |
def self.logger | |
@@logger ||= Logger.new("#{Rails.root}/log/method_logger.log") | |
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
# Came across an issue when working on a serializer/deserializer | |
# needed to know whether something was array like or hash like. | |
class Object | |
def array_like? | |
self.respond_to?(:each) && respond_to?(:at) | |
end | |
def hash_like? |
NewerOlder