Skip to content

Instantly share code, notes, and snippets.

View unixpickle's full-sized avatar

Alex Nichol unixpickle

View GitHub Profile
func CreateMesh() *model3d.Mesh {
box := model3d.NewMesh()
stepSize := 0.05
addQuad := func(p model3d.Coord3D, normalAxis int) {
ax1 := model3d.Coord3D{X: stepSize}
ax2 := model3d.Coord3D{Y: stepSize}
if normalAxis == 0 {
ax1 = model3d.Coord3D{Z: stepSize}
} else if normalAxis == 1 {
@unixpickle
unixpickle / go.mod
Last active May 8, 2020 23:33
Deformation into sphere
module gists/deformation
go 1.14
require (
github.com/unixpickle/essentials v1.1.0
github.com/unixpickle/model3d v0.2.1
github.com/unixpickle/polish v0.0.0-20200508163631-1844661b331d
)
@unixpickle
unixpickle / hi.js
Created February 12, 2020 01:38
Bilinear interp
const canvas = document.createElement('canvas');
canvas.width = 400;
canvas.height = 400;
const ctx = canvas.getContext('2d');
ctx.font = '350px serif';
ctx.textBaseline = 'middle';
ctx.textAlign = 'center';
ctx.fillText('Hi', 200, 200);
const data = ctx.getImageData(0, 0, 400, 400);
@unixpickle
unixpickle / involutes.py
Created January 7, 2020 22:50
Circle involutes
import math
def involute_point(a, t):
c = math.cos(t)
s = math.sin(t)
d = t - a
return c + d * s, s - d * c
@unixpickle
unixpickle / extract_tar.go
Created December 22, 2019 22:31
Extract ImageNet tar in-place
// Command extract_tar can be used to extract a large
// ImageNet tarbal on a system that doesn't have enough
// storage for both the tarbal and the untarred data.
//
// As it extracts the tarbal, it truncates the original
// tar file so that it takes up less and less space.
//
// Based on this earlier gist for processing ImageNet tars:
// https://gist.github.com/unixpickle/7304c78032c9f433e28a87409f4d5aca
package main
@unixpickle
unixpickle / data.py
Created November 18, 2019 21:57
3D model generator model
"""
Reading data produced by an external program.
"""
import math
import random
import numpy as np
import torch
@unixpickle
unixpickle / README.md
Created November 14, 2019 20:58
Hacking Lily's Garden

Overview

In this document, I will describe how I managed to get unlimited stars and coins in the Android game "Lily's Garden". In short, here are the steps:

  • Use the adb backup feature to extract all of the game's data
  • Extract the Android backup into a tar file
  • Modify the file which stores the number of coins and stars
  • Re-sign the coins/stars field using a reverse-engineered HMAC key
  • Convert the tar file back to an Android backup
@unixpickle
unixpickle / load_collider.go
Created November 2, 2019 20:48
3D model generator data source
package main
import (
"compress/gzip"
"fmt"
"math"
"os"
"github.com/unixpickle/model3d"
)
@unixpickle
unixpickle / maml.py
Created October 21, 2019 17:35
MAML v2
import math
import torch
import torch.nn.functional as F
def maml_grad(model, inputs, outputs, lr, batch=1, checkpoint=False):
"""
Update the model gradient using MAML.
"""
@unixpickle
unixpickle / maml.py
Created October 12, 2019 19:08
MAML in PyTorch
import torch
import torch.nn.functional as F
def maml_grad(model, inputs, outputs, lr, batch=1):
"""
Update a model's gradient using MAML.
The gradient will point in the direction that
improves the total loss across all inner-loop