This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def random_number_generator(arg1, arg2): | |
| """ | |
| Summary line. | |
| Extended description of function. | |
| Parameters | |
| ---------- | |
| arg1 : int | |
| Description of arg1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (fn [delim lst] | |
| (reduce #(if (true? (< %2 delim)) | |
| (conj %1 %2) %1) [] lst)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (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")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ssh-copy-id -i <identity-file> user@host |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -O and -x drop privalages and owners on database | |
| pg_dump cap -U postgres -h localhost -Fc -p 9000 -O -x --verbose > dump.bak |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* 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) |
NewerOlder