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 most atomic way to train and run inference for a GPT in pure, dependency-free Python. | |
| This file is the complete algorithm. | |
| Everything else is just efficiency. | |
| @karpathy | |
| """ | |
| import os # os.path.exists | |
| import math # math.log, math.exp |
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
| document.querySelector("table") |
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
| splash:runjs([[ | |
| document.querySelector('table').innerHTML | |
| ]]) |
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
| # List of Highly Used Pandas Data Transforms | |
| # 1. Loading Data | |
| import pandas as pd | |
| data = pd.read_csv('data.csv') | |
| # 2. Basic Inspection | |
| data.info() | |
| data.describe() | |
| data.head() |
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
| # Thanks to commenters for providing the base of this much nicer implementation! | |
| # Save and run with $ python 0dedict.py | |
| # You may need to hunt down the dictionary files yourself and change the awful path string below. | |
| # This works for me on MacOS 10.14 Mohave | |
| from struct import unpack | |
| from zlib import decompress | |
| import re | |
| filename = '/System/Library/Assets/com_apple_MobileAsset_DictionaryServices_dictionaryOSX/9f5862030e8f00af171924ebbc23ebfd6e91af78.asset/AssetData/Oxford Dictionary of English.dictionary/Contents/Resources/Body.data' | |
| f = open(filename, 'rb') |
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
| # Thanks to commenters for providing the base of this much nicer implementation! | |
| # Save and run with $ python 0dedict.py | |
| # You may need to hunt down the dictionary files yourself and change the awful path string below. | |
| # This works for me on MacOS 10.14 Mohave | |
| from struct import unpack | |
| from zlib import decompress | |
| import re | |
| filename = '/System/Library/Assets/com_apple_MobileAsset_DictionaryServices_dictionaryOSX/9f5862030e8f00af171924ebbc23ebfd6e91af78.asset/AssetData/Oxford Dictionary of English.dictionary/Contents/Resources/Body.data' | |
| f = open(filename, 'rb') |
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
| -- A robust table inspection utility | |
| function inspectTable(t, method) | |
| if (method == "inspect") then | |
| print(hs.inspect(t)) | |
| elseif (method == "keys") then | |
| for k, v in pairs(t) do | |
| print(k) | |
| end | |
| elseif (method == "metatable") then | |
| if (t.__metatable ~= nil) then |
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
| <style id="flickersuppression"> | |
| /* Add CSS to elements you want to hide */ | |
| #carousel {visibility:hidden !important} | |
| </style> | |
| <script type="text/javascript"> | |
| /* | |
| This function will poll the DOM for a specified amount of time until a specific element is available in the DOM and once available, execute a callback function which can be used to change the content on the page. The arguments are: | |
| t: A function which returns the DOM element you are looking for. | |
| e: The callback function to execute after the element exists. | |
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
| <style id="flickersuppression"> | |
| /* Add CSS to elements you want to hide */ | |
| #carousel {visibility:hidden !important} | |
| </style> | |
| <script type="text/javascript"> | |
| /* | |
| The function below requires jQuery to be on the page, using the $ namespace. | |
| Feel free to modify namespace if needed. | |
| */ |
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
| function runPythonCode(scriptCode) | |
| --local output, status, type, rc = hs.execute("PATH=/usr/local/bin:${PATH}; python -c 'import sys; sys.stdout.write(str(123))'") | |
| local output, status, type, rc = hs.execute("PATH=/usr/local/bin:${PATH}; python -c '" .. scriptCode .. "'") | |
| local response = { | |
| output = output, | |
| status = status, | |
| type = type, | |
| rc = rc | |
| } | |
| return response |
NewerOlder