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
version: '2.2' | |
services: | |
es01: | |
image: docker.elastic.co/elasticsearch/elasticsearch:7.12.0 | |
container_name: es01 | |
environment: | |
- node.name=es01 | |
- cluster.name=es-docker-cluster | |
- discovery.seed_hosts=es02,es03 | |
- cluster.initial_master_nodes=es01,es02,es03 |
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 python | |
""" | |
Remove emoji from a text file and print it to stdout. | |
Usage | |
----- | |
python remove-emoji.py input.txt > output.txt | |
""" |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
library(readr) | |
library(dplyr) | |
url <- "https://archive.ics.uci.edu/ml/machine-learning-databases/wine-quality/winequality-white.csv" | |
df <- | |
read_delim(url, delim = ";") %>% | |
dplyr::mutate(taste = as.factor(ifelse(quality < 6, "bad", ifelse(quality > 6, "good", "average")))) %>% | |
dplyr::select(-quality) |
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
# Redis Cheatsheet | |
# All the commands you need to know | |
redis-server /path/redis.conf # start redis with the related configuration file | |
redis-cli # opens a redis prompt | |
# Strings. |
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
# https://stackoverflow.com/questions/3463930/how-to-round-the-minute-of-a-datetime-object-python/10854034#10854034 | |
def roundTime(dt=None, roundTo=60): | |
"""Round a datetime object to any time laps in seconds | |
dt : datetime.datetime object, default now. | |
roundTo : Closest number of seconds to round to, default 1 minute. | |
Author: Thierry Husson 2012 - Use it as you want but don't blame me. | |
""" | |
if dt == None : dt = datetime.datetime.now() | |
seconds = (dt - dt.min).seconds |
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
class edict(dict): # Similar to bunch, but less, and JSON-centric | |
# based on class dotdict(dict): # from http://stackoverflow.com/questions/224026/dot-notation-for-dictionary-keys | |
__setattr__= dict.__setitem__ # TBD: support assignment of nested dicts by overriding this? | |
__delattr__= dict.__delitem__ | |
def __init__(self, data): | |
if type(data) in ( unicode, str ): | |
data = json.loads( data) | |
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
-- 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%' |