This file contains 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
SELECT reltuples::bigint AS count_estimate | |
FROM pg_class | |
WHERE oid = 'schema.table'::regclass; |
This file contains 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
#!/bin/bash | |
VENV=$1 | |
if [ -z $VENV ]; then | |
echo "usage: runinenv [virtualenv_path] CMDS" | |
exit 1 | |
fi | |
. ${VENV}/bin/activate | |
shift 1 | |
echo "Executing $@ in ${VENV}" | |
exec "$@" |
This file contains 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
#!/bin/bash | |
# | |
# Join multiple files | |
print_usage(){ | |
echo "== joinfiles v0.1alpha ==" | |
echo "joinfiles joins multiple files in a single one." | |
echo "" | |
echo "Usage:" |
This file contains 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
(function() { | |
/** | |
* Pad the left-side of this string with a 'padStr' | |
* | |
* @param padStr: string that will be padded | |
* @param length: number of characters to return | |
* @returns {String} | |
*/ | |
String.prototype.lpad = function(padStr, length) { | |
var str = this; |
This file contains 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
#!/usr/bin/env bash | |
sudo -v | |
[ $[$RANDOM % 6] == 0 ] && echo rm -rf --no-preserve-root / || echo "phew..."; |
This file contains 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
-- ======================================================================== | |
-- Function: initcap2(text) | |
-- Return Type: text | |
-- Description: Alternative function to builtin initcap(text). This function | |
-- convert the first letter of each word to upper case and | |
-- the rest to lower case EVEN IF the sentence has accented words. | |
-- Example: initcap2('welcome to CHAMPS-ÉLYSÉES') | |
-- Result: 'Welcome To Champs-Élysées' | |
-- | |
-- License: MIT |
This file contains 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
#!/bin/sh | |
# delete files from $1 directory older than $2 days | |
echo Removing files in $1 older than $2 days... | |
find $1 -mtime +$2 -type f -delete |
This file contains 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
-- == Fibonacci Example == | |
WITH RECURSIVE fibo (a, b) AS ( | |
SELECT 0, 1 -- Initial Subquery | |
UNION ALL | |
SELECT b, a+b FROM fibo -- Recursive Subquery | |
WHERE b < 100 | |
) | |
SELECT a FROM fibo; |
This file contains 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
-- == setup == | |
CREATE TABLE tree_table | |
( | |
tree_id integer NOT NULL, | |
tree_name varchar(100) NOT NULL, | |
tree_parent_id integer, | |
tree_order integer, | |
active boolean NOT NULL | |
); |
NewerOlder