Skip to content

Instantly share code, notes, and snippets.

View camelloj's full-sized avatar

Job Ezequiel Mendez Santizo camelloj

View GitHub Profile
@camelloj
camelloj / sinatra_host_authorization.rb
Last active September 16, 2025 12:14
Sinatra ruby app Host authorization
# Set list of host that can interact with your app
require "sinatra/base"
class ExampleApp < Sinatra::Base
# disable it for all environments
set :host_authorization, { permitted_hosts: [] }
# or...
@camelloj
camelloj / ruby_csvtojson.txt
Created April 15, 2024 17:47
one-liner CSV to JSON whit Ruby
ruby -r json -r csv -e 'puts CSV.parse(STDIN, headers:true).map(&:to_h).to_json' < INPUT.csv
@camelloj
camelloj / error_gem_pg_ubuntu.txt
Last active September 1, 2021 19:21
Error to install pg on ubuntu
Installing pg 1.2.3 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: ../.rvm/gems/ruby-2.6.3/gems/pg-1.2.3/ext
/usr/share/rvm/rubies/ruby-2.6.3/bin/ruby -I /usr/share/rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0 -r ./siteconf20210901-306426-52o4ch.rb extconf.rb
@camelloj
camelloj / psql_fix_warning
Last active January 4, 2019 20:31
fix warning from old version on psql
[How To] Fix psql version 9.2, server version 9.5 warning
If you have more than one version of PostgreSQL installed in your Linux server, which is very common given the older version of the database shipped with most stable server distros, you may end up with the following warning when trying to login to the database console
bash-4.1$ psql
psql (9.2.9, server 9.5.1)
WARNING: psql version 9.2, server version 9.5.
Some psql features might not work.
Type "help" for help.
postgres=# \q
get from https://help.theatremanager.com/book/export/html/3665
************************************************************
Promoting a Standby to the Main server
************************************************************
Except for an absolute calamity, there is no reason to promote the hot standby to be the main server. If you need to, the general recovery steps are outlined below. There is only ONE command to do at the backup server to make it the primary server (see bottom half of page).
1. Shut down, turn off, unplug and/or remove the main server from the network so that it is no longer active
2. On the backup server, create the failover trigger file using the primary failover methodology (described in detail below):
@camelloj
camelloj / postgresql_sql_commands.sql
Created September 1, 2018 00:25
Postgresql commands
-- display configurations
--- max connections set up
SELECT name, current_setting(name)
FROM pg_settings
WHERE name = 'max_connections'
--- display config file
show config_file;
--- display effective cache size
$ cd /tmp
$ wget http://download.redis.io/redis-stable.tar.gz
$ tar xvzf redis-stable.tar.gz
$ cd redis-stable
$ make
$ cp src/redis-cli /usr/local/bin/
$ chmod 755 /usr/local/bin/redis-cli
@camelloj
camelloj / install_psql_centos6
Last active July 4, 2018 16:03
Install_psql_centos6
Exclude postgresql* on yum repos
$ vim /etc/yum.repos.d/CentOS-Base.repo
** [base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
@camelloj
camelloj / pg_dump_mismatch_version.txt
Created July 14, 2017 06:40
pg_dump: aborting because of server version mismatch
pg_dump: server version: #.##.#; pg_dump version: #.##.#
How to fix:
1. Check the installed version(s) of pg_dump
$ find / -name pg_dump -type f 2>/dev/null
2. List of output
$ /usr/bin/pg_dump
$ /usr/pgsql-9.4/bin/pg_dump
$ /usr/pgsql-9.6/bin/pg_dump
@camelloj
camelloj / postgresql93_add_pg_stat_statements.txt
Created July 10, 2017 21:29
how to enable pg_stat_statements on postgres93
* Install official PostgreSQL contrib package
$ yum install postgresql93-contrib
* Create extension
$ create extension pg_stat_statements;
* Edit postgresql.conf
$ vim /var/lib/pgsql/9.3/data/postgresql.conf
** add
shared_preload_libraries = pg_stat_statements (required)
track_activity_query_size = 2048 (increase maximum length before which queries are truncated)
pg_stat_statements.track = ALL (track all statements, including those inside stored procedures)