Skip to content

Instantly share code, notes, and snippets.

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

Jesús Gómez jgomo3

🏠
Working from home
View GitHub Profile
@borkdude
borkdude / install-dev-certificate
Created May 26, 2022 11:59
install_dev_certificate.clj
#!/usr/bin/env bash
set -eo pipefail
CERT_FILE="./certs/dev/dev-ca/rootCA.pem"
CERT_NAME="Nextjournal Development Root CA"
echo "Installing development Root CA into system store..."
if uname -a | grep -q Darwin; then
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain $CERT_FILE
@macagua
macagua / Python_Cache_Packages_Conda.txt
Last active March 30, 2022 22:18
[TIP] When there is Internet latency and requires installing python packages by conda tool but the installation failed, then you can prevent conda from re-downloading previously downloaded packages, running this command
mkdir -p ~/.conda/pkgs && printf 'pkgs_dirs:\n - ~/.conda/pkgs\n' >> ~/.condarc
@db0sch
db0sch / regenerate_credentials.md
Last active October 31, 2023 20:30
How to regenerate the master key for Rails 5.2 credentials

If your master.key has been compromised, you might want to regenerate it.

No key regeneration feature at the moment. We have to do it manually.

  1. Copy content of original credentials rails credentials:show somewhere temporarily.
  2. Remove config/master.key and config/credentials.yml.enc
  3. Run EDITOR=vim rails credentials:edit in the terminal: This command will create a new master.key and credentials.yml.enc if they do not exist.
  4. Paste the original credentials you copied (step 1) in the new credentials file (and save + quit vim)
  5. Add and Commit the file config/credentials.yml.enc
@jaymcgavren
jaymcgavren / blog.rb
Created October 26, 2017 22:48
Set up Active Record with an in-memory database and model classes, all in a single file.
# Instead of loading all of Rails, load the
# particular Rails dependencies we need
require 'sqlite3'
require 'active_record'
# Set up a database that resides in RAM
ActiveRecord::Base.establish_connection(
adapter: 'sqlite3',
database: ':memory:'
)
@craigvantonder
craigvantonder / flush-dns.sh
Last active February 3, 2021 04:42
Flushing the DNS in Ubuntu 16.04
#!/bin/bash
# NB: First install nscd with sudo apt-get install nscd
# run this command to flush dns cache:
sudo /etc/init.d/dns-clean restart
# or use:
sudo /etc/init.d/networking force-reload
# Flush nscd dns cache:
sudo /etc/init.d/nscd restart
@patrickmmartin
patrickmmartin / PYTHON_DEFAULT.md
Created February 5, 2017 09:48
update-alternatives for python3 on Ubuntu

Ubuntu 16 default python is almost python 3

Loads of solutions exist, but for changing the system default, alias is not the way to go.

$ update-alternatives --list python update-alternatives: error: no alternatives for python

@internaut
internaut / pandas_crossjoin_example.py
Last active June 12, 2020 14:30
Shows how to do a cross join (i.e. cartesian product) between two pandas DataFrames using an example on calculating the distances between origin and destination cities. See https://mkonrad.net/2016/04/16/cross-join--cartesian-product-between-pandas-dataframes.html
"""
Shows how to do a cross join (i.e. cartesian product) between two pandas DataFrames using an example on
calculating the distances between origin and destination cities.
Tested with pandas 0.17.1 and 0.18 on Python 3.4 and Python 3.5
Best run this with Spyder (see https://github.com/spyder-ide/spyder)
Author: Markus Konrad <post@mkonrad.net>
April 2016
@littlemove
littlemove / my-ruby.el
Created March 18, 2016 11:40
Spacemacs: Code folding for ruby-mode
;; Code folding
(add-hook 'ruby-mode-hook
(lambda () (hs-minor-mode)))
(eval-after-load "hideshow"
'(add-to-list 'hs-special-modes-alist
`(ruby-mode
,(rx (or "def" "class" "module" "do" "{" "[")) ; Block start
,(rx (or "}" "]" "end")) ; Block end
,(rx (or "#" "=begin")) ; Comment start
@drmalex07
drmalex07 / README-oneshot-systemd-service.md
Last active January 20, 2024 12:57
An example with an oneshot service on systemd. #systemd #systemd.service #oneshot

README

Services declared as oneshot are expected to take some action and exit immediatelly (thus, they are not really services, no running processes remain). A common pattern for these type of service is to be defined by a setup and a teardown action.

Let's create a example foo service that when started creates a file, and when stopped it deletes it.

Define setup/teardown actions

Create executable file /opt/foo/setup-foo.sh:

@jhngrant
jhngrant / postgresql-debugger-install-ubuntu
Last active September 26, 2022 21:23
Installing the PL/pgSQL Debugger Extension (pldbgapi) for pgAdmin III on PostgreSQL 9.4 and Ubuntu 14.10
# PostgreSQL can be on a remote server but you'll need root privileges in Linux and superuser in PostgreSQL.
# First install build tools
sudo su
aptitude install build-essential
aptitude install postgresql-server-dev-9.4
# Clone and build the PL/pgSQL server-side debugger