Skip to content

Instantly share code, notes, and snippets.

View wagnerpereira's full-sized avatar

Wagner Pereira wagnerpereira

View GitHub Profile
#!/usr/bin/env bash
# Abort sign off on any error
set -e
# Start the benchmark timer
SECONDS=0
# Repository introspection
OWNER=$(gh repo view --json owner --jq .owner.login)
@jaydorsey
jaydorsey / private_bundle_install_gist.md
Created May 25, 2022 01:22
Setting up a github/bundle token for privately hosted repos

If your Gemfile has a privately hosted package referenced similar to this:

gem 'sekret', git: 'https://github.com/my-private-group/sekret.git', branch: 'main'

You may see a prompt when running bundle install, or other bundler commands, to enter your github username & password.

To resolve this, you need to generate a token and add it to your system.

Generating a token

@serradura
serradura / 01_metodos_de_instancia.rb
Created October 26, 2020 16:53
Ruby - Métodos de instância VS de classe VS lambda
class Calc
def sum(a, b)
a + b
end
def multiply(a, b)
a * b
end
end
@aashish
aashish / insert_image_on_pdf.rb
Last active February 21, 2024 17:18
Insert image on a existing PDF having content with hexapdf gem
require 'hexapdf'
doc = HexaPDF::Document.open("/home/xxxx/Downloads/OoPdfFormExample.pdf")
page = doc.pages[0]
canvas = page.canvas(type: :overlay)
canvas.translate(0, 20) do
canvas.fill_color(0.3, 0.7, 0.7)
canvas.rectangle(50, 0, 80, 80, radius: 80)
# see: https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html
LOGLEVELS = %w[DEBUG INFO WARN ERROR FATAL UNKNOWN].freeze
LOGGER = Logger.new(STDOUT)
level ||= LOGLEVELS.index ENV.fetch("LOG_LEVEL","WARN") # default to WARN index: 2
level ||= Logger::WARN # FIX default in case of environment LOG_LEVEL value is present but not correct
LOGGER.level = level
# Usage:
# before launching the program:
# $ export LOG_LEVEL=DEBUG
@ahmetb
ahmetb / gcrgc.sh
Last active February 26, 2024 09:14
Script to clean up Google Container Registry images pushed before a particular date
#!/bin/bash
# Copyright © 2017 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@ivanseidel
ivanseidel / PID.ino
Last active March 29, 2024 07:15
Simple PID Class for Arduino Projects
// (Really Simple) PID Class by Ivan Seidel
// GitHub.com/ivanseidel
// Use as you want. Leave credits
class PID{
public:
double error;
double sample;
double lastSample;
@hasantayyar
hasantayyar / git-dropbox-fix.sh
Created January 9, 2014 10:19
Solution if you are using dropbox and git same time and if you get this error "fatal: Reference has invalid format: refs/heads/master conflicted copy"
find . -type f -name "* conflicted copy*" -exec rm -f {} \;
awk '!/conflicted/' .git/packed-refs > temp && mv temp .git/packed-refs
@irazasyed
irazasyed / homebrew-permissions-issue.md
Last active May 2, 2024 22:51
Homebrew: Permissions Denied Issue Fix (OS X / macOS)

Homebrew Permissions Denied Issues Solution

sudo chown -R $(whoami) $(brew --prefix)/*

@robbyrussell
robbyrussell / ohmyzsh-dropbox-sync.sh
Created February 8, 2012 15:20
Keep your @ohmyzsh ~/.zshrc in sync via dropbox
# Was asked how I keep my zshrc config sync'd between my computers with Dropbox
# Add a new directory in your Dropbox (or use an existing one)
mkdir -p ~/Dropbox/ohmyzsh
# move existing file to Dropbox
mv ~/.zshrc ~/Dropbox/ohmyzsh/zshrc
# symlink file back to your local directory
ln -s ~/Dropbox/ohmyzsh/zshrc ~/.zshrc