Skip to content

Instantly share code, notes, and snippets.

Jesús Gómez jgomo3

Block or report user

Report or block jgomo3

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
jgomo3 / edgelist.sql
Created Aug 9, 2019
Create an edge list of relations being related by foreign key [postgres]
View edgelist.sql
-- Pre: The names of the relations to consider are in a relation named nodes in
-- the public schema (it could be parametrized)
tc.table_name watcher
, ctu.table_name target
information_schema.table_constraints tc
INNER JOIN information_schema.constraint_table_usage ctu ON tc.constraint_name = ctu.constraint_name
INNER JOIN nodes pt ON tc.table_name = pt."name"
jgomo3 /
Created Jun 4, 2019 — forked from drmalex07/
An example with an oneshot service on systemd. #systemd #systemd.service #oneshot


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/

jgomo3 /
Created May 29, 2019
WeatherWizard Java Tutorial example without Applets
* Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
jgomo3 / publisher_worker_class_factory.rb
Created Apr 12, 2019
One way to wrap mundane things to a Sidekiq Worker perform method
View publisher_worker_class_factory.rb
module Notification
def self.publisher_worker_class(klass) do
include(Sidekiq::Worker, Wisper::Publisher)
sidekiq_options(:queue => :report)
define_method :perform do |*args, **kwargs|
success = false
context =*args, **kwargs)
broadcast(:deliveried_report_delivery, context)
jgomo3 / my-ruby.el
Created Nov 5, 2018 — forked from littlemove/my-ruby.el
Spacemacs: Code folding for ruby-mode
View my-ruby.el
;; Code folding
(add-hook 'ruby-mode-hook
(lambda () (hs-minor-mode)))
(eval-after-load "hideshow"
'(add-to-list 'hs-special-modes-alist
,(rx (or "def" "class" "module" "do" "{" "[")) ; Block start
,(rx (or "}" "]" "end")) ; Block end
,(rx (or "#" "=begin")) ; Comment start
jgomo3 / seeds.rb
Created Jul 11, 2018 — forked from seyhunak/seeds.rb
Rails - Import SQL file as seed
View seeds.rb
unless Rails.env.production?
connection = ActiveRecord::Base.connection
connection.tables.each do |table|
connection.execute("TRUNCATE #{table}") unless table == "schema_migrations"
sql ='db/import.sql')
statements = sql.split(/;$/)
jgomo3 / infix.clj
Last active Apr 18, 2018
Last exercise of the Read and Eval Chapter of Brave Clojre
View infix.clj
(ns infix)
(defn index-of
"Clojure doesn't have an index-of function. The Java .indexOf method
works reliably for vectors and strings, but not for lists. This solution
works for all three.
[item coll]
(let [v (if
jgomo3 /
Last active Apr 5, 2018
Function composition and piping (or chaining) using reduce
from functools import partial
from functools import reduce
def _chain(order, *functions):
ordered_functions = list(order(functions))
first_fn = ordered_functions[0]
rest_fn = ordered_functions[1:]
def _apply(x, f):
return f(x)
def composite(*args, **kwargs):
jgomo3 /
Created Mar 19, 2018 — forked from craigvantonder/
Flushing the DNS in Ubuntu 16.04
# 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
jgomo3 / smash_hobbits.clj
Created Mar 16, 2018
Chapter 3 excercise for the "Clojure for the Brave and True" -- For hitting hobbits
View smash_hobbits.clj
(ns clojure-noob.smash-hobbits
(:require [clojure.string :as str]))
(def asym-hobbit-body-parts [{:name "head" :size 3}
{:name "left-eye" :size 1}
{:name "left-ear" :size 1}
{:name "mouth" :size 1}
{:name "nose" :size 1}
{:name "neck" :size 2}
{:name "left-shoulder" :size 3}
You can’t perform that action at this time.