Skip to content

Instantly share code, notes, and snippets.

View gabteles's full-sized avatar
🏠
Working from home

Gabriel Teles gabteles

🏠
Working from home
View GitHub Profile
# frozen_string_literal: true
class PDFSnapshotComparator
def initialize(generated)
@generated = generated
end
def same?(expectation)
out1 = Tempfile.new(['', '.png'])
out2 = Tempfile.new(['', '.png'])
#!/bin/bash
# remove exited containers:
docker ps --filter status=dead --filter status=exited -aq | xargs -r docker rm -v
# remove unused images:
docker images --no-trunc | grep '<none>' | awk '{ print $3 }' | xargs -r docker rmi
# remove unused volumes:
sudo find '/var/lib/docker/volumes/' -mindepth 1 -maxdepth 1 -type d | grep -vFf <(
$ time terraform apply -var-file=terraform-private.tfvars -var-file=terraform.tfvars
...
real 3m35,256s
user 0m3,221s
sys 0m1,241s
$ time terraform destroy -var-file=terraform-private.tfvars -var-file=terraform.tfvars
real 4m25,263s
user 0m3,484s
sys 0m1,152s
@gabteles
gabteles / promise-filter-sensitive-data.js
Created December 10, 2015 16:01
Filters sensitive data from Angular's $http responses.
/**
* Filters sensitive data from Angular's $http responses.
*
* @author Gabriel Teles <gab.teles@hotmail.com>
* @version 0.1.0
* @since 2015.12.10
*/
(function() {
'use strict';
@gabteles
gabteles / fibonacci.rb
Created June 29, 2015 02:20
Implementação da sequência de Fibonacci em Ruby como enumerável e utilizando a fórmula com a razão áurea.
# Implementação pela fórmula
class << Math
FiveSquareRoot = Math.sqrt(5)
GoldenRatio = (1 + FiveSquareRoot) / 2
def fibonacci(n)
((GoldenRatio ** n - ((-GoldenRatio) ** (-n))) / FiveSquareRoot).round
end
end
@gabteles
gabteles / combsort.rb
Last active August 29, 2015 14:23
Combsort in Ruby
class Array
def combsort!(shrink = 1.247330950103979)
gap = size
swapped = false
until gap == 1 and !swapped
gap = (gap / shrink).to_i
gap = 1 if gap < 1
@gabteles
gabteles / cfor.rb
Created June 23, 2015 20:59
Implements "for" like c, cpp, java, etc
module Kernel
def cfor(init, condition, inc)
while condition.()
yield
inc.()
end
end
end
if ($0 == __FILE__)
@gabteles
gabteles / Game.rb
Last active January 21, 2024 22:32
Emulador do RGSS Player do RPG Maker (XP, VX e VXA) escrito em Ruby. A versão do Ruby deve ter arquitetura x86, já que a WinAPI falha ao carregar DLLs x86 (as do RM, no caso) em programas x64.
# encoding: utf-8
# @file : Main.rb
# @desc : Omni RGSSx Player
# @author : Gab!
# @history : 2014/04/04
# Requires
require 'fiddle'
require 'fiddle/struct'
require 'fiddle/types'
@gabteles
gabteles / jquery.konamiCode.js
Created July 26, 2013 16:44
Konami Code jQuery Plugin
/*
* Konami Code jQuery Plugin
*
* Usage:
*
* 1 - Set permanent callback: everytime the user makes the
* konami code the callback will
* be called.
*
* $(document).konamiCode(callback, true)
@gabteles
gabteles / Brainfuck2.rb
Created July 14, 2013 22:16
Segunda versão do meu interpretador/tradutor de Brainfuck em/para Ruby. Ainda está meio bruto, mas funciona relativamente bem.
# Interpretador de Brainfuck V2
# Autor: Gabriel Teles <gab.teles@hotmail.com>
require 'io/console' # Necessário para usar STDIN.getch
module Brainfuck2
# Classe de controle
class ProgramData
attr_reader :bufferSize, :buffer, :stack, :commands, :position