Skip to content

Instantly share code, notes, and snippets.

View DylanLukes's full-sized avatar

Dylan Lukes DylanLukes

  • University of California San Diego
  • San Diego, CA
View GitHub Profile
@DylanLukes
DylanLukes / build.zig
Created December 31, 2023 04:27
Minimal build.zig for building bgfx, and using it in a Zig project.
const std = @import("std");
pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const is_debug = optimize == .Debug;
// BGFX
// ----
@DylanLukes
DylanLukes / cosmo.plugin.zsh
Last active November 5, 2023 19:54
Cosmo ZSH Plugin
cosmo() {
declare cosmo_path=${COSMO_PATH:-/opt/cosmos/bin:/opt/cosmo/bin}
declare ape_bin
# If no arguments were provided, abort.
if [[ $# -eq 0 ]]; then
echo "usage: cosmo <command> [<args>]"
return 1
fi
@DylanLukes
DylanLukes / css-filter-generator-to-convert-from-black-to-target-hex-color.markdown
Created October 24, 2023 01:38
CSS filter generator to convert from black to target hex color

CSS filter generator to convert from black to target hex color

Added License 2022-07-15; this is retroactive for whatever help that is.

0-clause Free BSD License

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.[20]

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@DylanLukes
DylanLukes / BGFX Embedded Shaders in C99.md
Last active April 26, 2023 23:50
Small extension to BGFX for embedded shader loading when using (pure) C99.

Usage:

// Include the headers generated by shaderc.
// I am using CMake to automate compilation, loosely based on:
//     https://github.com/Paper-Cranes-Ltd/big2-stack
#include <generated/shaders/demo/all.h>

#include "util/bgfx/c99_embedded_shader.h"
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RecursiveDo #-}
module WAM.L0.Token where
import Control.Applicative
import Control.Applicative.Combinators
import Control.Monad
import Data.Char
import Text.Earley
--
-- Is there a more efficient/elegant way to do this?
--
-- Objective: To disable/enable the mouse cursor for specific windows
--
checkMouseDisable :: X ()
checkMouseDisable = do
import Data.List.Split
nFiniteChunks :: Int -> [a] -> [[a]]
nFiniteChunks n xs = splitPlaces places xs
where len = length xs
hi = len `div` n + 1
lo = len `div` n
nHi = len - lo * n
nLo = hi * n - len
places = (replicate nHi hi) ++ (replicate nLo lo)
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeInType #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE UnicodeSyntax #-}
//
// NilCollapse.swift
//
// Created by Dylan Lukes on 7/19/18.
//
// No Rights Reserved.
extension Collection {
subscript (safe index: Index) -> Element? {
return indices.contains(index) ? self[index] : nil