Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@spmurrayzzz
spmurrayzzz / finetune_sft_trl.py
Created September 12, 2023 20:53 — forked from younesbelkada/finetune_sft_trl.py
Benchmarking SFT trainer with 8bit models
# coding=utf-8
# Copyright 2023 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@spmurrayzzz
spmurrayzzz / immutable-proxy-example.js
Last active October 22, 2016 01:15
Immutable object factory, using proxies
const immutable = require('./immutable');
let obj;
obj = immutable({ foo: 'bar' });
obj.foo = 'baz'; // assignment fails silently
delete obj.foo; // delete fails silently
obj = immutable({ foo: [ 1, 2, 3 ] });
obj.foo.push( 4 ); // mutation fails silently
@spmurrayzzz
spmurrayzzz / score.js
Created August 16, 2015 22:57
js13kgames closure fun
(function() {
var score = 0;
Object.defineProperty( this, 'score', {
get: function(){
return score;
},
set: function( val ) {
score = val;
this.elem.innerHTML = _.template(
tmplStr, { score: score }
// Sourced from https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Storage
//
// Note: The maximum size of data that can be saved is severely restricted by the use of cookies.
// With this algorithm, use the functions localStorage.setItem() and localStorage.removeItem() to add,
// change, or remove a key. The use of methods localStorage.yourKey = yourValue; and delete localStorage.yourKey;
// to set or delete a key is not a secure way with this code. You can also change its name and use it only to
// manage a document's cookies regardless of the localStorage object.
if (!window.localStorage) {
Object.defineProperty(window, "localStorage", new (function () {
@spmurrayzzz
spmurrayzzz / Vagrantfile
Last active December 31, 2015 06:39
High-performing Vagrant settings
# Note: If you're serving files via shared folders, for christs sake use NFS
# but that does require private networking.
#
# The DNS settings were the ones that made the most difference, so if you're resource
# constrained, the last two settings were the ones that helped the most.
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "1024"]
vb.customize ["modifyvm", :id, "--cpuexecutioncap", "90"]
vb.customize ["modifyvm", :id, "--cpus", 2]
@spmurrayzzz
spmurrayzzz / d_day.js
Created July 10, 2013 09:58
fucking birthday
var me = new Person();
var d_day = setInterval(function(){
if (me.age == 30) {
console.log('fuck my life');
shuffle_off(me.mortal_coil);
clearTimeout(d_day);
}
}, 86400e1);
@spmurrayzzz
spmurrayzzz / archive.py
Last active December 17, 2015 00:10
Semi-intelligently archive the contents of Mac OS X Desktop
#!/usr/bin/env python
'''
archive.py
Quick and dirty script that moves desktop clutter to a date-sorted archive
location. Nothing elegant here, just keeps desktop workspace much less
cluttered. Intended to be run as a cron job at a sane frequency.
Usage is ideal if your desktop is merely a swap space, not so ideal if your
@spmurrayzzz
spmurrayzzz / get-donors.py
Created April 18, 2013 18:24
Scrape donors from HTML
#!/usr/bin/env python
from subprocess import call
from bs4 import BeautifulSoup
import json
import os
def get_html():
if os.path.isfile('richard-family-fund'):
@spmurrayzzz
spmurrayzzz / euler-25.py
Created March 24, 2013 00:17
Project Euler #25
def fib():
first = 0
second = 1
while True:
cached = first
first = first + second
second = cached
yield first
@spmurrayzzz
spmurrayzzz / django-user-extend.py
Created February 20, 2013 23:21
Extending Django User model
from django.db import models
from django.contrib.auth.models import User
from django.db.models.signals import post_save
# ------------- USERS -------------
class UserProfile(models.Model):
user = models.OneToOneField(User)
def __unicode__(self):