Skip to content

Instantly share code, notes, and snippets.

@asanchez75
asanchez75 / access_postgresql_with_docker.md
Created September 20, 2022 09:21 — forked from MauricioMoraes/access_postgresql_with_docker.md
Allow Docker Container Access to Host's Postgres Database on linux (ubuntu)

You have to do 2 things in order to allow your container to access your host's postgresql database

  1. Make your postgresql listen to an external ip address
  2. Let this client ip (your docker container) access your postgresql database with a given user

Obs: By "Host" here I mean "the server where docker is running on".

Make your postgresql listen to an external ip address

Find your postgresql.conf (in case you don't know where it is)

$ sudo find / -type f -name postgresql.conf

@asanchez75
asanchez75 / iterm.el
Created September 13, 2022 14:41 — forked from johnmastro/iterm.el
Send text from Emacs to iTerm
;;; iterm.el - Send text to a running iTerm instance
(require 'pcase)
(require 'thingatpt)
;; To match SublimeText's key binding:
;; (global-set-key (kbd "<C-return>") 'iterm-send-text)
(defvar iterm-default-thing 'line
"The \"thing\" to send if no region is active.
@asanchez75
asanchez75 / ProofOfConceptSparkCuctomListener.scala.txt
Created August 22, 2022 20:31 — forked from LucaCanali/ProofOfConceptSparkCuctomListener.scala.txt
Proof-of-concept code of how to extend Spark listeners for custom monitoring of Spark metrics
// Proof-of-concept code of how to extend Spark listeners for custom monitoring of Spark metrics
// When using this from the spark-shell, use the REPL command :paste and copy-paste the following code
// Tested on Spark 2.1.0, March 2017
import org.apache.spark.scheduler._
import org.apache.log4j.LogManager
val logger = LogManager.getLogger("CustomListener")
class CustomListener extends SparkListener {
override def onStageCompleted(stageCompleted: SparkListenerStageCompleted): Unit = {
@asanchez75
asanchez75 / smartcheck.sh
Created June 15, 2022 13:02 — forked from tommybutler/smartcheck.sh
Script to quickly scan the S.M.A.R.T. health status of all your hard drive devices in Linux (at least all the ones from /dev/sda to /dev/sdzz). You need smartctl installed on your system for this script to work, and your hard drives need to have S.M.A.R.T. capabilities (they probably do).
#!/bin/bash
# install the smartctl package first! (apt-get install smartctl)
if sudo true
then
true
else
echo 'Root privileges required'
@asanchez75
asanchez75 / lifehack.css
Created April 18, 2022 16:33 — forked from angelolev/lifehack.css
Script to see HTML elements containers and properties
<style>
html * {
background: rgba(255, 0, 0, .1);
box-shadow: 0 0 0 1px red;
}
</style>
@asanchez75
asanchez75 / gist:2ce9a19687053213a2b395c946ec91fd
Created April 3, 2022 16:18 — forked from taniwallach/gist:f1f6c81ce19b7d68f74d4b71d1db57a2
Installing HP-107w on Linux (using HP's unified linux driver ULDLINUX_V1.00.39_00.12.zip)
HP provides a downloadable "driver" for Linux for the HP 107w printer but there are NO reasonable install instructions provided, and following the "obvious" install process did not get the printer working.
The closest I found to HP install instuctions once I knew more is https://support.hp.com/in-en/document/c05588857
Since I found this annoying and wasted more time on getting this printer working under Linux, I'm sharing a summary of what did work (on Debian 10).
1. Download the driver file from https://support.hp.com/us-en/drivers/selfservice/hp-laser-100-printer-series/24494339/model/24494342 from under the "Basic Drivers" menu for when the OS is set to Linux.
The current version now is: "HP Laser 100 and HP Color Laser 150 Printer series Print Driver V1.00.39:00.12 5.9 MB Mar 20, 2019"
root@vmi465483:~# cat /etc/nginx/sites-enabled/dspace.conf
server {
server_name repositorio.unijuanpablo.edu.pe;
root /var/www/html/;
client_max_body_size 2000m;
location / {
return 301 http://repositorio.unijuanpablo.edu.pe/xmlui/;
}
@asanchez75
asanchez75 / postgres-deps.py
Created November 28, 2021 19:15 — forked from Tiduster/postgres-deps.py
Generating a dependency graph for Postgres DB
# From https://sigterm.sh/2010/07/09/generating-a-dependency-graph-for-a-postgresql-database/
# Converted to Python3
# Add config fort dbport
# Increase PNG Size
# pylinting
from optparse import OptionParser, OptionGroup
import sys
import psycopg2
@asanchez75
asanchez75 / ParallelProcessing.scala
Created October 1, 2021 11:07 — forked from pavel-filatov/ParallelProcessing.scala
Parallel processing with Scala-Spark
object ParallelProcessing {
val queries: List[(String, String)] = List(
("SELECT * FROM ABC", "output1"),
("SELECT * FROM XYZ", "output2")
)
// Just use parallel collection instead of futures, that's it
queries.par foreach {
case (query, path) =>
@asanchez75
asanchez75 / vim-shortcuts.md
Created October 29, 2020 16:39 — forked from tuxfight3r/vim-shortcuts.md
VIM SHORTCUTS

VIM KEYBOARD SHORTCUTS

MOVEMENT

h        -   Move left
j        -   Move down
k        -   Move up
l        -   Move right
$        -   Move to end of line
0        -   Move to beginning of line (including whitespace)