Skip to content

Instantly share code, notes, and snippets.

Ivan ivanyv

Block or report user

Report or block ivanyv

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
ivanyv / dnsmasq OS
Created Feb 27, 2018 — forked from ogrrd/dnsmasq OS
Setup dnsmasq on OS X
View dnsmasq OS

Never touch your local /etc/hosts file in OS X again

To setup your computer to work with *.dev domains, e.g., and so on, without having to add to your hosts file each time.



ivanyv /
Last active Nov 14, 2016
Exploring a monolith Rails architecture based on "domains" (which I call "modules")



The app is organized into "modules" (not Ruby modules), like "Core", "Admin", "Directory", etc.

Each module contains models, controllers, and every other related class.

When I say "modules", I'm actually talking about domains, so why call them modules? I'm actually torn on this as I like how "modules" fits much better. But I also know

ivanyv / application_form.rb
Created Jul 21, 2016
Easy form/service objects and decorators
View application_form.rb
# app/models/application_form.rb
module ApplicationForm
extend ActiveSupport::Concern
class_methods do
def model_name
# Project::Form.model_name => Project.model_name
ivanyv / application.amp.erb
Created Dec 12, 2015
Easy Google AMP on Rails
View application.amp.erb
<link rel="canonical" href="<%= current_uri_sans_amp %>">
View gist:379d0fbf6ca0853785c6
Verifying that +ivan is my openname (Bitcoin username).

Keybase proof

I hereby claim:

  • I am ivanyv on github.
  • I am ivanyv ( on keybase.
  • I have a public key whose fingerprint is 66D2 81C2 EAFF 19BA 9B22 4404 D0BB 1424 7607 0208

To claim this, I am signing this object:

ivanyv / globals.rb
Last active Dec 30, 2015
Crazy global variables
View globals.rb
require 'singleton'
class G
include Singleton
attr_accessor :variables
def self.[](var)
ivanyv / serialize.rb
Created Mar 17, 2012
Easy peasy serializer separation for DDD
View serialize.rb
# app/controllers/users_controller.rb
class UsersController < ApplicationController
respond_to :json, :xml
def show
@user = @user.find(params[:id])
respond_with Serializer(@user)
View base_model.rb
# app/models/my_model.rb
module MyApp
module Model
def self.included(base)
base.send :include, Mongoid::Document
base.send :include, Mongoid::Timestamps
base.send :include, ActiveAdmin::Mongoid::Patches
ivanyv / chunky_pixels.rb
Created Jul 1, 2011
Make chunky pixels the brute force way
View chunky_pixels.rb
require 'rubygems'
require 'chunky_png'
orig = ChunkyPNG::Image.from_file('input.png')
rows = (orig.width / 10.0).ceil
cols = (orig.height / 10.0).ceil
canvas = * 10, cols * 10).replace(orig)
(0...rows).each do |row|
x = row * 10
You can’t perform that action at this time.