Skip to content

Instantly share code, notes, and snippets.

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

Ruben Sierra rsierra

🏠
Working from home
View GitHub Profile
@chrismccord
chrismccord / upgrade.md
Last active April 7, 2023 12:03
Phoenix 1.2.x to 1.3.0 Upgrade Instructions

If you want a run-down of the 1.3 changes and the design decisions behidn those changes, check out the LonestarElixir Phoenix 1.3 keynote: https://www.youtube.com/watch?v=tMO28ar0lW8

To use the new phx.new project generator, you can install the archive with the following command:

$ mix archive.install https://github.com/phoenixframework/archives/raw/master/phx_new.ez

Bump your phoenix dep

Phoenix v1.3.0 is a backwards compatible release with v1.2.x. To upgrade your existing 1.2.x project, simply bump your phoenix dependency in mix.exs:

@porras
porras / xargs.md
Last active August 31, 2021 14:54

This is my best try at transcribing of the lightning talk I gave at RUG::B on April 2016. Due to poor time management (LOL) the delivery was rushed and some examples were skipped, I hope having them posted here makes them more useful.

xargs

xargs is a small but very useful program that is installed in most if not all of your computers¹. Many of you probably know it. Those who don't will learn something really useful, but those who do will learn a couple of cool tricks, too.

Why xargs

You might have heard about the Unix philosophy:

@bastman
bastman / docker-cleanup-resources.md
Created March 31, 2016 05:55
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@enoliglesias
enoliglesias / time_machine.rb
Last active March 8, 2016 19:32
Rack middleware to travel in time your rails application
class Dummy::TimeMachine
def initialize(app)
@app = app
end
def call(env)
Rails.logger.info("[TimeMachine] Starting time travel.")
Timecop.return
request = Rack::Request.new(env)
params = request.params
@enoliglesias
enoliglesias / sermepa_signature_sha256_confirmation.rb
Last active November 25, 2016 17:35
Ds_Signature creation for Sermepa with SHA256
def confirmation(credentials)
return false if params['ds_signature'].blank?
# The DES3-CBC key generation it's the same that in the creation gist
# You can take a look at the explanation
secret_key = credentials[:secret_key]
secret_key_base64 = Base64.strict_decode64(secret_key)
des3 = OpenSSL::Cipher::Cipher.new('des-ede3-cbc')
block_length = 8
des3.padding = 0
@jamescmartinez
jamescmartinez / slack_delete.rb
Last active January 4, 2021 21:28
This Ruby script will bulk remove all Slack files older than 30 days. Just add your API token from https://api.slack.com/web#authentication into the token quotes at the top of the file.
require 'net/http'
require 'json'
require 'uri'
@token = ''
def list_files
ts_to = (Time.now - 30 * 24 * 60 * 60).to_i # 30 days ago
params = {
token: @token,
@brenes
brenes / custom_mini_profiler.rb
Last active August 29, 2015 14:21
Utility class for decorating a method and adding the information to the rach mini profiler summary
# Simple class to decorate a method and send information MiniProfiler
# Usage: CustomMiniProfiler.measure MyClass, :mymethod, "This method takes..."
class CustomMiniProfiler
def self.measure klass, method, message, class_method=false
receptor_class = class_method ? klass.singleton_class : klass
receptor_class.send :define_method, "#{method}_with_mini_profiler" do |*args, &block|
Rack::MiniProfiler.step(message) do
send "#{method}_without_mini_profiler", *args, &block
end
@brenes
brenes / error_redirection.rb
Created December 9, 2014 16:29
Rack error redirector
# This rack engine redirects to external URLs when some error is thrown.
# How to use it?
# Just add the rack middleware in config/application.rb
# require 'rack/error_redirection'
# config.app_middleware.insert_before('ActionDispatch::ShowExceptions', 'Rack::ErrorRedirection')
# And fill the error_404_url and error500_url variables
module Rack
class ErrorRedirection
def initialize(app)
@app = app
@brenes
brenes / fix-srt.rb
Last active June 8, 2018 07:47
Small script for fixing srt files with blank lines
# This small script uses the 'srt' gem to parse the srt file
# It solves problems with certain subtitle files with empty lines that make Flex crash
# You can use it with files, folders with files or even folders with subfolders with files (God bless Recursivity)
# USAGE: ruby fix-srt.rb file/to/fix.srt
# USAGE: ruby fix-srt.rb folder/with/files/to/fix
# USAGE: ruby fix-srt.rb folders/with/subfolders/to/fix
require 'rubygems'
require 'srt'
class StrFixer
@brenes
brenes / gist:6000406
Created July 15, 2013 14:32
Funcion JS para loguear errores de Parsley
$('form').parsley( {
listeners: {
onFieldError: function ( elem, constraints, ParsleyField ) {
if (javascript_env == 'production') {
return;
}
_log("Errores: ")
_log(elem.attr("name") + ": " + elem.val());
for(constraint_id in constraints) {