Skip to content

Instantly share code, notes, and snippets.

def random_number_generator(arg1, arg2):
"""
Summary line.
Extended description of function.
Parameters
----------
arg1 : int
Description of arg1
(fn [delim lst]
(reduce #(if (true? (< %2 delim))
(conj %1 %2) %1) [] lst))
(use '[clojure.java.shell :only [sh]])
(require '[clojure.string :as str])
(defn execute-command [command]
"""
Execute shell command and return output as a vector
"""
(str/split (:out (sh command)) #"\n"))
ssh-copy-id -i <identity-file> user@host
rpn = folding [] words
where folding (x:y:ys) "+" = (y + x):ys
folding (x:y:ys) "-" = (y - x):ys
folding (x:y:ys) "*" = (y * x):ys
folding (x:y:ys) "/" = (y / x):ys
folding xs number = read number:xs
@aaraza
aaraza / pg_backup.sh
Last active October 8, 2017 02:23
Backing up and restoring postgres database
# -O and -x drop privalages and owners on database
pg_dump cap -U postgres -h localhost -Fc -p 9000 -O -x --verbose > dump.bak
@aaraza
aaraza / commands.sh
Last active February 1, 2019 20:40
Useful CLI commands
# Move all subdirectory files into parent folder
find . -mindepth 2 -type f -print -exec mv {} . \;
# Remove files from temp directory older than 12 hrs
find /tmp/* -mmin +720 -exec /bin/rm -rf {} +
# Change default screenshot location on macs
defaults write com.apple.screencapture location <path>
# Rename files in a folder example
@aaraza
aaraza / subqueries.sql
Last active January 26, 2023 22:01
SQL subqueries on the Sakila database.
/* Find the full name and email address of all customers that have rented an action movie. */
SELECT CONCAT(first_name, " ", last_name) AS name, email
FROM customer WHERE customer_id IN
(SELECT customer_id FROM rental WHERE inventory_id IN
(SELECT inventory_id FROM inventory WHERE film_id IN
(SELECT film_id FROM film_category JOIN category USING (category_id) WHERE category.name="Action")));
/* Find the name of each film, its category, and the aggregate number of films that fall within that category*/
SELECT film.title, category.name, `count`.count_of_category FROM film
JOIN film_category USING(film_id)