Skip to content

Instantly share code, notes, and snippets.

@corajr
corajr / output_pytorch-1.12.1.md
Created September 3, 2022 04:36
Comparison between pytorch-nightly and pytorch 1.12.1 on 2022 Macbook M2 Air, 24 GB, 10-core GPU
$ conda list  | grep pytorch                                                                                                                                    ✔  00:35:30
pytorch                   1.12.1                 py3.10_0    pytorch
pytorch-lightning         1.6.5              pyhd8ed1ab_0    conda-forge
torchvision               0.13.1                py310_cpu    pytorch

$ python scripts/dream.py --full_precision
>> cuda not available, using device mps
>> Loading model from models/ldm/stable-diffusion-v1/model.ckpt
LatentDiffusion: Running in eps-prediction mode

metal-conda

A sample conda environment.yml file for tensorflow-metal.

Usage

CONDA_SUBDIR=osx-arm64 conda env create -f environment.yml
conda activate tensorflow-metal
python main.py
@corajr
corajr / compile.jl
Last active June 30, 2021 14:00
hand-corrected compiler output
function compile(code)
f = tempname()
write(f, code)
run(pipeline(`faust -lang julia $f`, stdout=pipeline(`tee ex.jl`)))
end
compile("""
import("stdfaust.lib");
process = fi.resonbp(440.0, 1000.0, 0.5);
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Usage: ./learning_time_sample.py SESSION_GAP_IN_MINUTES
Requires: pip install intervaltree
This script sums up sessions from a BigQuery export, generated using the following query:
from __future__ import absolute_import
from google.appengine.ext import ndb
from appengine import backup_model
from appengine import db_decorators
@db_decorators.written_in_transaction_model()
class ActivitySessionSubentity(ndb.Model):
activity_type = ndb.StringProperty(indexed=True)
#!/usr/bin/env python
import collections
Topic = collections.namedtuple("Topic", ["render_type"])
def mk_example(n, render_type="Topic"):
return [Topic(render_type=render_type) for _ in xrange(n)]
example = mk_example(25, "Topic") + mk_example(25, "Tutorial")
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@corajr
corajr / scrambler.hs
Last active February 15, 2017 03:12
Scrambler example
#!/usr/bin/env stack
-- stack --resolver lts-8.0 --install-ghc runghc --package hspec --package lens
import Test.Hspec
import Data.List (sort)
import Control.Lens (_init, _tail, (%~))
listScrambler :: String -> String
listScrambler = unwords . map f . words
where f (x:xs@(_:_)) = x:(sort (init xs)) ++ [last xs]
f xs = xs

Keybase proof

I hereby claim:

  • I am corajr on github.
  • I am corajr (https://keybase.io/corajr) on keybase.
  • I have a public key whose fingerprint is 7A74 15B8 979D 1B45 754E 3CDD EF47 4C72 E512 368D

To claim this, I am signing this object:

{-# LANGUAGE TemplateHaskell #-}
module Data.Integer.FibonacciStack where
import Control.Monad.State
import Control.Lens
naiveFib :: Int -> Integer
naiveFib 0 = 0
naiveFib 1 = 1
naiveFib n = naiveFib (n-1) + naiveFib (n-2)