Skip to content

Instantly share code, notes, and snippets.

View btipling's full-sized avatar
:shipit:
shipping code

btipling

:shipit:
shipping code
  • ConductorOne
  • Bay Area, California
  • 12:43 (UTC -12:00)
View GitHub Profile
@btipling
btipling / build.zig
Last active October 30, 2023 21:30
opengl triangle with zig-gamedev
const std = @import("std");
const zsdl = @import("libs/zig-gamedev/libs/zsdl/build.zig");
const zopengl = @import("libs/zig-gamedev/libs/zopengl/build.zig");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const exe = b.addExecutable(.{
.name = "hellotriangle",
@btipling
btipling / set_slack_status.ps1
Last active June 30, 2020 20:14
Setting my slack status via powershell
param ([string] $Status)
function Invoke-SlackRequest([string]$Url, [hashtable]$data, [hashtable]$headers) {
Write-Host "Making a request to slack @ $Url"
$Body = ConvertTo-Json -InputObject $data
Write-Host "Sending body: $Body"
$headers["Content-type"] = "application/json; charset=utf-8";
$result = Invoke-RestMethod -Method 'Post' -Uri $url -Body $body -Headers $headers
if (!$result.ok) {
Write-Error "Not OK!"
@btipling
btipling / foo.json
Last active June 2, 2020 19:53
Just some JSON to parse.
{
"foo": 3,
"bar": 10
}
@btipling
btipling / host.ps1
Created June 2, 2020 07:40
A little toy key value store in PowerShell
PS C:\Users\swart\projects\powershell_scripts> .\name_value_store.ps1
PS C:\Users\swart\projects\powershell_scripts> Add-Data -Name "Foo" -Value 2
PS C:\Users\swart\projects\powershell_scripts> Add-Data -Name "Bar" -Value 8
PS C:\Users\swart\projects\powershell_scripts> Read-Data
Name Value
@btipling
btipling / check_file_exists.ps1
Created May 31, 2020 21:14
A script that prints whether a file exists or not.
param ([string] $Path)
Get-Item -Path $Path -ErrorAction SilentlyContinue -ErrorVariable test | Out-Null
if ($test.Count -eq 0) {
Write-Host "The file at $Path exists!"
}
else {
Write-Host "The file at $Path was not found."
}
@btipling
btipling / params_to_hash.ps1
Last active May 28, 2020 22:21
Demonstrates how to use params, hash tables and convert them into objects and how to use ExpandProperty
param ([string] $name, [int] $value = 0)
$table = @{ Name = $name; Value = $value }
Write-Host "Your table is:"
Write-Output $table
Write-Host "`n"
Write-Host "It has this many items in it: " $table.Count
Write-Host "`n`n"
@btipling
btipling / guess_number.ps1
Created May 27, 2020 21:00
A 1 to 10 number guessing game in PowerShell
function Write-Text([string]$text) {
Write-Host -ForegroundColor Green $text
}
function Remove-Value([int]$value, [int[]]$list) {
[int[]] $new_list = $null
foreach ($v in $list) {
if ($v -ne $value) {
$new_list += $v
@btipling
btipling / output.txt
Created August 7, 2017 01:30
Figuring out state monads!
(Just 3,[9,1])
(Nothing,[])
module Main where
import Control.Monad.Writer
main :: IO ()
main = do
putStrLn $ "do notation: " ++ (show $ runWriter multWithLog)
putStrLn $ "binding: " ++ (show $ runWriter multiWithLogBind)
putStrLn $ "let and bind: " ++ (show $ runWriter multiWithLogLet)
@btipling
btipling / Main.hs
Last active June 25, 2017 23:57
Haskell based parenthesis validator
{-|
Module: Validator
Description: Parses parenthesis variations for correct nesting.
Parses (), <>, {}, [] etc for correct nesting, open and closing.
Usage:
$ validator '[<>{()}]'
[<>{()}]