Skip to content

Instantly share code, notes, and snippets.

View tlkahn's full-sized avatar
🥫

JG tlkahn

🥫
View GitHub Profile
import random
def quirky_text_converter(text):
"""
Convert normal text to a quirky, alternating case with intermittent capitalization.
Parameters:
text (str): The text to convert.
Returns:
@tlkahn
tlkahn / diamond_depencies.py
Created October 18, 2024 05:55
I really enjoyed this kinda of design. Look nowhere else. Code is the flow.
import random
from typing import List, Tuple
import ell
@ell.simple(model="gpt-4o-mini", temperature=1.0)
def random_number() -> str:
"""You are silly robot. Only respond with a number."""
return "Come with up with a random number"
@tlkahn
tlkahn / main.py
Last active October 15, 2024 03:05
from typing import List, Tuple
class Polynomial:
def __init__(self, neg: List[float], pos: List[float]):
"""
Initialize the polynomial.
- neg: Coefficients for negative exponents, ordered from x^{-1}, x^{-2}, ...
- pos: Coefficients for non-negative exponents, ordered from x^{0}, x^{1}, ...
"""
self.neg = neg.copy() # e.g., [a1, a2, ...] for a1*x^{-1} + a2*x^{-2} + ...
@tlkahn
tlkahn / main.py
Last active October 15, 2024 02:20
import numpy as np
def gaussian_elimination(A, b):
"""
Gaussian elimination is a method for solving systems of linear equations. It involves transforming a matrix into row echelon form through a series of elementary row operations. Key points:
1. Used to solve linear systems: $Ax = b$
2. Steps:
- Convert to augmented matrix [A|b]
- Transform to row echelon form

Smart Contract Weakness Classification (SWC)

The content of the SWC registry has not been thoroughly updated since 2020. It is known to be incomplete and may contain errors as well as crucial omissions.

For currently maintained guidance on known Smart Contract vulnerabilities written primarily as guidance for security reviewers, please see the EEA EthTrust Security Levels specification. As well as the latest release version, an Editor’s draft is available, that represents the latest work of the group developing the specification.

General guidance for developers on how to ensure security, that is currently maintained, is also available through the Smart Contract Security Verification Standard (SCSVS), or the Smart Contract Security Field Guide.

The following table contains an overview of the SWC registry. Eac

@tlkahn
tlkahn / gist:7cd95c48662e863b8c6086da25a11be8
Created September 29, 2024 03:34
local request to llvm served instance
require 'net/http'
require 'json'
uri = URI('http://localhost:8000/v1/chat/completions')
request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
request.body = {
model: 'meta-llama/Llama-3.2-1B',
messages: [{ role: 'user', content: ARGV[0] }],
chat_template: "{% for message in messages %}{{'\u003chuman\u003e' if message.role == 'user' else '\u003cassistant\u003e'}}{{ message.content }}{% if not loop.last %}{{ '\\n' }}{% endif %}{% endfor %}{% if add_generation_prompt %}\\n\u003cassistant\u003e{% endif %}",
max_tokens: 100,
@tlkahn
tlkahn / snail.md
Last active September 13, 2024 06:28

The idea of a snail crawling from Earth to Mars is a fun hypothetical scenario! While it's not physically possible for a snail to survive and move through space, we can calculate how long it would take based on average distances and the snail's typical speed.

Snail's Average Speed

  • Average speed of a common garden snail: Approximately 1 millimeter per second (mm/s), which is 0.001 meters per second (m/s).

Distance Between Earth and Mars

The distance between Earth and Mars varies due to their elliptical orbits around the Sun:

The idea of a snail crawling from Earth to Mars

@tlkahn
tlkahn / snail.md
Created September 13, 2024 06:26
snail.md

The idea of a snail crawling from Earth to Mars