Skip to content

Instantly share code, notes, and snippets.

View humanismusic's full-sized avatar
💭
Building

Humanismusic humanismusic

💭
Building
View GitHub Profile
# This is a work in progress. There are still bugs. Once it is production-ready this will become a full repo.
import os
def count_tokens(text, model_name="gpt-3.5-turbo", debug=False):
"""
Count the number of tokens in a given text string without using the OpenAI API.
This function tries three methods in the following order:
1. tiktoken (preferred): Accurate token counting similar to the OpenAI API.
2. nltk: Token counting using the Natural Language Toolkit library.
@rain-1
rain-1 / LLM.md
Last active November 2, 2024 12:14
LLM Introduction: Learn Language Models

Purpose

Bootstrap knowledge of LLMs ASAP. With a bias/focus to GPT.

Avoid being a link dump. Try to provide only valuable well tuned information.

Prelude

Neural network links before starting with transformers.

import os
import pickle
import warnings
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
from tensorflow.keras.callbacks import EarlyStopping
from tensorflow.keras.layers import Dense
from tensorflow.keras.layers import Dropout
@IanColdwater
IanColdwater / twittermute.txt
Last active November 17, 2024 02:37
Here are some terms to mute on Twitter to clean your timeline up a bit.
Mute these words in your settings here: https://twitter.com/settings/muted_keywords
ActivityTweet
generic_activity_highlights
generic_activity_momentsbreaking
RankedOrganicTweet
suggest_activity
suggest_activity_feed
suggest_activity_highlights
suggest_activity_tweet
@nileshtrivedi
nileshtrivedi / composable_web.md
Last active January 10, 2022 04:31
My thoughts on making the Web more composable like UNIX

The Composable Web Proposal

Serverless infrastructure like AWS Lambda and Google Cloud Functions have made it much cheaper for developers to offer server-side code for public consumption without keeping a server always running.

If these functions could be declared as stateless or deterministic, costs can be brought down even more because only the first invocation needs to be executed. Cached response could be returned for future invocations with the same input arguments.

All modern browsers support URL lengths of thousands of characters, even on mobile. A lot of data can be embedded and passed around directly in the URLs (instead of passing identifiers which requires a look-up which costs server time).

So here's a thought:

@mikowl
mikowl / oneliners.js
Last active June 29, 2024 17:39
👑 Awesome one-liners you might find useful while coding.
// Inspired by https://twitter.com/coderitual/status/1112297299307384833 and https://tapajyoti-bose.medium.com/7-killer-one-liners-in-javascript-33db6798f5bf
// Remove any duplicates from an array of primitives.
const unique = [...new Set(arr)]
// Sleep in async functions. Use: await sleep(2000).
const sleep = (ms) => (new Promise(resolve => setTimeout(resolve, ms)));
// or
const sleep = util.promisify(setTimeout);
@treypeng
treypeng / main.js
Last active March 18, 2019 07:53
Script to detect darth maul candles from bitmex 1h interval data
require('./util');
const Candler = require('./candle-db');
const ATR_LENGTH = 24;
const SMA_LENGTH = 24;
let trs = []; // series. needed by atr() function.
@QuantBits
QuantBits / script.js
Created February 8, 2019 17:55
BitMex USD Converter - For TemperMonkey
// ==UserScript==
// @name BitMex USD Converter
// @namespace https://bitmex.com/
// @version 0.11
// @description Get some sanity into your gambling.
// @author koinkraft
// @grant none
// @include https://bitmex.com/*
// @include https://www.bitmex.com/*
// @require https://code.jquery.com/jquery-2.1.4.min.js
@drewm
drewm / shoot-sharing-image.js
Last active April 30, 2021 06:24
Dynamic Social Sharing Images
const puppeteer = require('puppeteer');
const imagemin = require('imagemin');
const imageminPngquant = require('imagemin-pngquant');
// Get the URL and the slug segment from it
const url = process.argv[2];
const segments = url.split('/');
const slug = segments[segments.length-2];
(async () => {
@JackGJenkins
JackGJenkins / show_intercom_launcher_after_scroll_or_action.js
Last active August 22, 2019 16:51
Simple jQuery snippet to show the Intercom messenger launcher when your user scrolls to the bottom of the page, or clicks a button.
//SHOW THE LAUNCHER WHEN A USER SCROLLS TO THE BOTTOM OF YOUR PAGE
//You'll need to have 'hide_default_launcher: true' defined in your intercomSettings object when the page loads initially.
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() == $(document).height()) {
Intercom('update', {"hide_default_launcher": false});
}
});
//SHOW THE LAUNCHER AFTER A USER CLICKS A BUTTON