Skip to content

Instantly share code, notes, and snippets.

View andrewstellman's full-sized avatar

Andrew Stellman andrewstellman

View GitHub Profile
@andrewstellman
andrewstellman / Analysis.md
Last active April 15, 2019 12:07
3-point shot percentage after other team makes or misses (NBA 2017-2018 season)

Analysis: 3-point shot percentage after other team makes or misses

This analysis shows how pbprdf was used to analyze NBA players' 3-point shot percentage after a player on the other team either made or missed a shot over the 2017-2018 regular season.

Overview

We're interested in finding 3-point shots that were made immediately after a 3-point shot taken by the other team. The way we do this is by running a SPARQL query that calculates each player's season 3-point shot percentage, the 3P% after a player on the other team misses, and the 3P% after a player on the other team makes. We want to calculate the percentage of 3-point shots that they make or miss when we include only shots that they took immediately after a player on the other team took a 3-pointer (within two lines on the play-by-play).

Here's the data that we're using to do this analysis. Each play has a set of triples that inc

@andrewstellman
andrewstellman / Option.cs
Last active March 20, 2022 23:01
Example of a toy Option<T> class
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace Toy_Option
{
public abstract class Option<T> : IEnumerable<T>
{
@andrewstellman
andrewstellman / README.md
Last active June 11, 2019 15:21
Quick RDF example of an ontology, data, and queries

Quick RDF example

Quick example of RDF that shows structured data. Example of triples using this ontology:

  :WallyWorld a :Company ;
    rdfs:label "Wally World Amusements" .

  :Bill a :Employee ;
 :employedBy :WallyWorld ;
@andrewstellman
andrewstellman / OSX-Convert-MOV-GIF.md
Created September 5, 2020 13:19 — forked from tskaggs/OSX-Convert-MOV-GIF.md
Creating GIFs from .MOV files in OSX using FFmpeg and ImageMagick

Convert MOV to GIF using FFmpeg and ImageMagick

I tried a few different techniques to make a GIF via command-line and the following gives me the best control of quality and size. Once you're all setup, you'll be pumping out GIFs in no time!

Preparation

Install FFmpeg

  • $ brew install ffmpeg [all your options]
    • Example: $ brew install ffmpeg --with-fdk-aac --with-ffplay --with-freetype --with-frei0r --with-libass --with-libvo-aacenc --with-libvorbis --with-libvpx --with-opencore-amr --with-openjpeg --with-opus --with-rtmpdump --with-schroedinger --with-speex --with-theora --with-tools

Install ImageMagick

@andrewstellman
andrewstellman / PoorMansLog.cs
Created November 27, 2020 14:17
PoorMansLog (taking a joke tweet way to seriously)
// https://twitter.com/AndrewStellman/status/1332042223987388420
using System;
using System.Collections.Generic;
using Microsoft.Extensions.Logging;
namespace LogTest
{
public class PoorMansLog : ILogger, IDisposable
{
Serves 4-6
3/4 lb. (350g) good-quality penne (the cooking time of my penne lists an 8-9 minute cooking time)
2 or 3 shallots, finely sliced, or half of a small yellow onion, finely diced
2-4 slices of pancetta, chopped
1 bunch asparagus
1/4 lb. (115g) Feta cheese
Zest of one lemon
4 cups (960ml) Chicken stock
Kosher salt and freshly-ground pepper
@andrewstellman
andrewstellman / gist:592f2050f80931833c4a901b79bad7dc
Created September 4, 2021 15:40
Weight randomized evergreen tweets by time since last sent in C#
using System;
using System.Linq;
namespace WeightByTime
{
record Tweet(long id, long time);
static class UnixTime
{
public static long EpochTime(this DateTime dateTime) =>
@andrewstellman
andrewstellman / gist:b66f8df263e339879f783e5569294c6c
Created February 26, 2025 16:21
Generate a console Mandelbrot in C#
int width = 80; // Default width
if (args != null && args.Length > 0)
{
if (int.TryParse(args[0], out int parsedWidth) && parsedWidth > 0)
{
width = parsedWidth;
}
}
int height = width / 2;
double xMin = -2.0;
@andrewstellman
andrewstellman / gist:758c08d082008297f30857c7481a68dd
Created February 26, 2025 19:10
Animated console Mandelbrot in C#
// Parse command line arguments for width, height, frames, and maxIterations
int width = 80; // Default width
int height = 40; // Default height
int frames = 100; // Default number of frames
int maxIterations = 100; // Default max iterations
// Check if args is not null
if (args != null)
{
// Parse width if provided
// Parse command line arguments for width, height, density, and frames
int width = args?.Length > 0 && int.TryParse(args[0], out int w) && w > 0 ? w : 70;
int height = args?.Length > 1 && int.TryParse(args[1], out int h) && h > 0 ? h : 30;
double density = args?.Length > 2 && double.TryParse(args[2], out double d) && d > 0 && d <= 1 ? d : 0.3;
int frames = args?.Length > 3 && int.TryParse(args[3], out int f) && f > 0 ? f : 500;
// Initialize the grid with random cells
bool[,] grid = new bool[height, width];
Random random = new Random();