Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Oskar Szrajer gotar

🏠
Working from home
View GitHub Profile
@gotar
gotar / code.rb
Created Dec 13, 2019
ROM(PG, Sequel) + Dry-v example
View code.rb
#!/usr/bin/env ruby
require 'bundler/inline'
DB_URL = "postgres://localhost/gotar"
gemfile(true) do
source 'https://rubygems.org'
gem 'pg'
@gotar
gotar / code.rb
Created Dec 13, 2019
ROM (SQLite) + DRY-V example
View code.rb
#!/usr/bin/env ruby
require 'bundler/inline'
DB_URL = "postgres://localhost/gotar"
gemfile(true) do
source 'https://rubygems.org'
gem 'rom', '~> 5.1'
View vimrc
set nocp
set encoding=utf-8
call plug#begin('~/.vim/plugged')
let g:plug_url_format = 'git@github.com:%s.git'
Plug 'kien/ctrlp.vim'
Plug 'rking/ag.vim'
Plug 'tpope/vim-bundler'
@gotar
gotar / .vimrc
Created Aug 11, 2016
vimrc file
View .vimrc
set nocp
set encoding=utf-8
call plug#begin('~/.vim/plugged')
Plug 'kien/ctrlp.vim'
Plug 'rking/ag.vim'
Plug 'tpope/vim-bundler'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-endwise'
@gotar
gotar / db.rake
Created May 16, 2016 — forked from rpanachi/db.rake
Rakefile for Sequel database operations
View db.rake
namespace :db do
require 'sequel'
Sequel.extension(:migration)
MIGRATIONS_PATH = 'db/migrations'
def db_conn_env
ENV["BOOKSHELF_DATABASE_URL"]
end
View combine.rb
chat: {
id: 1,
owner_id: 1,
member_id: 2
}
user1: {
id: 1
name: 'Foo'
}
View test_mapper.rb
require 'rom-mapper'
class MyMapper1 < ROM::Mapper
reject_keys true
attribute :foo, from: [:bar, :baz] do |bar, baz|
[bar, baz]
end
end
@gotar
gotar / json_api.rb
Created Aug 12, 2015
Mapping raw tuple to jsonapi using rom-mapper and yaks
View json_api.rb
require 'anima'
require 'rom-mapper'
require 'yaks'
class User
include Anima.new(:id, :first_name, :last_name, :posts)
end
class Post
include Anima.new(:id, :title)
View gist:e695cc88b1884f90f570
require 'transproc/all'
require 'addressable/uri'
##
# Convert string keys to symbols
#
transform = Transproc(:symbolize_keys)
data = {
'name' => 'Mark Rickerby',
View 1_create_products.rb
Sequel.migration do
up do
run 'CREATE EXTENSION "uuid-ossp"'
create_table :products do
column :id, :uuid, :default => Sequel.function(:uuid_generate_v4), :primary_key => true
end
end
end