Skip to content

Instantly share code, notes, and snippets.

View ryanpadilha's full-sized avatar
:octocat:

Ryan Padilha ryanpadilha

:octocat:
View GitHub Profile
@ryanpadilha
ryanpadilha / pg-dump.sh
Last active November 9, 2017 16:55
PostgreSQL 9.6 :: database management - binary
#!/bin/bash
# PostgreSQL database dump
# troubleshooting for
# pg_dump: server version: 9.6.2; pg_dump version: 9.5.6
# pg_dump: aborting because of server version mismatch
#
# commands to verify version mismatch on linux environment
# psql --version
# pg_dump --version
@ryanpadilha
ryanpadilha / pg_search_conf_unaccented.sql
Created July 10, 2017 15:06
PostgreSQL - full-text search configuration
-- enable extensions
-- full-text search on postgresql
CREATE EXTENSION unaccent;
-- languages supported
CREATE TEXT SEARCH CONFIGURATION fr ( COPY = french );
ALTER TEXT SEARCH CONFIGURATION fr ALTER MAPPING
FOR hword, hword_part, word WITH unaccent, french_stem;
CREATE TEXT SEARCH CONFIGURATION en ( COPY = english );
@ryanpadilha
ryanpadilha / rm-gitignore-files.sh
Last active September 11, 2017 18:10
Remove files that are listed in .gitignore
#!/bin/bash
# Remove files are listed in gitignore
git rm --cached `git ls-files -i --exclude-from=.gitignore`
# git bash on windows
# git ls-files -i -z --exclude-from=.gitignore | xargs -0 git rm --cached
# in case of any problem with the statements above, its run in any OS
git rm -r --cached .
git add .
@ryanpadilha
ryanpadilha / fix-apt-get.sh
Last active May 5, 2025 19:03
Commands to fix apt - E: Sub-process /usr/bin/dpkg returned an error code (1)
#!/bin/bash
sudo rm -rf /var/lib/dpkg/info/*.*
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get update
sudo apt-get check
sudo apt-get -f install
sudo apt-get upgrade
@ryanpadilha
ryanpadilha / user-management.sh
Last active November 29, 2017 16:51
Linux user management script
#!/bin/bash
# Linux user management script
# to list all user on linux environment (listed in /etc/passwd)
getent passwd
# to list all groups on linux environment (listed in /etc/group)
getent group
# to add a new user, with sudo this add sudoers privilegies
@ryanpadilha
ryanpadilha / drop-pg-connection-pid.sql
Created August 7, 2017 22:29
Drop all connections to a specific database-name
-- PostgreSQL 9.6
-- view connections
select * from pg_stat_activity where datname = 'db_name';
-- drop connections
select pg_terminate_backend(pid) from pg_stat_activity where datname = 'db_name';
@ryanpadilha
ryanpadilha / apache-tomcat-install-centos.sh
Last active April 3, 2019 19:30
How To Install Apache Tomcat 9 on CentOS 7
#!/bin/bash
# Apache Tomcat 9.x instructions for installation on CentOS Linux 7
# Apache needs JDK 8 installed on environment (we prefer Oracle JVM HotSpot!)
# find out instructions how to install :D
# A | create tomcat user :: should be run as an unprivileged user
# 1. create a new tomcat group
sudo groupadd tomcat
@ryanpadilha
ryanpadilha / tomcat.service
Created August 8, 2017 18:40
Sample /etc/systemd/system/tomcat.service
# Systemd unit file for tomcat
[Unit]
Description=Apache Tomcat Web Application Container
After=syslog.target network.target
[Service]
Type=forking
Environment=JAVA_HOME=/usr/lib/jvm/jre
Environment=CATALINA_PID=/opt/tomcat/temp/tomcat.pid
@ryanpadilha
ryanpadilha / move-remote-git-repository.sh
Created August 15, 2017 01:47
Moving a remote git repository
$ git remote show origin
$ git remote rm origin
$ git remote add origin git@newserver:project.git
$ git remote show origin
@ryanpadilha
ryanpadilha / license-badges.md
Created August 30, 2017 17:00 — forked from lukas-h/license-badges.md
License Badges for your Project

Markdown License badges

Collection of License badges for your Project's README file.
This list includes the most common open source and open data licenses.
Easily copy and paste the code under the badges into your Markdown files.

Notes

  • Badges are made with Shields.io.
  • This badges do not fully replace the license informations for your projects, they are only emblems for the README, that the user can see the License at first glance.  
  • 🇫🇷 Cette liste en français