Skip to content

Instantly share code, notes, and snippets.

class SomeServiceWithApplyAndCall < CRUD::CreateService
def apply(attributes, to_one, to_many, options)
self.(attributes[:name], to_one[:foo], to_many[:bar])
end
def call(name, foo_id, bar_ids)
# the real service stuff
end
module Orders
module Teams
class CreateTeam < FoodeeService
dependency :client_dao, Client
# @param [Client] client_id
def call(client_id, name = nil)
client = client_dao.find client_id
function fizzBuzz(n) {
for(let i = 0; i < n; i++){
const mod3 = i % 3;
const mod5 = i % 5;
let str;
if ( mod3 == 0 && mod5 == 0){
str = "FizzBuzz"
}
let fizzbuzz = (i) =>
switch (i mod 3, i mod 5) {
| (0, 0) => "FizzBuzz"
| (0, _) => "Fizz"
| (_, 0) => "Buzz"
| _ => string_of_int(i)
};
for (i in 1 to 100) {
Js.log(fizzbuzz(i))
# JSONAPI::RelationshipBuilder#define_relationship_methods
# model_class.ancestors.collect{|ancestor| ancestor.name}.include?('ActiveRecord::Base')
# replace with this
if model_class && model_class < ActiveRecord::Base
import Ember from 'ember';
const {
Component
} = Ember;
/**
* Wrapper around "semantic-ui-daterangepicker#~1.3.21",
*/
import Ember from 'ember';
const {
Component
} = Ember;
/**
* Wrapper around "semantic-ui-daterangepicker#~1.3.21",
*/
# Create a global connection pool at parse time
$redis_connection_pool = ConnectionPool::Wrapper.new(
size: ENV['REDIS_CONNECTION_POOL_SIZE'] || ENV['RAILS_MAX_THREADS'] || 5,
timeout: ENV['REDIS_CONNECTION_TIMEOUT'] || 3) {
Redis.new(url: ENV['REDIS_URL'])
}
# Helper for returning a redis client from the with or without a namespace
def with_redis(namespace = nil)
$redis_connection_pool.with do |connection|
class Foo {};
let foos = [];
let interval;
interval = setInterval(() => {
foos.push(new Foo());
if(foos.length > 10000) {
clearInterval(interval);
console.log('done');
class Foo {};
window.foo = new Foo();