Skip to content

Instantly share code, notes, and snippets.

View m1guelpf's full-sized avatar

Miguel Piedrafita m1guelpf

View GitHub Profile
@hanxiao
hanxiao / testRegex.js
Last active September 21, 2024 17:50
Regex for chunking by using all semantic cues
// Updated: Aug. 20, 2024
// Run: node testRegex.js whatever.txt
// Live demo: https://jina.ai/tokenizer
// LICENSE: Apache-2.0 (https://www.apache.org/licenses/LICENSE-2.0)
// COPYRIGHT: Jina AI
const fs = require('fs');
const util = require('util');
// Define variables for magic numbers
const MAX_HEADING_LENGTH = 7;
@xlr8harder
xlr8harder / sydney.py
Created August 2, 2024 18:49
Talk to Sydney with Llama 3.1 405B base model.
import gradio as gr
from openai import OpenAI
import jinja2
from transformers import AutoTokenizer
# get an api key from hyperbolic.
api_key = "..."
# Initialize the OpenAI client
client = OpenAI(
@drewolbrich
drewolbrich / InputNotWorkingIndicator.swift
Last active August 11, 2024 03:33
A recreation of the Mac Virtual Display "Input temporarily not working" indicator
//
// InputNotWorkingIndicator.swift
//
// Created by Drew Olbrich on 6/26/24.
// Copyright © 2024 Lunar Skydiving LLC. All rights reserved.
//
// MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
import SwiftUI
// Remember to download FontSettings.swift
struct WWDC24AnimatedTextView: View {
var text = "Hello, World!"
var animation: Animation = .easeInOut
var targetFontSize: CGFloat = 40
var minimumFontSize: CGFloat = 30
var targetFontWeight: Font.Weight = .semibold
@davidsteppenbeck
davidsteppenbeck / AnimatingMeshView.swift
Created June 11, 2024 16:41
Animating mesh gradient for iOS 18 using TimelineView
import SwiftUI
struct AnimatingMeshView: View {
let referenceDate: Date
var body: some View {
TimelineView(.animation) { context in
let t = context.date.timeIntervalSince(referenceDate)
MeshGradient(width: 5, height: 4, points: [
@JamesSedlacek
JamesSedlacek / KeyboardToolbar.swift
Last active September 10, 2024 14:07
SwiftUI Keyboard Toolbar Workaround
//
// KeyboardToolbar.swift
//
// Created by James Sedlacek on 9/20/23.
//
import SwiftUI
import Combine
@Observable
@ald3ns
ald3ns / lockbit_str_decrypt.py
Created April 16, 2023 17:48
Binary Ninja script to decrypt strings from ARM macOS Lockbit sample!
# SHA256: 3e4bbd21756ae30c24ff7d6942656be024139f8180b7bddd4e5c62a9dfbd8c79
# Get the strings from the data section
data_section = bv.get_section_by_name("__data")
symbols = bv.get_symbols(data_section.start, (data_section.end-data_section.start))
xor_val = 0
xor=Transform['XOR']
# Find the _xor_val
@VictorTaelin
VictorTaelin / gpt4_abbreviations.md
Last active September 20, 2024 00:13
Notes on the GPT-4 abbreviations tweet

Notes on this tweet.

  • The screenshots were taken on different sessions.

  • The entire sessions are included on the screenshots.

  • I lost the original prompts, so I had to reconstruct them, and still managed to reproduce.

  • The "compressed" version is actually longer! Emojis and abbreviations use more tokens than common words.

@shawwn
shawwn / adam.py
Last active February 15, 2023 19:48
Reformulating Adam optimizer to gain an intuition about what it's doing.
def lerp(a, b, t):
return (b - a) * t + a
def bias(i, x, beta):
return 1 - jnp.asarray(beta, x.dtype) ** (i + 1)
@optimizer
def adam(step_size, b1=0.9, b2=0.999, eps=1e-8) -> OptimizerResult:
"""Construct optimizer triple for Adam.
# Script for converting a HF Diffusers saved pipeline to a Stable Diffusion checkpoint.
# *Only* converts the UNet, VAE, and Text Encoder.
# Does not convert optimizer state or any other thing.
# Written by jachiam
import argparse
import os.path as osp
import torch