Skip to content

Instantly share code, notes, and snippets.

@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) =>
from SPARQLWrapper import SPARQLWrapper, POST, BASIC, DIGEST, TURTLE, N3, XML, RDFXML
from rdflib import Graph
sparql = SPARQLWrapper("http://localhost:7200/repositories/myrepo")
sparql.setHTTPAuth(BASIC)
sparql.setCredentials("admin", "admin")
sparql.setMethod(POST)
sparql.setQuery("""
construct {?s ?p ?o}
where {
@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)
SELECT * FROM sys_rdf_schema;
ld_dir('/data', '*.ttl', 'http://www.example.com/genealogy.owl#');
delete from DB.DBA.load_list where ll_file='/data//einstein.ttl';
SPARQL SELECT (COUNT(DISTINCT ?x) AS ?count) WHERE { ?x ?y ?z };
sparql clear graph <http://www.example.com/genealogy.owl#>;
sparql load <https://github.com/blokhin/genealogical-trees/raw/master/data/header.ttl> into <http://www.example.com/genealogy.owl#>;
rdfs_rule_set('fhkb', 'http://www.example.com/genealogy.owl#');
SPARQL SELECT ?g count(*) as ?count WHERE { GRAPH ?g {?s ?p ?o } } GROUP BY ?g ORDER BY DESC 2;

Lsyncd Technical Session

So what is lsyncd?

Lsyncd is a tool used to keep a source directory in sync with other local or remote directories. It is a solution suited keeping directories in sync by batch processing changes over to the synced directories.

When would we use lsyncd?

So the generic use case is to keep a source directory in sync with one or more local and remote directories.

@asanchez75
asanchez75 / trim.awk
Created March 21, 2020 07:01 — forked from andrewrcollins/trim.awk
ltrim(), rtrim(), and trim() in awk
function ltrim(s) { sub(/^[ \t\r\n]+/, "", s); return s }
function rtrim(s) { sub(/[ \t\r\n]+$/, "", s); return s }
function trim(s) { return rtrim(ltrim(s)); }
BEGIN {
# whatever
}
{
# whatever
}
END {
@asanchez75
asanchez75 / tmux.md
Created February 26, 2020 12:40 — forked from Bekbolatov/tmux.md
Clean tmux cheat-sheet

Clean tmux cheat-sheet

By resources

sessions

list-sessions        ls         -- List sessions managed by server
new-session          new        -- Create a new session
@asanchez75
asanchez75 / nginx_reverse_for_notebook
Created February 10, 2020 12:30 — forked from kent119/nginx_reverse_for_notebook
Config Nginx as a reverse proxy for Jupyter notebook on VPS
# /etc/nginx/sites-enabled/some.domain
# Change the server name {some.domain}
# Change the {host.of.notebook} and {port} in the following locations
server {
listen 80;
# Change the server name {some.domain}
server_name some.domain;
location / {
# Change the {host.of.notebook} and {port}
proxy_pass http://host.of.notebook:port;
@asanchez75
asanchez75 / Vagrantfile
Created February 7, 2020 13:21 — forked from z3cka/Vagrantfile
Sample base Vagrantfile with 2GB of ram and 2 cpus :-) Initialize with: vagrant init precise32 http://files.vagrantup.com/precise32.box
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "precise32"