using github client - gh
https://cli.github.com/manual/gh_gist
add --public for creating public gist; if not given, by default created - secret
$ gh gist create --public hello.py
import time | |
def do_once(): | |
s = 0 | |
start = time.time() | |
for i in range(1_00_00_000): | |
s += i | |
print(f"Sum is {s:_}") | |
finish = time.time() | |
duration = finish - start |
import random | |
import string | |
from faker import Faker | |
fake = Faker() | |
def generate_random_string(length=10): | |
return ''.join(random.choices(string.ascii_lowercase, k=length)) | |
def generate_user_info(num_users=50): |
using github client - gh
https://cli.github.com/manual/gh_gist
add --public for creating public gist; if not given, by default created - secret
$ gh gist create --public hello.py
import openai | |
import openai.types | |
def check_openai_api_key(api_key): | |
openai.api_key = api_key | |
try: | |
openai.models.list() | |
except openai.AuthenticationError as e: | |
return False |
function eventFire(el, etype){ | |
if (el.fireEvent) { | |
el.fireEvent('on' + etype); | |
} else { | |
var evObj = document.createEvent('Events'); | |
evObj.initEvent(etype, true, false); | |
el.dispatchEvent(evObj); | |
} | |
} |
import sys | |
import turtle | |
def generate_magic_square(n): | |
""" | |
This works only for odd grid size 3x3, 5x5, 11x11 etc., not for even | |
""" | |
magic_square = [[0] * n for _ in range(n)] | |
num = 1 |
import time | |
from multiprocessing import Process | |
import pytest | |
def proc_a(): | |
print("starting proc a") | |
i = 1 | |
# for i in range(10): |
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" |
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 |
words_list = [ | |
'aahed', | |
'aalii', | |
'aargh', | |
'aarti', | |
'abaca', | |
'abaci', | |
'aback', | |
'abacs', | |
'abaft', |