Skip to content

Instantly share code, notes, and snippets.

View xdougx's full-sized avatar

Douglas Rossignolli xdougx

View GitHub Profile
class @ButtonsFactory
# recebe os dados do botão como href, id, class, text e html
constructor: (params) ->
button = $("<a>")
for (key, value) in params
button.attr(key, value)
button

Setting up a SSL Cert from Comodo

I use Namecheap.com as a registrar, and they resale SSL Certs from a number of other companies, including Comodo.

These are the steps I went through to set up an SSL cert.

Purchase the cert

@xdougx
xdougx / solr_cap.rb
Last active August 29, 2015 14:20 — forked from doitian/solr_cap.rb
namespace :deploy do
task :setup_solr_data_dir do
run "mkdir -p #{shared_path}/solr/data"
end
end
namespace :solr do
desc "start solr"
task :start, :roles => :app, :except => { :no_release => true } do
run "cd #{current_path} && RAILS_ENV=#{rails_env} bundle exec sunspot-solr start --port=8983 --data-directory=#{shared_path}/solr/data --pid-dir=#{shared_path}/pids"
@xdougx
xdougx / searching.rb
Last active July 20, 2016 14:47
A intenção era só simplificar e ganhar todos os métodos sem precisar fazer muito, é muito simples fazer em uma classe desprendida do ActiveRecord
module Searchable
included do
scope :gender, ->(gender) { where(:gender => gender) }
scope :birth_on, ->(date) { where(:birthdate =>date) }
scope :birth_before_than, ->(date) { where("#{quoted_table_name}.birthdate < ?", date) }
scope :birth_after_than, ->(date) { where("#{quoted_table_name}.birthdate > ?", date) }
scope :profile, ->(profile){ where(:profile => profile) }
end
module ClassMethods
@xdougx
xdougx / class_property.cr
Last active October 19, 2015 16:04
Macro for Cystal to include class property
module ClassProperty
macro class_property(*names)
class_getter {{*names}}
class_setter {{*names}}
end
macro class_property?(*names)
class_getter? {{*names}}
class_setter {{*names}}
end
@xdougx
xdougx / runner.rb
Created October 21, 2015 12:45
bench test with array concat
require "crystal_executer/version"
require "active_support/core_ext/hash"
require "benchmark"
module ModuleBench
class Runner
def self.exec path, params = {}
m1 = Benchmark.bm do |x|
x.report("Ruby") do
a = []
@xdougx
xdougx / database.yml
Last active October 21, 2015 13:31
build an database connection with PG
development:
encoding: utf8
port: 5432
database: development
username: username
password:
host: localhost
---
test:
encoding: utf8
@xdougx
xdougx / database.yml
Created October 21, 2015 13:06
database example
development:
encoding: utf8
port: 5432
database: development
username: username
password:
host: localhost
---
test:
encoding: utf8
Error in ./boot.cr:12: instantiating 'Importation::Base#import()'
Importation::Base.new(App.new).import
^~~~~~
in ./app/importation/base.cr:31: instantiating 'Importation::Runner#run()'
Importation::Runner.new(self, path).run
^~~
def search_city(city = "")
until hashcity.include?(city) do
city = gets.chomp
end
end