Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.
| Ctrl+C | copy current line (if no selection) |
| Ctrl+X | cut current line (if no selection) |
| Ctrl+⇧+K | delete line |
| Ctrl+↩ | insert line after |
| #!/usr/bin/python | |
| import subprocess | |
| import re | |
| # Get process info | |
| ps = subprocess.Popen(['ps', '-caxm', '-orss,comm'], stdout=subprocess.PIPE).communicate()[0] | |
| vm = subprocess.Popen(['vm_stat'], stdout=subprocess.PIPE).communicate()[0] | |
| # Iterate processes |
Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.
| Ctrl+C | copy current line (if no selection) |
| Ctrl+X | cut current line (if no selection) |
| Ctrl+⇧+K | delete line |
| Ctrl+↩ | insert line after |
| # A simple cheat sheet of Spark Dataframe syntax | |
| # Current for Spark 1.6.1 | |
| # import statements | |
| from pyspark.sql import SQLContext | |
| from pyspark.sql.types import * | |
| from pyspark.sql.functions import * | |
| #creating dataframes | |
| df = sqlContext.createDataFrame([(1, 4), (2, 5), (3, 6)], ["A", "B"]) # from manual data |
| '''To fetch top 5 lastest Episodes & Release Dates from Anime Websites.''' | |
| import requests | |
| from bs4 import BeautifulSoup | |
| from IPython.core.display import display, HTML | |
| SAMURAI_JACK_SITE_URL = "http://www.toonova.net/samurai-jack-season-5" | |
| MY_HERO_ACADEMIA_SITE_URL = "http://watchmha2.com/" | |
| DBZ_SUPER_SITE_URL ="http://watchdbzsuper.tv/" |
| """ Trains an agent with (stochastic) Policy Gradients on Pong. Uses OpenAI Gym. """ | |
| import numpy as np | |
| import cPickle as pickle | |
| import gym | |
| # hyperparameters | |
| H = 200 # number of hidden layer neurons | |
| batch_size = 10 # every how many episodes to do a param update? | |
| learning_rate = 1e-4 | |
| gamma = 0.99 # discount factor for reward |
| from airflow.models import Variable | |
| # Common (Not-so-nice way) | |
| # 3 DB connections when the file is parsed | |
| var1 = Variable.get("var1") | |
| var2 = Variable.get("var2") | |
| var3 = Variable.get("var3") | |
| # Recommended Way | |
| # Just 1 Database call |
| import io | |
| import pandas as pd | |
| def split_s3_name(s3_path): | |
| bucket, key = s3_path.strip('s3://').split('/', 1) | |
| return (bucket, key) | |
| def read_from_s3(file_name): |
| # Extracted using: $ unzip -p lib/pycharm.jar com/jetbrains/python/PyBundle.properties | grep -B1 INSP.NAME | grep '^#' | sed 's|Inspection||g' | sed -e 's|#\s\{,1\}|# noinspection |' | |
| # noinspection PyPep8 | |
| # noinspection PyPep8Naming | |
| # noinspection PyTypeChecker | |
| # noinspection PyAbstractClass | |
| # noinspection PyArgumentEqualDefault | |
| # noinspection PyArgumentList | |
| # noinspection PyAssignmentToLoopOrWithParameter | |
| # noinspection PyAttributeOutsideInit |
| # Testing https://github.com/GoogleCloudPlatform/magic-modules/pull/5448/files | |
| # Step by Step - Instructions | |
| - Step1: Download files | |
| ``` | |
| wget https://github.com/GoogleCloudPlatform/magic-modules/raw/e8d547a02b95d7a1a650b52c5968404ee57a7b14/mmv1/products/compute/terraform.yaml | |
| wget https://github.com/GoogleCloudPlatform/magic-modules/raw/e8d547a02b95d7a1a650b52c5968404ee57a7b14/mmv1/templates/terraform/examples/external_ssl_proxy_lb_mig_backend_custom_header.tf.erb |