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 csv | |
| import argparse | |
| def main(): | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument("--file") | |
| parser.add_argument("--outfile") | |
| args = parser.parse_args() | |
| mapping = { |
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 os | |
| import re | |
| import logging | |
| def rename_it(dirpath, path_suffix, is_dir): | |
| pattern = r"([a-zA-Z0-9\s\+\&\']+)\s([a-z0-9]{32})" | |
| match = re.match(pattern, path_suffix) | |
| if match is not None: | |
| if is_dir: |
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
| from kafka import KafkaConsumer | |
| consumer1 = KafkaConsumer('payments', group_id="group1", bootstrap_servers='localhost:9092') | |
| for msg in consumer1: | |
| print(msg) |
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 tweepy | |
| import os | |
| consumer_key = os.getenv("TWITTER_API_KEY") | |
| consumer_secret = os.getenv("TWITTER_API_SECRET") | |
| access_token = os.getenv("TWITTER_OAUTH_TOKEN") | |
| access_token_secret = os.getenv("TWITTER_OAUTH_SECRET") | |
| auth = tweepy.OAuthHandler(consumer_key, consumer_secret) |
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 tweepy | |
| import os | |
| consumer_key = os.getenv("TWITTER_API_KEY") | |
| consumer_secret = os.getenv("TWITTER_API_SECRET") | |
| access_token = os.getenv("TWITTER_OAUTH_TOKEN") | |
| access_token_secret = os.getenv("TWITTER_OAUTH_SECRET") | |
| auth = tweepy.OAuthHandler(consumer_key, consumer_secret) |
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
| Nginx Redirection flow | |
| www.host.com www.host.com | |
| 80 443 | |
| \ / |
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 requests | |
| import sys | |
| import webbrowser | |
| GITHUB_URL = "https://api.github.com/search/repositories?q={query_string}&sort=stars" | |
| class CustomException(Exception): | |
| pass | |
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
| const path = require("path"); | |
| const webpack = require("webpack"); | |
| const TerserPlugin = require("terser-webpack-plugin"); | |
| const { CleanWebpackPlugin } = require("clean-webpack-plugin"); | |
| const HtmlWebpackPlugin = require("html-webpack-plugin"); | |
| const MiniCssExtractPlugin = require("mini-css-extract-plugin"); | |
| const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin"); | |
| module.exports = ({ mode, presets } = { mode: "production", presets: [] }) => ({ | |
| devtool: "eval-cheap-module-source-map", |
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
| def get_starting_date_minus_n_months(curr_date, num_months): | |
| """ | |
| Given the curr_date (datetime) object and num_months, returns the starting date | |
| minus "num_months" months. Note that time won't change | |
| for example: curr_date is "2019-10-22 23:59:59" and num_months is 3 | |
| it returns "2019-07-01 23:59:59" | |
| """ | |
| if num_months < 0: | |
| raise ValueError( |
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
| def divide(data, n_column=3): | |
| result = [] | |
| cur_index = 0 | |
| n = len(data) | |
| while cur_index < n/n_column: | |
| result.append(data[cur_index*n_column: (cur_index+1)*n_column]) | |
| cur_index += 1 | |
| if n%n_column != 0: | |
| result.append(data[cur_index*n_column: (cur_index+1)*n_column]) | |
| return result |
NewerOlder