Skip to content

Instantly share code, notes, and snippets.

@mlabonne
mlabonne / finetune_llama2.py
Last active January 22, 2025 15:02
Easy Llama 2 fine-tuning script (📝 Article: https://tinyurl.com/finetunellama2)
# Based on younesbelkada/finetune_llama_v2.py
# Install the following libraries:
# pip install accelerate==0.21.0 peft==0.4.0 bitsandbytes==0.40.2 transformers==4.31.0 trl==0.4.7 scipy
from dataclasses import dataclass, field
from typing import Optional
import torch
from datasets import load_dataset
from transformers import (
@gerhardberger
gerhardberger / .hyperterm.js
Created July 15, 2016 19:48
tomorrow night eighties colors for hyperterm
module.exports = {
config: {
// default font size in pixels for all tabs
fontSize: 13,
// font family with optional fallbacks
fontFamily: '"Droid Sans Mono", Menlo, monospace',
// terminal cursor background color (hex)
cursorColor: '#cccccc',
@kitten
kitten / Store.js
Created May 18, 2015 22:51
A generic Store class, that utilises Immutable.js
import { EventEmitter } from "events";
import { Map } from "immutable";
const CHANGE_EVENT = "change";
class Store extends EventEmitter {
constructor() {
super();
this.data = new Map();
}
@vsouza
vsouza / .bashrc
Last active March 7, 2025 09:42
Golang setup in Mac OSX with HomeBrew. Set `GOPATH` and `GOROOT` variables in zshell, fish or bash.
# Set variables in .bashrc file
# don't forget to change your path correctly!
export GOPATH=$HOME/golang
export GOROOT=/usr/local/opt/go/libexec
export PATH=$PATH:$GOPATH/bin
export PATH=$PATH:$GOROOT/bin
@polonskiy
polonskiy / PHProutines.php
Created December 4, 2014 09:32
PHProutines
<?php
class Runner {
public function __construct() {
pcntl_signal(SIGCHLD, SIG_IGN);
}
public function go() {
if (pcntl_fork()) return;
@gondo
gondo / KnpPaginatorQuerySubscriber
Last active August 29, 2015 14:07
fixing random pagination results in knp_paginator and mysql
<?php
namespace General\GeneralBundle\EventListener;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Knp\Component\Pager\Event\ItemsEvent;
use Doctrine\ORM\Query;
use Doctrine\ORM\QueryBuilder;
class KnpPaginatorQuerySubscriber implements EventSubscriberInterface
@jdx
jdx / boot.js
Last active August 11, 2024 13:00
zero-downtime node.js app runner
// This script will boot app.js with the number of workers
// specified in WORKER_COUNT.
//
// The master will respond to SIGHUP, which will trigger
// restarting all the workers and reloading the app.
var cluster = require('cluster');
var workerCount = process.env.WORKER_COUNT || 2;
// Defines what each worker needs to run
@gordonbrander
gordonbrander / min-event-behavior.js
Last active August 21, 2018 11:57
Minimal FRP events and behaviors
// Minimal FRP Behaviors and Events.
// An event function is any function of shape `function (next) { ... }` where
// `next(value)` is a callback to be called by event function. Transformations
// of event are accomplished by wrapping event with another event function,
// and consuming original event within (CPS).
// A behavior is any function of shape `function (time) { ... }`, where
// `time` is current time. Behaviors may capture state, return value from time,
// or be constant. Behaviors must always return a value, but value may
@egonSchiele
egonSchiele / dining_with_waiter.rb
Created May 16, 2013 18:20
Dining philosophers using locks in Ruby. This implements a Waiter who is in charge of forks.
require 'thread'
class Waiter
def initialize
@mutex = Mutex.new
end
def can_eat? philosopher
left = philosopher.left_fork
right = philosopher.right_fork
@d11wtq
d11wtq / calc.erl
Last active December 15, 2015 07:08
Reverse Polish Notation Calculator in Erlang
%% @doc Reverse Polish Notation Calculator.
%%
%% Parses expressions like "1 2 3 + -" = -4
%%
%% This is an exercise in Learn You some Erlang for Great Good,
%% however I didn't read the text and just implemented it.
%%
%% I guess understanding stack-based parsing helps here.
-module(calc).
-export([rpn/1]).