Skip to content

Instantly share code, notes, and snippets.

View dcuadraq's full-sized avatar

David Cuadra dcuadraq

View GitHub Profile
@dcuadraq
dcuadraq / Gemfile
Last active August 29, 2015 14:16
Add existing rails project to heroku
# Ruby version has to be 1.9.3 or above, by default is 2.0
...
ruby '2.2.0'
# Heroku uses only supports Postgresql
# Check database.yml to make sure production is using postgresql
gem 'pg' #, group: :production # in case of using another db for development
gem 'rails', '4.2.0'
gem 'unicorn'
gem 'rails_12factor', group: :production
@dcuadraq
dcuadraq / game.rb
Last active August 29, 2015 14:17
Tic tac toe
module TicTacToe
class Game
# X starts
# Previous winner starts new game
# or which turn would have followed if draw
attr_reader :players, :grid, :turn
def initialize(args={})
@players = []
@dcuadraq
dcuadraq / archlinux_install.sh
Created November 5, 2015 05:32 — forked from julionc/archlinux_install.sh
Things to do after install ArchLinux (2012.12.01)
#!/usr/bin/env bash
# Things to do after install ArchLinux (2012.12.01)
pacman --noconfirm -S sudo
# Enabled archlinuxfr repo
arch=$(uname -m)
sudo cp /etc/pacman.conf /etc/pacman.conf.bak
echo "" >> /etc/pacman.conf
echo "[archlinuxfr]" >> /etc/pacman.conf
@dcuadraq
dcuadraq / sendgrid.rb
Created June 12, 2016 22:47
Wrapper for Sendgrid API v3
class Sendgrid
class << self
@@LISTS = {
newsletter: ENV.fetch('SENDGRID_LIST_NEWSLETTER_ID'),
}.with_indifferent_access
def add_mail_to_list(list_name, email, args={})
Rails.logger.info("SubscriptionWorker: Adding '#{email}' to sengrid list '#{list_name}'")
contact_name = args[:contact_name] || ''
subscribe_to_sendgrid(list_name, email, contact_name)
@dcuadraq
dcuadraq / vagrant.md
Last active August 7, 2016 19:58
Vagrant commands

#Vagrant

Creates and downloads if necesary a vm with Ubuntu 12.04 LTS

vagrant init hashicorp/precise32

Runs the VM of current directory

vagrant up
@dcuadraq
dcuadraq / Blogging.md
Last active November 14, 2016 07:38
Blogs options
@dcuadraq
dcuadraq / resources.md
Last active November 16, 2016 22:39
Social share

Javascript libraries

For webcam input, freeze and convert to img.

Whatsapp

Using a link you can open whatsapp on mobile and have a predefined text to be sent to 1 or more contacts. If it is 1, it will open the conversation and the text will be already typed but it can be edited. In case of selecting multiple contacts, the message will be sent individualy without being able to edit.

@dcuadraq
dcuadraq / unit1.md
Last active January 4, 2021 12:27
Effective Ruby notes

Accustoming Yourself to Ruby

ITEM 1: UNDERSTAND WHAT RUBY CONSIDERS TO BE TRUE

nil and false are the only objects evaluated as false.

!!nil == false # true
!!0 == false # false
false.nil? # false

ITEM 2: TREAT ALL OBJECTS AS IF THEY COULD BE NIL

@dcuadraq
dcuadraq / install_solidus.md
Last active January 11, 2018 07:20
How to install Solidus

#Solidus

Install imagemagick for thumbnail generation

brew install imagemagick

Create a new rails app

rails new solidus -d postgresql
@dcuadraq
dcuadraq / examples.md
Last active December 21, 2016 17:19
rack-attack gem

Examples

Block requests with matching header

class Rack::Attack
  throttle('req/ip', limit: 0, period: 1.second) do |req|
    req.ip if req.env['HTTP_X_SCANNER'] == 'Netsparker' ||
              req.params['email'] == 'netsparker@example.com'
  end
end