Skip to content

Instantly share code, notes, and snippets.

View justinmeiners's full-sized avatar

Justin Meiners justinmeiners

View GitHub Profile
NSOpenPanel *panel;
NSArray* fileTypes = [NSArray arrayWithObjects:@"pdf", @"PDF", nil];
panel = [NSOpenPanel openPanel];
[panel setFloatingPanel:YES];
[panel setCanChooseDirectories:NO];
[panel setCanChooseFiles:YES];
[panel setAllowsMultipleSelection:YES];
[panel setAllowedFileTypes:fileTypes];
int i = [panel runModal];
if (i == NSOKButton){
@justinmeiners
justinmeiners / unity3d_multiplypoint_3_4.md
Last active January 19, 2021 06:31
What is the difference between MultiplyPoint and MultiplyPoint3x4 in Unity3D?

What is the difference between MultiplyPoint and MultiplyPoint3x4 in Unity3D?

What steps of a matrix multiplication could Unity possibly be skipping to make an optimization? The optimization is possible because a scaling and rotation needs only a 3x3 matrix and another vector for the translation, so part of the full 4x4 matrix is unused and can be ignored.

Here is the source code taken from the decompilation [here][1]:

public Vector3 MultiplyPoint(Vector3 v)

{

@justinmeiners
justinmeiners / http_request_parameters_node.js
Last active January 22, 2020 03:21
How to make a node.js HTTP GET request with query parameters.
/*
https://nodejs.org/api/url.html#url_url_format_urlobject
Use the module to build a URL with query parameters:
*/
const requestUrl = url.parse(url.format({
protocol: 'https',
hostname: 'yoursite.com',
pathname: '/the/path',
query: {
@justinmeiners
justinmeiners / vector.h
Last active January 20, 2020 07:03
generic vector template in ANSI C
/*
https://gist.github.com/pervognsen/c56d4ddce94fbef3c80e228b39efc028
https://gist.github.com/pervognsen/6f295f356010186f3c350f31fbeec28b
*/
/*
EXAMPLE
@justinmeiners
justinmeiners / python3_caching_proxy.py
Last active February 9, 2023 17:17
A simple caching HTTP proxy in Python 3.
# A simple HTTP proxy which does caching of requests.
# Inspired by: https://gist.github.com/bxt/5195500
# but updated for Python 3 and some additional sanity improvements:
# - shutil is used to serve files in a streaming manner, so the entire data is not loaded into memory.
# - the http request is written to a temp file and renamed on success
# - forward headers
import http.server
import socketserver
import urllib.request

Peter Thiel on Markets, Technology, and Education

YouTube

Uncommon Knowledge. The Hoover Institution

Published: October 23, 2014

Participants

The Problem

Let's suppose you are writing an autocomplete/search feature in which an input field sends requests to the server to get suggestions. The tricky part here is accounting for latency, so I'm going to model this as a timeline of events. This a choice of mathematical structure that I will use to represent the problem. You can visualize it by thinking of points on a number line.

Components

/*
After making my ASM rogue, I thought it might be fun to make a C one.
Termbox looks awesome.
gcc rogue.c -I /usr/local/include -L /usr/local/lib -l termbox -o rogue
*/
#include <stdio.h>
#include <stdlib.h>
/* Created By: Justin Meiners (2012)
This is the only worthwhile piece a project I wrote in 2012. I got interested in emulation after watching
[Bisqwit's video](https://www.youtube.com/watch?v=y71lli8MS8s)
It was interesting to learn about how the cartridge data is organized
and how the graphics are stored.
I didn't get very far into the actual emulation, as the CPU has tons of instructions
with slightly different variations and I didn't understand computer architecture at the time.
// https://gist.github.com/pervognsen/c56d4ddce94fbef3c80e228b39efc028
// https://gist.github.com/pervognsen/fb31981701b534e495a8baa2a6c3ae86
// https://gist.github.com/pervognsen/d4dc1dc159f93a0ad5b6
// https://gist.github.com/vurtun/2e32089f0f012aab2b4c6385f145b5bd
// http://blog.pkh.me/p/20-templating-in-c.html
#ifndef LISTPOOL_VAL
#error "LISTPOOL_VAL must be #defined to a type."
#endif