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
"use client"; | |
import React, { useState, useRef, useEffect } from "react"; | |
interface HoverSVGProps { | |
src: string; | |
width: number; | |
height: number; | |
color: string; | |
alt: string; | |
hoverColor: string; |
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, sys, os | |
from openai import OpenAI | |
newsapi_apikey = os.environ.get('NEWS_APIKEY') | |
# This is a terrible excuse for a keywords function. Please replace. Most issues with this RAG can be blamed on this. | |
def get_keywords(input_text): | |
stripped = ''.join([i for i in input_text if i.isalpha() or i == ' ']) |
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
# This is a solver for The Password Game: https://neal.fun/password-game/, | |
# Specifically the section "The elements in your password must have atomic numbers that add up to 200" | |
# It's written as a Flask app because I was sharing it with my friends that were also playing. | |
# However you can just use the function `get_required_elements_for_password_game(password)` | |
# to do it locally | |
# Got ChatGPT to write the element list for me | |
elements = [ | |
{"name": "Hydrogen", "symbol": "H", "atomic_number": 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
class Timer: | |
def __init__(self, indent = 30): | |
self.start = time.time() | |
self.rj = indent | |
self.report = 'Start:'.rjust(self.rj) + '0.000000'.rjust(10) | |
self.current = self.start | |
def diff(self, msg): | |
tmp = self.current | |
self.current = time.time() | |
return msg.rjust(self.rj) +':'+str(round(self.current - tmp, 6)).rjust(10) |
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
# The function: | |
get_headers = lambda curl: {k:v for k, v in | |
[[i.strip().strip(r"'-H \$'") for i in | |
[x.split(': ')[0], ': '.join(x.split(': ')[1:])]] | |
for x in curl.split('\n') | |
if '-H' in x]} | |
# You get a curl request in this kind of format from eg: Chrome Developer Tools | |
# Important: all arguments must be on a new line and it must be a raw string (the r before the triple quotes) |
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
FILES="*.eps"; for f in $FILES; do ps2pdf -dEPSCrop $f; done |
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 turtle | |
# msgr font is Roboto | |
# draw rounded corner | |
def corner(tess): | |
for i in range(15): | |
tess.right(6) | |
tess.forward(2) | |
# draw rounded, filled rectangle of around (40+h)*(40+w) dimensions |
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 praw | |
import re | |
import pandas as pd | |
# connect to reddit | |
reddit = praw.Reddit(client_id='my_id', client_secret='my_secret', user_agent='me') | |
# get new submissions from News | |
submissions = [] | |
for submission in reddit.subreddit("News").new(limit = None): |
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 praw | |
import re | |
from tqdm import tqdm | |
import pandas as pd | |
pd.options.display.max_colwidth = 70 | |
# pick subreddits, any delimiter but letter, number and new line is okay (will default to r/news if no valid input) | |
subreddits = "+".join(re.findall(r'[A-Za-z0-9]+', raw_input("Enter desired subreddits on one line\n"))) | |
print "Your subreddits are: " + subreddits |
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
cat |
NewerOlder