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
| alias via="vi ~/.bash_aliases" | |
| alias reload=". ~/.bash_aliases" | |
| alias c="clear" | |
| alias cls="clear" | |
| alias lk="ls -lrta" | |
| alias pp="pwd" | |
| echo "Aliases Set" |
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 re | |
| import linecache | |
| def find_line_with_pattern(log_file_name, pattern): | |
| lines = open(log_file_name).readlines() | |
| for i, line in enumerate(lines): | |
| if re.match(pattern, line): | |
| return i+1 |
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
| words_list = [ | |
| 'aahed', | |
| 'aalii', | |
| 'aargh', | |
| 'aarti', | |
| 'abaca', | |
| 'abaci', | |
| 'aback', | |
| 'abacs', | |
| 'abaft', |
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
| # Update path as required | |
| powershell -command "&{(Get-Item 'C:\Program Files\Google\Chrome\Application\chrome.exe').VersionInfo.ProductVersion}" | |
| ex: O/P | |
| 108.0.5359.125 |
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
| """ | |
| For the given Rubik's cube solution, generates the scramble | |
| For getting solution: | |
| https://ruwix.com/widget/3d/?label=Sample%20Solve&alg=F%20R%20F%20R%20U%20U%20L%20R%20L%20R%20U%27&flags=showalg&colors=WCA | |
| for this specific solution | |
| F R F R U U L R L R U' | |
| the scramble step is: |
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
| """Simple script to watch for specific process is over, and trigger action once it is over | |
| - Waits for some start time (the process is expected to start within this time) | |
| - Fetches all the running processes, exiting for below-mentioned conditions | |
| - Waits for next run | |
| - The watcher exits if: | |
| - process is not found running for max watcher timeout, from starting | |
| - current time is over max watcher timeout, from last process found time | |
| Requirements: |
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
| """ | |
| Original source: | |
| https://www.mattcrampton.com/blog/query_an_ntp_server_from_python/ | |
| """ | |
| from socket import AF_INET, SOCK_DGRAM | |
| import socket | |
| import struct | |
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 regex | |
| import json | |
| input_string = '''2020-12-23T07:23:18.000000+05:30 45.79.121.190 {"hostname":"abc.members.linode.com","os":{"name":"CentOS Linux","family":"redhat","version":"7 (Core)","platform":"centos","kernel":"3.10.0-1127.13.1.el7.x86_64","codename":"Core"},"containerized":false,"ip":["44.75.121.190","2400:8904::f03c:92ff:fed4:e4f0","fe80::f03c:92ff:fed4:e4f0"],"name":"abc.members.linode.com","cpu":{"pct":0.062},"id":"c29d751565e74afdbaade6c8a36dd2ef","mac":["f2:3c:92:d4:e4:f0"],"architecture":"x86_64"} LOGSTASH[-]: 2020-12-23T07:23:18.995Z {hostname=abc.members.linode.com, os={name=CentOS Linux, family=redhat, version=7 (Core), platform=centos, kernel=3.10.0-1127.13.1.el7.x86_64, codename=Core}, containerized=false, ip=[44.75.121.190, 2400:8904::f03c:92ff:fed4:e4f0, fe80::f03c:92ff:fed4:e4f0], name=abc.members.linode.com, cpu={pct=0.062}, id=c29d751565e74afdbaade6c8a36dd2ef, mac=[f2:3c:92:d4:e4:f0], architecture=x86_64} %{message}''' | |
| # def get_json2(input_str): | |
| # start = input_str.find('{ |
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 https://github.com/tiangolo/fastapi/issues/258 | |
| from typing import List | |
| from fastapi import FastAPI | |
| from starlette.responses import HTMLResponse | |
| from starlette.websockets import WebSocket, WebSocketDisconnect | |
| app = FastAPI() |
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
| # ref: https://stackoverflow.com/questions/12232304/how-to-implement-server-push-in-flask-framework | |
| import datetime | |
| import time | |
| import json | |
| from flask import Flask, Response | |
| app = Flask(__name__) | |
| def event_stream(): |