Skip to content

Instantly share code, notes, and snippets.

View robyurkowski's full-sized avatar

Rob Yurkowski robyurkowski

View GitHub Profile
require "dry-types"
module DryTS
# We use this method to mark a type for inclusion in our generated TS types.
def ts_export(_assigned_type)
extract_constants!
# ... Other stuff for exporting TS
end
def extract_constants!
module Web
class Application < Lotus::Application
configure do
##
# BASIC
#
# Define the root path of this application.
# All the paths specified in this configuration are relative to this one.
#
def publish_form(slug_unique, publishable, document)
PublishFormRenderer.render(slug_unique: slug_unique, publishable: publishable, document: document, context: self)
end
@robyurkowski
robyurkowski / skywalker-slash-command.rb
Created December 9, 2014 14:21
override skywalker transaction for non-transactional ORMs
require 'skywalker/command'
module Skywalker
class Command
def transaction(&block)
block.call
end
end
end
require 'active_record'
module Skywalker
class Command
################################################################################
# Class interface
################################################################################
def self.call(*args)
new(*args).call
end
private def confirm_failure(error)
self.error = error
run_failure_callbacks
end
private def run_failure_callbacks
# This line fails because on_failure responds_to #call ?!
on_failure.call(self) if on_failure.respond_to?(:call)
end
@robyurkowski
robyurkowski / comments_new_route.js
Last active August 29, 2015 14:03
sending reload to parent route
App.CommentsNewRoute = Ember.Route.extend({
model: function() {
return this.store.createRecord('comment', {post: this.modelFor('post')});
},
actions: {
save: function() {
var model = this.modelFor('commentsNew');
model.save().then(
array = %w(dog cat aardvark)
array.each {|animal| puts animal.upcase }
array.map! {|animal| animal.reverse }
array.select {|animal| animal.include? 'a' }
array.sort_by(&:length)
array << 'dog'
array.uniq!
hash = {cat: "meow", dog: "woof", aardvark: "sluuurp"}
hash.keys.join(" and ")
Ember.Application.initializer({
name: 'debug'
initialize: (container, app) ->
app.d = app.debug =
controller: (name) -> container.lookup("controller:#{name}")
c: (name) -> container.lookup("controller:#{name}")
route: (name) -> container.lookup("route:#{name}")
r: (name) -> container.lookup("route:#{name}")
Meloria.Customer = DS.Model.extend({
name: DS.attr('string'),
phone: DS.attr('string'),
email: DS.attr('string'),
dateOnWaitingList: DS.attr('date'),
status: DS.attr('number'),
local: DS.attr('boolean'),