Skip to content

Instantly share code, notes, and snippets.

@adrienbrault
adrienbrault / llama2-mac-gpu.sh
Last active April 8, 2025 13:49
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
@0age
0age / c000r.sol
Last active June 10, 2024 18:32
0xMonaco car (top-ranked finisher by ELO, Paradigm CTF 2022) https://0xmonaco.ctf.paradigm.xyz/viewTeam/OpenSea
// SPDX-License-Identifier: MIT
pragma solidity 0.8.16; // (10M optimization runs)
interface MonacoInterface {
struct CarData {
uint32 balance; // Where 0 means the car has no money.
uint32 speed; // Where 0 means the car isn't moving.
uint32 y; // Where 0 means the car hasn't moved.
Car car;
}
@clemensgg
clemensgg / gist:81307bded1b99d166c484049d0f5246c
Last active February 26, 2022 21:54
configure hermes relayer to use feegrant module for omniflix
# omniflix team are granting relayer accounts to pay fees from a specified 'granter' account
# fill out the relayer-coordination-sheet provided by the team to get your relayer account whitelisted (granted)
# works with hermes v0.11.0 and higher (https://github.com/informalsystems/ibc-rs)
# config.toml (set granter account, set your endpoints, comment out channels you don't relay)
[[chains]]
id = 'omniflixhub-1'
rpc_addr = 'http://...'
grpc_addr = 'http://...'
@rigelrozanski
rigelrozanski / imgcat.go
Created April 30, 2020 03:55
Iterm2 imgcat image output from golang
import (
"encoding/base64"
"fmt"
"io/ioutil"
"os"
)
func main() {
r, err := os.Open("yourimagehere.png")
if err != nil {
@aaronc
aaronc / key-management.md
Last active October 31, 2022 23:09
Key groups, msg and fee delegation from the Gaians team at Hackatom Berlin 2019

Fee delegation

The delegation module also allows for fee delegation via some changes to the AnteHandler and StdTx. The behavior is similar to that described above for Msg delegations except using the interface FeeAllowance instead of Capability:

// FeeAllowance defines a permission for one account to use another account's balance
// to pay fees
@anacampesan
anacampesan / gifFrameDisposal.js
Last active April 24, 2023 12:02
GIF Frame Disposal Correction Algorithm
function explodeGif(gifUrl) {
return gifler(gifUrl)._animatorPromise.then(function(gif) {
let current = createTempCanvas(gif.width, gif.height, 'current');
let currentCtx = current.getContext('2d');
let temp = createTempCanvas(gif.width, gif.height, 'temp');
let tempCtx = temp.getContext('2d');
gif._animationLength = 0;
for (let i = 0; i < gif._frames.length; i++) {
@spyesx
spyesx / rsync_backup.sh
Last active April 18, 2025 09:50
Rsync backup excluding node_modules
# Backup files
#https://explainshell.com/explain?cmd=rsync+-azuv+--delete+--progress+--exclude+%27node_modules%27
rsync -auvhp --delete --exclude=node_modules [source] [destination]
# Remove all node_modules folders
# https://explainshell.com/explain?cmd=find+.+-name+%22node_modules%22+-type+d+-prune+-exec+rm+-rf+%27%7B%7D%27+%2B
find . -name "node_modules" -type d -prune -exec rm -rf '{}' +
@GNSPS
GNSPS / ProxyFactory.sol
Last active December 11, 2024 21:58
Improved `delegatecall` proxy contract factory (Solidity) [v0.0.5]
/***
* Shoutouts:
*
* Bytecode origin https://www.reddit.com/r/ethereum/comments/6ic49q/any_assembly_programmers_willing_to_write_a/dj5ceuw/
* Modified version of Vitalik's https://www.reddit.com/r/ethereum/comments/6c1jui/delegatecall_forwarders_how_to_save_5098_on/
* Credits to Jorge Izquierdo (@izqui) for coming up with this design here: https://gist.github.com/izqui/7f904443e6d19c1ab52ec7f5ad46b3a8
* Credits to Stefan George (@Georgi87) for inspiration for many of the improvements from Gnosis Safe: https://github.com/gnosis/gnosis-safe-contracts
*
* This version has many improvements over the original @izqui's library like using REVERT instead of THROWing on failed calls.
* It also implements the awesome design pattern for initializing code as seen in Gnosis Safe Factory: https://github.com/gnosis/gnosis-safe-contracts/blob/master/contracts/ProxyFactory.sol
@codediodeio
codediodeio / database.rules.json
Last active January 10, 2025 22:28
Common Database Rules for Firebase
// No Security
{
"rules": {
".read": true,
".write": true
}
}
@naterush
naterush / AcceptMyTx.sol
Created June 4, 2017 18:54
This contract allows users to keep their gas price very low while still effectively paying miners. This would allow users to circumnavigate any imposed gas price maximums.
pragma solidity ^0.4.10;
contract AcceptMyTx {
function forwardTransaction(address destination, bytes data, uint amountToMiner) payable {
block.coinbase.transfer(amountToMiner);
destination.call.value(msg.value - amountToMiner)(data); //even in case of failure, miner is paid
}
}