Skip to content

Instantly share code, notes, and snippets.

View JustinBis's full-sized avatar

Justin Bisignano JustinBis

  • Anthropic
  • Denver, CO
View GitHub Profile
@JustinBis
JustinBis / gist:6473520cc2c1da3156903b13cc860163
Created September 18, 2024 23:16
Android Save File to Download Dir
/**
Saves a file to /storage/emulated/0/Download/
Surprisingly, this still works on modern Android without needing additional permissions.
`<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />` may still be required
*/
private fun saveFile(
filename: String,
fileBytes: ByteArray,
) {
val downloadsFolder = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS)!!
@JustinBis
JustinBis / FixedSizeColorPainter.kt
Created November 3, 2023 06:22
A fork of [ColorPainter] that allows specifying a fixed size. Useful placeholder for Coil's AsyncImage
/**
* A fork of [ColorPainter] that allows specifying a fixed size.
*
* This is particularly useful for drawing a placeholder for a Coil [AsyncImage] when you know the
* image's dimensions ahead of time. If you use [ColorPainter], you have to specify the size using a
* modifier, which fixes the size of the [AsyncImage]. With [FixedSizeColorPainter], you can instead
* fix the size of the incoming image and let Coil calculate the target size via [ContentScale] just
* as it will for the eventually loaded image.
*/
class FixedSizeColorPainter(
@JustinBis
JustinBis / bad.pdf.php
Last active April 20, 2016 19:40
An example of a malicious pdf file that will run php code
%PDF-1.5
<?php phpinfo(); ?>
@JustinBis
JustinBis / CS123-OpenGL-Guide.md
Last active January 16, 2019 00:50
The CS123 OpenGL Guide

The CS123 Guide to OpenGL

OpenGL, the best graphics library this side of the Mississippi (which actually means the whole world, if you’re hip to geometric topology). This guide will guide you through the guiding principles of OpenGl. That’s a lot of guide. It is organized by topic, and in each topic we order each subtopic by a plausible chronology of use. If you can’t find something, use control-F or command-F. If you still can’t find it, contact a TA and tell us what we missed.

Vertex Buffer Objects (VBOs)

Vertex Buffer Objects (VBOs) are OpenGL’s way of storing geometry data. VBOs are referenced by VBO IDs that can be generated using OpenGL. Every object that you wish to render will eventually have to have its geometry stored in a VBO, so you really should spend some time getting to know these objects well.

Create a VBO ID

@JustinBis
JustinBis / Petals Around the Rose
Created November 20, 2013 00:09
Petals Around the Rose: A quick implementation of the puzzle game in Python
##################################
# Petals Around the Rose #
# #
# The classic puzzle implemented #
# in python and obfuscated to #
# keep the formula a secret #
##################################
import random