On the command prompt, type screen
. Run the desired program. Use the key sequence ctrl-a + ctrl-d
to detach from the screen session. Reattach to the screen session by typing screen -r
.
$ screen -list
or
-- show running queries (pre 9.2) | |
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query | |
FROM pg_stat_activity | |
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
ORDER BY query_start desc; | |
-- show running queries (9.2) | |
SELECT pid, age(clock_timestamp(), query_start), usename, query | |
FROM pg_stat_activity | |
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
IPython.core.debugger.Pdb.set_trace() | |
# DeprecationWarning: `Tracer` is deprecated since version 5.1, directly use `IPython.core.debugger.Pdb.set_trace()` | |
from IPython.core.debugger import Tracer; Tracer()() |
function count_emails() { | |
var max = 500; | |
var offset = 0; | |
var emails = []; | |
while (true) { | |
var threads = GmailApp.search("in:anywhere", offset, max); | |
emails = searchThreads.concat(threads); | |
if (threads.length < max) { |
var ui = SpreadsheetApp.getUi(); | |
function onOpen(e){ | |
ui.createMenu("Gmail Manager").addItem("Get Emails by Label", "getGmailEmails").addToUi(); | |
} | |
function getGmailEmails(){ | |
var input = ui.prompt('Label Name', 'Enter the label name that is assigned to your emails:', Browser.Buttons.OK_CANCEL); | |
import random | |
from collections import Counter | |
random.seed(3) | |
pizzas = ['caipira', 'portuguesa', 'pepperoni', '4 queijos'] | |
print(Counter([random.sample(pizzas, 1)[0] for r in range(1000)])) |
// paste it in your console and change the url to your needs. | |
function logout(to_url) { | |
var out = window.location.href.replace(/:\/\//, '://log:out@'); | |
jQuery.get(out).error(function() { | |
window.location = to_url; | |
}); | |
} |
from math import gcd | |
from functools import reduce | |
# or | |
# def gcd(a, b): | |
# """Return greatest common divisor using Euclid's Algorithm.""" | |
# while b: | |
# a, b = b, a % b | |
# return a |
# credits for -> https://www.sisense.com/blog/exact-row-counts-for-every-database-table/ | |
CREATE OR REPLACE FUNCTION | |
count_rows(schema text, tablename text) RETURNS integer | |
AS | |
$BODY$ | |
DECLARE | |
result integer; | |
query varchar; | |
BEGIN |
--- | |
- name: Create Instance in AWS | |
hosts: localhost | |
connection: local | |
gather_facts: false | |
vars: | |
aws_access_key: "xxxxxx" | |
aws_secret_key: "xxxxxx" | |
security_token: "xxxxxx" |