Skip to content

Instantly share code, notes, and snippets.

View dbalexandre's full-sized avatar

Douglas Barbosa Alexandre dbalexandre

View GitHub Profile
@joaomdmoura
joaomdmoura / enrich_csv_clearbit.rb
Last active August 17, 2021 20:46
Ruby script to enrich company data based on a email column in a CSV
# Before running this make sure you have Ruby installed
# preference to version > 2.4
#
# Also install the clearbit library, after the ruby
# installation, to do it you just run:
# $ gem install clearbit
#
# Then, you run a ruby console on the same directory of this file
# and the following commands:
#
@benbartling
benbartling / db.rake
Created November 17, 2017 21:24
Rake Task - Restore Heroku Postgres to Local DB - Ruby on Rails
#CAPTURE NEW: rails db:restore_from_production\[capture\]
#DOWNLOAD LATEST: rails db:restore_from_production\[download\]
#RESTORE: rails db:restore_from_production
#[HEROKU_APP_NAME] = Name of your heroku app.
#[NUMBER_OF_CORES] = Number of concurrent jobs to run for pg_restore.
namespace :db do
desc 'Pull down the latest backup from Heroku and rebuild your local database with it.'
task :restore_from_production, [:process] => :environment do |task, args|
import requests
from requests.auth import HTTPBasicAuth
import re
from StringIO import StringIO
JIRA_URL = 'https://your-jira-url.tld/'
JIRA_ACCOUNT = ('jira-username', 'jira-password')
# the JIRA project ID (short)
JIRA_PROJECT = 'PRO'
GITLAB_URL = 'http://your-gitlab-url.tld/'

Architecture of GitLab as an Open Source Project

In this talk I'll briefly explain how GitLab was composed from different components, and what do each different components do, and how I contribute to GitLab. If you would also like to contribute to GitLab, then you'll certainly need to know where you need to get started for the contribution you want to make. This talk would be a nice introduction for you. If you are just interested in large software architecture in general, then this should also be interesting for you.

Outline

  • Who am I
  • Introduction to GitLab
    • What is GitLab
  • GitLab.com
@johanndt
johanndt / upgrade-postgres-9.3-to-9.5.md
Last active July 27, 2024 16:49 — forked from dideler/upgrade-postgres-9.3-to-9.4.md
Upgrading PostgreSQL from 9.3 to 9.5 on Ubuntu

TL;DR

Install Postgres 9.5, and then:

sudo pg_dropcluster 9.5 main --stop
sudo pg_upgradecluster 9.3 main
sudo pg_dropcluster 9.3 main
@henrik
henrik / half_open_struct.rb
Last active March 29, 2019 09:35
HalfOpenStruct for #ruby. Like OpenStruct but doesn't let you read a non-assigned value (raises instead of returning nil). Also see my RecursiveClosedStruct: https://gist.github.com/henrik/5098550
# Like OpenStruct but doesn't let you read a non-assigned value (raises instead of returning nil).
# This avoids issues where you read the wrong value due to a typo and don't notice.
class HalfOpenStruct
def initialize(hash = {})
@hash = hash
end
def include?(name)
@hash.include?(name)
@filipelinhares
filipelinhares / vim.md
Last active July 22, 2024 12:06
Vim basic commands

Vim basic commands

A

  • a Enter into insert mode after the character your cursor is on.
  • A Enter into insert mode at the end of the current line.

B

  • b Move cursor to first character of previous word.
  • B Move cursor to first character of previous non-blank series of characters.
  • Ctrl+b Scroll page backwards (move up in the file).
@indirect
indirect / README.md
Last active August 29, 2015 14:24
Rails 4 silenceable logger

Rails 4 Silenceable Logger

For when you really, really don't want to log a request.

I'm using this logger to skip logging requests for CarrierWave-uploaded images in development. Loading database dumps from other environments means that the images simply aren't there in development. Rather than deal with an ActiveSupport::RoutingError and a huge 20 line backtrace per missing image, I'm just suppressing all output using this logger and a catchall route that's only active in development.

Usage

Add lib/silenceable_logger.rb to your Rails app, and adapt config/development.rb and config/routes.rb as needed.

@pixeltrix
pixeltrix / time_vs_datatime.md
Last active February 18, 2024 19:20
When should you use DateTime and when should you use Time?

When should you use DateTime and when should you use Time?

It's a common misconception that [William Shakespeare][1] and [Miguel de Cervantes][2] died on the same day in history - so much so that UNESCO named April 23 as [World Book Day because of this fact][3]. However because England hadn't yet adopted [Gregorian Calendar Reform][4] (and wouldn't until [1752][5]) their deaths are actually 10 days apart. Since Ruby's Time class implements a [proleptic Gregorian calendar][6] and has no concept of calendar reform then there's no way to express this. This is where DateTime steps in:

>> shakespeare = DateTime.iso8601('1616-04-23', Date::ENGLAND)
=> Tue, 23 Apr 1616 00:00:00 +0000
>> cervantes = DateTime.iso8601('1616-04-23', Date::ITALY)
=> Sat, 23 Apr 1616 00:00:00 +0000
@jeffrafter
jeffrafter / rate_limits.rb
Created May 28, 2015 21:16
Handle Shopify API rate limits
# https://docs.shopify.com/api/introduction/api-call-limit
module ActiveResource
# 429 Client Error
class RateLimitExceededError < ClientError # :nodoc:
end
class Connection
RATE_LIMIT_SLEEP_SECONDS = 20 # number of seconds to sleep (by sleeping 20 you reset the clock to get 40 fresh burst calls with the default 2 calls/sec)