Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@adrienbrault
adrienbrault / llama2-mac-gpu.sh
Last active April 22, 2024 08:47
Run Llama-2-13B-chat locally on your M1/M2 Mac with GPU inference. Uses 10GB RAM. UPDATE: see https://twitter.com/simonw/status/1691495807319674880?s=20
# Clone llama.cpp
git clone https://github.com/ggerganov/llama.cpp.git
cd llama.cpp
# Build it
make clean
LLAMA_METAL=1 make
# Download model
export MODEL=llama-2-13b-chat.ggmlv3.q4_0.bin
@Jonty
Jonty / deredactatron.py
Last active October 10, 2023 20:39
The Deredactatron: De-redacts PDF's redacted by drawing rectangles over the text. Needs Python3 and PyMuPDF
#!/usr/bin/env python3
# De-redacts PDF's that have been redacted by drawing PDF-native rectangles over the text
# This removes ALL rectangles so might also nuke any shape diagrams a bit
# python deredactatron.py a_redacted_doc.pdf
# Outputs: deredacted-a_redacted_doc.pdf
import sys
import re
@dhh
dhh / Gemfile
Created June 24, 2020 22:23
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers
require "sqlite3"
require 'set'
require 'byebug'
# Will be rebuilt at any time. Nice and incremental.
db = SQLite3::Database.new "index.db"
# Keep prefix indexes for "mos*" searches.
#
# TODO: It doesn't seem like SQLITE FTS5 supports synonyms well. That's ok, but
# we're going to want that. We can download this database from Princeton, write
@IanColdwater
IanColdwater / twittermute.txt
Last active April 22, 2024 17:26
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
@kule
kule / mini_rspec.rb
Created September 11, 2018 09:37
Simplified example of how rspec works
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'colorize'
end
class MatcherInterface
def initialize(some_object)
@some_object = some_object
@mhl
mhl / tips.org
Last active November 20, 2017 09:44

Turn on KeyShortcuts

Turn on checkConstraints

This is very helpful, but will produce lots of warnings that you can ignore, in particular:

  • the inception date of positions

Make sure every item items won’t just get deleted

To do this, you should make sure that the item has at least one of the following:

  • An associated Wikipedia page
@flaviocopes
flaviocopes / check-substring-ends-with.go
Last active November 15, 2021 09:34
Go: check if a string ends with a substring #golang
package main
import (
"strings"
)
func main() {
strings.HasSuffix("foobar", "bar") // true
}
@JJediny
JJediny / gist:a466eed62cee30ad45e2
Created October 5, 2015 20:42
Jekyll Liquid Cheatsheet

There are two types of markup in Liquid: Output and Tag.

  • Output markup (which may resolve to text) is surrounded by
{{ matched pairs of curly brackets (ie, braces) }}
  • Tag markup (which cannot resolve to text) is surrounded by
@max-mapper
max-mapper / readme.md
Last active May 21, 2022 11:02
ffmpeg youtube live event rtmp stream from raspberry pi with raspi camera (raspivid)
  1. compile ffmpeg for arm https://github.com/fiorix/ffmpeg-arm
  2. create youtube 'live event'. get rtmp url + session id
  3. run this:
raspivid -o - -t 0 -vf -hf -fps 30 -b 6000000 | ffmpeg -re -ar 44100 -ac 2 -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero -f h264 -i - -vcodec copy -acodec aac -ab 128k -g 50 -strict experimental -f flv rtmp://a.rtmp.youtube.com/live2/<SESSION>

you can tweak -b and -fps to your liking. the settings above work well for 1080p. by not specifying width or height we get the full 1920x1080 resolution from the raspi camera