Skip to content

Instantly share code, notes, and snippets.

View hackvan's full-sized avatar
🇨🇴

Diego Camacho hackvan

🇨🇴
View GitHub Profile
@acamino
acamino / README.md
Last active May 20, 2025 21:05
Shortcuts to Improve Your Bash & Zsh Productivity

Shortcut — Action

  • CTRL + A — Move to the beginning of the line
  • CTRL + E — Move to the end of the line
  • CTRL + [left arrow] — Move one word backward (on some systems this is ALT + B)
  • CTRL + [right arrow] — Move one word forward (on some systems this is ALT + F)
  • CTRL + U — (bash) Clear the characters on the line before the current cursor position
  • CTRL + U —(zsh) If you're using the zsh, this will clear the entire line
  • CTRL + K — Clear the characters on the line after the current cursor position
  • ESC + [backspace] — Delete the word in front of the cursor
@lau
lau / simple_time_zone_list.ex
Last active September 23, 2024 03:00
Simple city to time zone mapping from Rails. As an Elixir map.
# Could be used for instance like this in Phoenix: <%= select f, :time_zone, SimpleTimeZoneList.mapping %>
defmodule SimpleTimeZoneList do
@mapping %{
"International Date Line West" => "Pacific/Midway",
"Midway Island" => "Pacific/Midway",
"American Samoa" => "Pacific/Pago_Pago",
"Hawaii" => "Pacific/Honolulu",
"Alaska" => "America/Juneau",
"Pacific Time (US & Canada)" => "America/Los_Angeles",
"Tijuana" => "America/Tijuana",
@ser1zw
ser1zw / insert_sql_generator.rb
Created May 5, 2015 02:04
INSERT query generator for Oracle
#
# INSERT query generator for Oracle
#
# Requirements:
# - Ruby 2.0 or later (https://www.ruby-lang.org/)
# - ruby-oci8 (gem install ruby-oci8)
# - Oracle Database
#
require 'oci8'
@umidjons
umidjons / parse-json-in-plsql.md
Created August 1, 2014 04:25
Parse JSON in PL/SQL

Parse JSON in PL/SQL

Download and install PL/JSON.

Following is an example of how to parse a JSON array represented as string:

declare
	my_clob clob := '[
@Kartones
Kartones / postgres-cheatsheet.md
Last active June 5, 2025 03:44
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
# Based on https://gist.github.com/fernandoaleman/5083680
# Start the old vagrant
$ vagrant init ubuntu_saucy
$ vagrant up
# You should see a message like:
# [default] The guest additions on this VM do not match the install version of
# VirtualBox! This may cause things such as forwarded ports, shared
# folders, and more to not work properly. If any of those things fail on
@dwayne
dwayne / ch1.md
Last active December 2, 2024 19:32
My notes from the book "Eloquent Ruby by Russ Olsen"

Chapter 1

Every programming community quickly converges on a style, an accepted set of idioms. Programming is all about communication and knowing those idioms are key to being a successful programmer in that community.

Ruby style of programming:

  • Code should be crystal clear, it should shout its intent
  • Good code is also concise

Ruby indentation convention:

@PWSdelta
PWSdelta / rspec_model_testing_template.rb
Last active March 11, 2025 21:14
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
@ppdeassis
ppdeassis / oracle_reader.rb
Created June 18, 2013 14:35
A Ruby class to acces an Oracle database
################################################################################
require 'oci8'
require 'iconv'
################################################################################
class OracleReader
################################################################################
def initialize(server, username, password)
# Open the connection.
@connection = OCI8.new(username, password, server)