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
Gem::Specification.new do |s| | |
s.name = 'enumerable_collate' | |
s.version = '0.1.0' | |
s.platform = Gem::Platform::RUBY | |
s.author = 'Hugo Peixoto' | |
s.email = 'hugo.peixoto@gmail.com' | |
s.summary = 'Enumerable Collate' | |
s.description = 'Allows for iteration of multiple enumerables' | |
s.files = ['enumerable_collate.rb'] |
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
#include "post.h" | |
using app::models::Post; | |
template<> | |
const char Post::super::model_name_[] = "post"; | |
template<> | |
const Post::super::ColumnList Post::super::columns_ = { |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset='utf-8'> | |
</head> | |
<body> | |
<% Post::Set& posts = params.get("posts"); %> | |
<h1>It works!</h1> | |
<ul> |
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
## List herp derp file | |
sub is_herpderp | |
{ | |
my ($match) = "@_\n"; | |
my($file) = Irssi::get_irssi_dir."/herp"; | |
open my $fh, "<", $file; | |
return grep {uc($_) eq uc($match)} <$fh>; | |
} |
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
#include <limits> | |
extern "C" int printf (const char*, ...); | |
template<typename T, typename U> | |
T checked_static_cast(const U& a_value) | |
{ | |
if (a_value < std::numeric_limits<T>::min() || | |
a_value > std::numeric_limits<T>::max()) { | |
printf("Out of bounds value!\n"); | |
int x = *(int*)0; |
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
module EnumerationSupport | |
def self.included (base) | |
base.extend ClassMethods | |
end | |
module ClassMethods | |
def add_enumeration name, *keys | |
keys = keys.map { |key| key.to_s.tr(' ', '_').upcase } | |
const_set(name.to_s.upcase, Class.new do | |
keys.each do |key| |
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
class CategoriesTest < ActiveSupport::TestCase | |
def setup | |
@catalog = mock() | |
@interactor = StoreAPI::CategoriesInteractor.new(@catalog) | |
end | |
test "Should return the root categories" do | |
expected_categories = [mock(), mock(), mock()] | |
Category.stubs(:main_categories).returns(expected_categories) |
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 'store_api/categories' | |
class StoreAPI | |
def categories | |
StoreAPI::Categories.new # defined in store_api/categories.rb | |
end | |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset='utf-8'> | |
</head> | |
<body> | |
<h1>Editing post <%= post["name"] %></h1> | |
<%= form_for(post, [&](FormBuilder& f) { %> | |
<p><%= f.input("name") %></p> |
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
test "Should allow multiple locales" do | |
x = X.new | |
x.set_name("Herp", "en_US") | |
x.set_name("Erpo", "pt_PT") | |
assert_equal "Herp", x.get_name("en_US") | |
assert_equal "Erpo", x.get_name("pt_PT") | |
end |