Skip to content

Instantly share code, notes, and snippets.

@israelb
israelb / rich_domain_models2.md
Created February 20, 2017 02:07 — forked from vsavkin/rich_domain_models2.md
Building Rich Domain Models in Rails (revision 2)

Building Rich Domain Models in Rails.

Part 1. Decoupling Persistence.

Abstract

Domain model is an effective tool for software development. It can be used to express really complex business logic, and to verify and validate the understanding of the domain among stakeholders. Building rich domain models in Rails is hard. Primarily, because of Active Record, which doesn't play well with the domain model approach.

One way to deal with this problem is to use an ORM implementing the data mapper pattern. Unfortunately, there is no production ready ORM doing that for Ruby. DataMapper 2 is going to be the first one.

Another way is to use Active Record just as a persistence mechanism and build a rich domain model on top of it. That's what I'm going to talk about in this article.

@israelb
israelb / README.md
Created February 27, 2017 16:43 — forked from oodavid/README.md
Deploy your site with git

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/
@israelb
israelb / db.rake
Created March 5, 2017 19:59 — forked from hopsoft/db.rake
Rails rake tasks for dump & restore of PostgreSQL databases
# lib/tasks/db.rake
namespace :db do
desc "Dumps the database to db/APP_NAME.dump"
task :dump => :environment do
cmd = nil
with_config do |app, host, db, user|
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump"
end
puts cmd
@israelb
israelb / accounts_controller.rb
Created March 9, 2017 17:31 — forked from jeremyw/accounts_controller.rb
Testing Rails 4 strong parameters
class AccountsController < ApplicationController
def update
@account = Account.find(params[:id])
respond_to do |format|
if @account.update_attributes(account_params)
format.html { redirect_to @account, notice: 'Account was successfully updated.' }
else
format.html { render action: "edit" }
end
@israelb
israelb / postgres-cheatsheet.md
Created March 24, 2017 23:11 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

If run with -E flag, it will describe the underlaying queries of the \ commands (cool for learning!).

Most \d commands support additional param of __schema__.name__ and accept wildcards like *.*

@israelb
israelb / interfaces.go
Last active April 4, 2017 02:20
golang
package main
import (
"fmt"
"time"
)
type guestConnection struct {
ip string
userName string
// chat/httpservice/main.go
package httpService
import (
"fmt"
"time"
)
func SendNotification() {

#Documentación GoLang Español

Detalles

  • Escribo todo al mismo tiempo que nos capacitan para poder reflejar y expresar bien lo que nos dicen los chicos de GrupoEsfera.
  • Me inspiré mucho con los ejemplos y dichos de GoTour, pero traté de complementarlos con el conocimiento de Diego.
  • Separé Variables, Punteros, Estructuras, Slices y Mapas porque me parecen conceptos deberían tener sus propias secciones para no confundir(me).
  • Si me confundo Pointer Receiver y Pointer Retriever, no es mi culpa.
@israelb
israelb / AWS Git Setup.md
Created June 8, 2017 15:49 — forked from matthewoden/AWS Git Setup.md
Setting up a remote Git in AWS EC2

AWS Remote Git Setup

Get a local git repo up on an EC2 Instance.

Add youself to SSH Authentication:

Add yourself to the ssh auth agent, if you haven't already.

ssh-add path/to/your/EC2.pem

Set up destination directory:

@israelb
israelb / mgoExample.go
Created July 11, 2017 02:40 — forked from border/mgoExample.go
mgo example
package main
import (
"fmt"
"labix.org/v2/mgo"
"labix.org/v2/mgo/bson"
"time"
)
type Person struct {