| Cmd | Note |
|---|---|
| Activating Modes | |
i |
activate insert mode |
I |
move cursor to beginning of line and activate insert mode |
a |
move cursor forward one and activate insert mode |
A |
append - move to end of line and activate insert mode |
r |
replace single character |
R |
activate replace mode |
v |
activate highlight (visual) mode |
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
| #!/usr/bin/env bash | |
| ## Uses GCP's Text-to-Speech API to convert text to MP3 | |
| ## example: ./text-to-speech.sh -li sheet1 # loop through file sheet1.csv, store files in folder called sheet1/ | |
| ## ./text-to-speech.sh -i sample.txt -o sample.mp3 # do single text block | |
| ## ./text-to-speech.sh -i "hello world!" -o sample.mp3 # do inline text | |
| ## prerequisite CLI tools: csvtool, jq, curl, gcloud | |
| ## Needs service account and features enabled in GCloud: | |
| ## - APIs |
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
| '''Merge complex dictionaries''' | |
| def is_element(obj): | |
| if isinstance(obj, dict) or isinstance(obj, list): | |
| return False | |
| return True | |
| def is_dict(obj): | |
| return isinstance(obj, dict) |
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
| # remove these first 3 lines before use. CLI command example: | |
| # oci compute-management instance-configuration create -c $COMPARTMENT_OCID --instance-details file://$PWD/inst_config.json --display-name $INST_CONFIG_NAME | |
| # oci compute-management instance-configuration launch-compute-instance --instance-configuration-id $INST_CONFIG_OCID --launch-details '{"display-name": "inst-config-test"}' | |
| { "block-volumes": null, | |
| "instance-type": "compute", | |
| "launch-details": { | |
| "agent-config": { | |
| "is-management-disabled": false, | |
| "is-monitoring-disabled": false | |
| }, |
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
| import sys | |
| import json | |
| import logging | |
| from logging.handlers import TimedRotatingFileHandler | |
| from pythonjsonlogger import jsonlogger | |
| STREAM_FORMATTER = logging.Formatter( | |
| "%(asctime)s — %(name)s — %(levelname)s: %(message)s" | |
| ) | |
| FORMAT_DICT = { |
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
| ''' | |
| Render a single Jinja2 template. Example usage: | |
| python render_single_template.py -v vars.yml > nginx.conf | |
| Sample vars.yml file: | |
| template: nginx.conf.j2 | |
| search-path: "./" | |
| name: localhost | |
| locations: | |
| - root |
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
| # download data from https://ourworldindata.org/coronavirus#confirmed-covid-19-cases-by-country | |
| # filter to US only | |
| # date starts with March 1, 2020 | |
| # Setup dataframe | |
| df <- read.csv('data-covid-19.csv', header=F, sep="\t") | |
| df$V1 <- as.Date(df$V1, format="%m/%d/%Y") | |
| names(df) <- c("date", "count") | |
| r.num <- nrow(df) |
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
| #!/usr/bin/env python | |
| '''RobinHood gives account info as string. This converts string into DataFrame''' | |
| import pandas as pd | |
| pd.set_option('display.max_columns',10) | |
| pd.set_option('display.max_rows',200) | |
| pd.set_option('display.expand_frame_repr',False) |
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
| ## int to bytes | |
| from math import ceil | |
| def int2byte(i): | |
| bytes = ceil(i.bit_length()/8) | |
| return i.to_bytes(bytes, 'big') | |
| x = 5 | |
| type(x) |
NewerOlder