Skip to content

Instantly share code, notes, and snippets.

View louismullie's full-sized avatar

L louismullie

View GitHub Profile
@jimsrc
jimsrc / gpt4_text_compression.md
Last active February 21, 2024 22:16
Minimizing the number of tokens usage to interact with GPT-4.

Overview

I just read this trick for text compression, in order to save tokens in subbsequent interactions during a long conversation, or in a subsequent long text to summarize.

SHORT VERSION:

It's useful to give a mapping between common words (or phrases) in a given long text that one intends to pass later. Then pass that long text to gpt-4 but encoded with such mapping. The idea is that the encoded version contains less tokens than the original text. There are several algorithms to identify frequent words or phrases inside a given text, such as NER, TF-IDF, part-of-speech (POS) tagging, etc.

@christophemarois
christophemarois / push-remote.sh
Last active March 1, 2020 09:31
Push to a remote non-bare git directory
# on the remote
mkdir my-repo
cd my-repo
git init
git config receive.denyCurrentBranch updateInstead
# on the local
git remote add [remote-name] ssh://[ssh profile name]/[path to repo on the remote]
@kujohn
kujohn / portforwarding.md
Last active April 27, 2024 20:16
Port forwarding in Mavericks

Port Forwarding in Mavericks


Since Mavericks stopped using the deprecated ipfw (as of Mountain Lion), we'll be using pf to allow port forwarding.

####1. anchor file Create an anchor file under /etc/pf.anchors/<anchor file> with your redirection rule like:

@jiahao
jiahao / Hypergeometric.jl
Created October 18, 2013 21:13
Hypergeometric random variate generators implemented in Julia
# Hypergeometric random variate generators
#
# (c) 2013 Jiahao Chen <jiahao@mit.edu>
#
# This file implements several random variate generators as described in the
# reference paper.
#
# Algorithm Function
# HBU randhg_hbu
# HIN randhg_hin
@shovon
shovon / README.md
Last active April 18, 2019 08:37
An install script for LLVM and Clang v3.2.

Installing LLVM and Clang v3.2 on OS X

I'm assuming you need this version for Emscripten.

Don't worry, this script will not override your current installation of LLVM and Clang.

Be sure that you have:

  • read this README file
  • read this README file
@tarcieri
tarcieri / ecb_test.rb
Last active June 30, 2021 14:54
Either ECB mode is broken in Ruby OpenSSL or I'm retarded...
#!/usr/bin/env ruby
require 'openssl'
# AES-128 ECB mode test vectors
# Taken from: http://www.inconteam.com/software-development/41-encryption/55-aes-test-vectors#aes-ecb-128
KEY = ["2b7e151628aed2a6abf7158809cf4f3c"].pack("H*")
PLAINTEXT = ["6bc1bee22e409f96e93d7e117393172a"].pack("H*")
CIPHERTEXT = ["3ad77bb40d7a3660a89ecaf32466ef97"].pack("H*")
@superwills
superwills / OpenSSL RSA encryption sample
Last active November 2, 2022 09:45
Base64 encoding and RSA encryption sample
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <openssl/rsa.h>
#include <openssl/engine.h>
#include <openssl/pem.h>
// I'm not using BIO for base64 encoding/decoding. It is difficult to use.
// Using superwills' Nibble And A Half instead
@dannvix
dannvix / intercept-https-with-python-mitmproxy.md
Last active February 16, 2023 02:43
Intercept and manipulate HTTPs traffic with Python and mitmproxy

Intercepts HTTPs Traffic with Python & mitmproxy

Warning

This Gist is created in 2014, and it's highliy outdated now, according to one of mitmproxy's manjor contributor (check his comment below). Thanks for letting us know, @mhils!

Introduction

Modern applications usually make use of back-end API servers to provide their services. With a non-transparent HTTPs proxy, which intercepts the communication between clients and servers (aka the man-in-the-middle scheme), you can easily manipulate both API requests and responses.

@HarryR
HarryR / cbcmac.py
Created February 22, 2013 22:47
Injects 2 blocks into a CBC-MAC stream with the resulting MAC being the same. Aka the 'CBC-MAC splicing attack'
#!/usr/bin/env python
from Crypto.Cipher import AES
from Crypto.Util.strxor import strxor
from binascii import hexlify
K = '0123456789abcdef'
cipher = AES.new(K, AES.MODE_ECB)
# Original Message
@mrichie
mrichie / gist:4043266
Created November 9, 2012 02:05 — forked from jfirebaugh/gist:4007524
Installing Ruby 2.0.0-preview1 with RVM on OS X
# First, make sure that you have the most recent rvm. Several bugs with 2.0.0-preview1
# have recently been fixed.
#
# Second, the openssl that comes with MacOS is too old for Ruby 2.0. You need to install
# a newer one with homebrew or the rvm pkg command.
# Option 1, with homebrew openssl:
brew update
brew install openssl