Skip to content

Instantly share code, notes, and snippets.

@winglian
winglian / long_gpt.py
Created May 27, 2023 23:38 — forked from NaxAlpha/long_gpt.py
Training script for LongGPT; Fine-tunes GPT-2 (335M) on The Pile Dataset with a context size of 8k tokens. (requires > 16GB RAM)
import time
from contextlib import suppress
import torch
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
import torch.backends.cuda as cuda
from torch.utils.data import DataLoader, IterableDataset
@winglian
winglian / docker-npm.js
Created October 27, 2017 22:29 — forked from jokeyrhyme/docker-npm.js
execute `npm` within a Docker container, within the host's working directory
'use strict'
// ideal for use with AWS Lambda and native Node.js modules
// requires Docker: https://docs.docker.com/engine/installation/
/*
Usage:
node docker-npm.js install
node docker-npm.js rebuild
@winglian
winglian / Middleware.js
Created December 23, 2016 15:53 — forked from unbug/Middleware.js
Powerful Javascript Middleware Pattern Implementation, apply middleweare to any object.
'use strict';
/* eslint-disable consistent-this */
let applyMiddlewareHash = [];
/**
* Composes single-argument functions from right to left. The rightmost
* function can take multiple arguments as it provides the signature for
* the resulting composite function.
*
@winglian
winglian / gen.swift
Created November 11, 2016 16:45 — forked from blainerothrock/gen.swift
A Very Simple Genetic Algorithm Written in Swift 3
#!/usr/bin/env xcrun swift
/*
gen.swift is a direct port of cfdrake's helloevolve.py from Python 2.7 to Swift 3
-------------------- https://gist.github.com/cfdrake/973505 ---------------------
gen.swift implements a genetic algorithm that starts with a base
population of randomly generated strings, iterates over a certain number of
generations while implementing 'natural selection', and prints out the most fit
string.
@winglian
winglian / bd_upgrade_es_on_semaphoreci.sh
Last active March 25, 2016 20:36 — forked from vlado/bd_upgrade_es_on_semaphoreci.sh
[BD] Upgrade Elasticsearch on SemaphoreCI
rbenv global 2.2.2
sudo service elasticsearch stop
if ! [ -e .semaphore-cache/elasticsearch-2.2.1.deb ]; then (cd .semaphore-cache; curl -OL https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/deb/elasticsearch/2.2.1/elasticsearch-2.2.1.deb); fi
echo Y | sudo dpkg -i .semaphore-cache/elasticsearch-2.2.1.deb
sudo service elasticsearch start
sleep 5 && curl -XGET 'localhost:9200'