Skip to content

Instantly share code, notes, and snippets.

View zerobatu's full-sized avatar

Claudio Alvarado zerobatu

  • Santiago, Chile
View GitHub Profile
@zerobatu
zerobatu / applicationController
Created July 25, 2013 21:14
helper_method error
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
private
def current_tenancy
Tenancy.find_by_subdomain! request.subdomain
end
helper_method :current_tenancy
n = gets.chomp
input = gets.chomp
input = input.split(" ").map { |x| x.to_i }
taxi = input.count(4)
tres = input.count(3)
dos = input.count(2)
uno = input.count(1)
taxi += tres
@zerobatu
zerobatu / gist:d1f1a91f63857f84474f
Last active August 29, 2015 14:17
revisa lista de mail de un texto
// limpia los espacios
var emailTrim = function(e) { return e.trim(); }
// filtra los textos en blanco
var filterMails = function(e) { return e.trim() !== "" }
// retorna los mail invalidos
var validMail = function(e) {
var re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return !e.match(re);
<!-- expect this -->
<soap:Body>
<UploadLogo>
<loginId>string</loginId>
<url>string</url>
</UploadLogo>
</soap:Body>
<!-- but savon return this -->
@zerobatu
zerobatu / read-access.sql
Last active May 18, 2018 19:54 — forked from oinopion/read-access.sql
How to create read only user in PostgreSQL
-- Create a group
CREATE ROLE readaccess;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO readaccess;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess;
-- Grant access to future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess;
@zerobatu
zerobatu / postgresql_configuration_on_ubuntu_for_rails.md
Created June 11, 2018 21:09 — forked from p1nox/postgresql_configuration_on_ubuntu_for_rails.md
PostgreSQL configuration without password on Ubuntu for Rails

Abstract

You could have postgre installed on localhost with password (or without user or password seted after instalation) but if we are developing we really don't need password, so configuring postgre server without password for all your rails project is usefull.

Install Postgre packages

  • postgresql
  • postgresql-client
  • libpq-dev

Keybase proof

I hereby claim:

  • I am zerobatu on github.
  • I am calvarado (https://keybase.io/calvarado) on keybase.
  • I have a public key ASB1V-yMjdIyW4Z2fC4bvhVTJYwKU6ugmitm3KHkKHGvYQo

To claim this, I am signing this object:

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCxmq+w6TaQxySxb3IJP3EDYfH7EAsnvyKvYi2nvDiS4LxPe4GvEpH5VoN+mlqxQBIFzUOSaJCaUaAtdbZ3pTRxeC8Z8Shm8fkQfHXxesKVhfyZg4gURdurMJ9iS6QuN/zjPz64xb1ASvpcD3ogYY4P25A97C+zrmuK5vYfqu2RNzO4ijOWDgvbZ8GNms3jQslXVUsEM5KCJfSX3ikh0R2ufW+cn0qD6yDpBqiIjVbzqbhc55cNzy8auMT19VLuNmjfFzCdFjKQ+MC49trSEySL1jP7t4BkQtwhMzyFgxrS05W5GUM9Ud0ZWVdYfGWkdbOigX5zGCGDN/U4TIX8+kLF calvarado@development