Skip to content

Instantly share code, notes, and snippets.

View aalvarado's full-sized avatar
😎

Adan Alvarado aalvarado

😎
View GitHub Profile
@fritz-c
fritz-c / git-recentco
Last active April 8, 2024 02:54 — forked from jordan-brough/git-recent
Git: Check out a branch from a list of recently checked out branches/tags/commits
#!/usr/bin/env bash
# Source: https://gist.github.com/fritz-c/c1e528b09bc1c0827a3c
# Original: https://gist.github.com/jordan-brough/48e2803c0ffa6dc2e0bd
# Download this script as "git-recentco" (no extension), chmod it to be executable and put it in your
# path somewhere (e.g. /usr/bin). You can then use it via `git recentco` from inside any git repo.
# Example:
#
@dideler
dideler / upgrade-postgres-9.3-to-9.4.md
Last active June 8, 2020 03:24
Upgrading PostgreSQL from 9.3 to 9.4 when upgrading Ubuntu 14.04 to 14.10

TL;DR

Create a backup:

pg_dumpall > mybackup.sql

Perform the upgrade:

sudo pg_dropcluster 9.4 main --stop
@jirutka
jirutka / pg_change_db_owner.sh
Last active February 6, 2024 20:01
Some convenient scripts to manage ownerships and privileges in PostgreSQL.
#!/bin/sh
#
# The MIT License
#
# Copyright 2014-2017 Jakub Jirutka <jakub@jirutka.cz>.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@jordan-brough
jordan-brough / git-recent
Last active April 8, 2024 02:53
Git: Display a list of recently checked out branches/tags/commits
#!/usr/bin/env bash
# Source: https://gist.github.com/jordan-brough/48e2803c0ffa6dc2e0bd
# See also: https://stackoverflow.com/a/25095062/58876
# Download this script as "git-recent" (no extension), chmod it to be executable and put it in your
# path somewhere (e.g. /usr/bin). You can then use it via `git recent` from inside any git repo.
# Examples:
@prabirshrestha
prabirshrestha / .bash_profile
Last active June 3, 2022 01:19
my terminal settings for windows
# curl -Lk https://gist.githubusercontent.com/prabirshrestha/279d8b179d9353fe8694/raw/.bash_profile -o ~/.bash_profile
[[ -s ~/.nvm/nvm.sh ]] && . ~/.nvm/nvm.sh # This loads NVM
export PATH="$HOME/.cargo/bin:$HOME/go/bin:$HOME/Library/Python/3.7/bin:$PATH"
export PATH="$HOME/.config/nvim/plugins/vim-themis/bin:$PATH"
stty -ixon
alias pbcopy='xsel --clipboard --input'
alias pbpaste='xsel --clipboard --output'
@emilyst
emilyst / .vimrc
Last active July 24, 2016 17:45
I'm trying to keep this up to date with whatever my actual .vimrc is at the time. It may or may not track pretty closely, but at the time of writing this description (1 Mar 14), it's perfectly up to date.
" 0 preamble ============================================================== {{{
"
" There is a great organization scheme in place here. If you run the
" :options command in Vim, you see a list of all the options that you
" can set, along with their current settings and a brief description of
" them. The great thing about this scheme is that--for better or
" worse--it sets up a system which can organize all my settings. I've
" decided to organize everything below thus, throwing ancillary things
" (my own mappings, plugin settings, and so on) where it makes sense.
"
/*!
* jQuery JavaScript Library v2.1.1pre
* http://jquery.com/
*
* Includes Sizzle.js
* http://sizzlejs.com/
*
* Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors
* Released under the MIT license
* http://jquery.org/license
@ArthurN
ArthurN / i18n.rb
Created December 2, 2013 01:07
Monkey-patch Rails I18n.translate to see what keys ActiveModel is trying to use.
#initializers/i18n.rb
I18n.module_eval do
class << self
def translate_with_puts(*args)
Rails.logger.debug "#{args}"
old_translate(*args)
end
alias :old_translate :translate
alias :translate :translate_with_puts
end
@mcmire
mcmire / table_helpers.rb
Last active December 18, 2015 23:19
Helper for use in RSpec/Capybara feature tests to find a table on a page and convert it into an array of arrays, so that you can make an assertion on it. Similar to Cucumber's #tableize but is better about stringifying cell content.
module TableHelpers
VALID_FORMATS = [:html, :text]
# Find a table on the page and convert it to an array of arrays.
#
# selector_or_node - A String CSS selector to find the table, or a
# Nokogiri::XML::Node object (if you already have a
# reference to the table).
# options - Optional hash:
# columns - An Integer or Range of Integers. Lets you
@maxivak
maxivak / send_data-send_file-remote-images-download
Created January 1, 2013 23:34
Rails. Download remote image as attachment in browser
# in controller
# for local files
send_file '/path/to/file', :type => 'image/jpeg', :disposition => 'attachment'
# for remote files
require 'open-uri'
url = 'http://someserver.com/path/../filename.jpg'
data = open(url).read
send_data data, :disposition => 'attachment', :filename=>"photo.jpg"