Skip to content

Instantly share code, notes, and snippets.

View pedroassumpcao's full-sized avatar
🌎
Being blessed

Pedro Assumpcao pedroassumpcao

🌎
Being blessed
View GitHub Profile
@dcrec1
dcrec1 / centos
Last active March 24, 2017 11:52
ubuntu/centos nginx
cd /tmp
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
rpm -Uhv rpmforge-release*.rf.i386.rpm
yum install readline-dev htop
require 'yaml'
YAML::ENGINE.yamler= 'syck'
@kdabir
kdabir / validate_positive.md
Created December 12, 2012 05:49
rspec/shoulda validate only positive values (numericality)

for something like this in rails model

...  
validates :points, :numericality => {:greater_than_or_equal_to => 0}, :allow_nil => true
...

test can be :

it { should validate_numericality_of(:points) }

it { should_not allow_value(-1).for(:points) }

@henrik
henrik / rules.md
Last active May 23, 2022 12:31
Sandi Metz' four rules from Ruby Rogues episode 87. Listen or read the transcript: http://rubyrogues.com/087-rr-book-clubpractical-object-oriented-design-in-ruby-with-sandi-metz/
  1. Your class can be no longer than 100 lines of code.
  2. Your methods can be no longer than five lines of code.
  3. You can pass no more than four parameters and you can’t just make it one big hash.
  4. When a call comes into your Rails controller, you can only instantiate one object to do whatever it is that needs to be done. And your view can only know about one instance variable.

You can break these rules if you can talk your pair into agreeing with you.

@pricees
pricees / Splitting a Ruby on a Rail
Last active August 1, 2023 18:21
How I split a fat rails model
Background
Raise.com is built on top of Spree. We have in-lined spree, and have decorators
on the models to beat the band. We want to move away from Spree altogeher.
This involves taking the models from Spree, moving them to the Raise
base app. This merge has the potential to create lots of big classes. Big classes
are difficult to maintain. One of the first steps towards returning classes/models to
being "right sized." is splitting the business logic and the persistence.
What I did
@pricees
pricees / Ruby Basic
Last active August 29, 2015 13:56
My Ruby Litmus Test.rb
# Integer vs Float div by zero gotchas
#
#
1 / 0 = [answer]
1.0 / 0 = [answer]
1 / 0.0 = [answer]
0 / 0.0 = [answer]
# String concatenation vs interpolation
x = 5
@LeCoupa
LeCoupa / bash-cheatsheet.sh
Last active May 5, 2024 00:12
Bash CheatSheet for UNIX Systems --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
#!/bin/bash
#####################################################
# Name: Bash CheatSheet for Mac OSX
#
# A little overlook of the Bash basics
#
# Usage:
#
# Author: J. Le Coupanec
# Date: 2014/11/04
@faizaanshamsi
faizaanshamsi / Attribute
Last active January 11, 2016 17:38
Circle CI for Elixir
Taken and modified from: https://gist.github.com/joakimk/48ed80f1a7adb5f5ea27
* line 4 and 13 of circle.yml reference a script/ci structure. Modify to suit.
@somebox
somebox / domain-driven-desire-resources.md
Last active February 10, 2022 14:55
Domain-Driven Desire: Further Reading

Domain-Driven Desire: The Talk from Øredev 2016

🎥 https://vimeo.com/191051851

Links and References

Thanks for watching my talk, Domain-Driven Desire at Øredev 2016. Here's a list of resources that inspired me, and will hopefully inspire you:

Videos

@mjason
mjason / Dockerfile
Last active February 25, 2024 21:51
build phoenix in docker
FROM ubuntu:16.04
RUN apt-get update
RUN apt-get install -y git wget curl build-essential
RUN wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb && dpkg -i erlang-solutions_1.0_all.deb
RUN apt-get update
RUN apt-get install erlang -y
RUN apt-get install -y elixir
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash -