Skip to content

Instantly share code, notes, and snippets.

View timriley's full-sized avatar
🇺🇦
Standing with Ukraine

Tim Riley timriley

🇺🇦
Standing with Ukraine
View GitHub Profile
@janko
janko / 0-gemfile.rb
Created July 31, 2016 11:24
Using Shrine with ROM and dry-rb
source "https://rubygems.org"
gem "shrine", github: "janko-m/shrine"
gem "rom-repository"
gem "rom-sql"
gem "sqlite3"
gem "dry-validation"
gem "roda"
gem "sucker_punch", "~> 2.0"
@cheeaun
cheeaun / rdrc2016.md
Last active June 13, 2018 08:39
RedDotRubyConf 2016 links & resources 😘
@solnic
solnic / fun.rb
Last active December 26, 2015 23:29
Ruby object that has "functions" rather than methods
class Function
attr_reader :name, :fn
class Composed
attr_reader :left, :right
def initialize(left, right)
@left = left
@right = right
end
@solnic
solnic / output.txt
Last active November 12, 2015 14:52
many-to-many with rom repo
I, [2015-11-11T18:21:57.978652 #52590] INFO -- : (0.000162s) CREATE TABLE `users` (`id` integer NOT NULL PRIMARY KEY AUTOINCREMENT, `name` varchar(255))
I, [2015-11-11T18:21:57.978842 #52590] INFO -- : (0.000069s) CREATE TABLE `groups` (`id` integer NOT NULL PRIMARY KEY AUTOINCREMENT, `name` varchar(255))
I, [2015-11-11T18:21:57.979020 #52590] INFO -- : (0.000062s) CREATE TABLE `users_groups` (`user_id` integer REFERENCES `users`, `group_id` integer REFERENCES `groups`)
I, [2015-11-11T18:21:57.979194 #52590] INFO -- : (0.000039s) INSERT INTO `users` (`id`, `name`) VALUES (1, 'Jane')
I, [2015-11-11T18:21:57.979321 #52590] INFO -- : (0.000027s) INSERT INTO `groups` (`id`, `name`) VALUES (1, 'Admins')
I, [2015-11-11T18:21:57.979398 #52590] INFO -- : (0.000025s) INSERT INTO `groups` (`id`, `name`) VALUES (2, 'Editors')
I, [2015-11-11T18:21:57.979486 #52590] INFO -- : (0.000025s) INSERT INTO `users_groups` (`user_id`, `group_id`) VALUES (1, 1)
I, [2015-11-11T18:21:57.979558 #52590] INFO -- : (0.000026s) IN
@xaviershay
xaviershay / standalone_rom_sql.rb
Created July 20, 2015 02:00
Standalone script to play around with ROM. http://rom-rb.org/
# Standalone script to try http://rom-rb.org/ with a database
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'rom'
gem 'rom-sql'
gem 'rom-rails'
gem 'activemodel'
@kottenator
kottenator / simple-pagination.js
Created July 13, 2015 20:44
Simple pagination algorithm
// Implementation in ES6
function pagination(c, m) {
var current = c,
last = m,
delta = 2,
left = current - delta,
right = current + delta + 1,
range = [],
rangeWithDots = [],
l;
@geelen
geelen / 1_Readme.md
Last active August 29, 2015 14:21
Traits

Global traits, local components

The idea is to combine the best bit of global styling (reuse, small payload) and local styling (total isolation, first-class React syntax)

This is combined with the concept of traits: you can think of them as permitted property/value pairs. Instead of every component being able to have every CSS property available to it, you can reduce your permitted set to X font families, Y font-size + line-height pairs, Z foreground/background colour pairs, W padding amounts. This is based off my work using amcss on real projects — traits were the single key feature that kept me using AM.

The one-sentence explanation: A site defines a set of permitted visual features, all components are simply a combination of those features

Definitions

@Ashton-W
Ashton-W / Breakpoints_v2.xcbkptlist
Last active January 25, 2023 09:28
My User Breakpoints_v2.xcbkptlist
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "2"
version = "2.0">
<Breakpoints>
<!-- All Exceptions -->
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
<BreakpointContent
@henrik
henrik / augmentations.rb
Last active August 29, 2015 14:18
Ruby mixins that support class method definitions and calls just as you would in the class itself, without (ab)using the self.included hook. Modified version of https://github.com/henrik/augmentations to support block arguments.
# By Henrik Nyh 2015-04-02 under the MIT license.
class ::Object
def self.augment(*mods, **opts)
mods.each { |mod| class_exec **opts, &mod.augmentation }
end
end
class ::Module
def augmentation(**opts, &block)
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.