Skip to content

Instantly share code, notes, and snippets.

View zbowling's full-sized avatar
🌐
Working from everywhere

Zac Bowling zbowling

🌐
Working from everywhere
View GitHub Profile
import requests
from bs4 import BeautifulSoup
import xml.etree.ElementTree as ET
import ollama
def fetch_rss_feed(url):
response = requests.get(url)
response.raise_for_status()
return response.content
from collections import List, Dict
from utils.variant import Variant
@value
struct JsonNode(CollectionElement, Stringable):
var value: Pointer[Variant[NoneType, Bool, Float64, String, List[Self], Dict[String, Self]]]
fn __init__(inout self: Self, value: Variant[NoneType, Bool, Float64, String, List[Self], Dict[String, Self]]):
self.value = Pointer[Variant[NoneType, Bool, Float64, String, List[Self], Dict[String, Self]]].alloc(1)
self.value[0] = value
@zbowling
zbowling / conway.mojo
Last active November 23, 2023 18:51
conway.mojo
from python import Python
from random import randint
from memory import memset_zero, memcpy
from time import sleep
let show_change = True
struct Grid:
var data: DTypePointer[DType.uint8]
var rows: Int
//
// HCLevelModel.h
// HamsterCrunch
//
// Created by Zac Bowling on 2/25/12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>

Improve Libc Portability

During the review process, add the following fields as needed:

@zbowling
zbowling / 0001-android-Add-locale-support.patch
Created September 29, 2014 18:02
libc++ patches from google
From 4cc54e7dcd19f78a3ebaaa3c6f05885029c53b01 Mon Sep 17 00:00:00 2001
From: David 'Digit' Turner <[email protected]>
Date: Wed, 12 Feb 2014 20:04:18 +0800
Subject: [PATCH 01/12] android: Add locale support.
This is based on the Bionic <ctype.h> declarations. Note that
unfortunately, the _ctype_ table exposed by this header has a bug
so a fixed copy is included here instead.
See src/support/android/locale_android.cpp for details.
@zbowling
zbowling / gist:3318310
Created August 10, 2012 21:47
Mountain Lion "locate" fix.

One of my favorite commands on most unix systems is the locate command which ships with the system. After upgrading Apple seems to have completely broken it.

It appears the built /usr/libexec/update.localdb script looks for a nobody user on Mountain Lion (this is the same version of this script since Snow Leopard). This user seems to be missing after an in-place Mountian Lion upgrade but may be missing in regular installs as well. Apple didn't seem to check to see if the locate script (Apple use's the version from FreeBSD) still worked after changing the default users in the local ldap on your machine. The locate.update script needs the user id for "nobody" to mark as the owner of the database files it creates.

Instead of modifying this script I found it easier to bring back the nobody user. This also fixes mysql upgrades from lion as well.

(nobody user on Lion was user 13)

sudo dscl . -create /Users/nobody
// HACK: Create an offscreen text view solely for calculating the height of table view cells
// containing text views. This bizarre hack is needed because:
//
// a.) UITextView is bizarre and uses WebKit instead of UIKit's methods for displaying strings,
// and NSString's sizeWithFont:constrainedToSize: does not calculate the height exactly as
// it does. (For instance, the height of strings with trailing whitespace are calculated
// differently, and UITextView some strange built-in padding and slightly
// different-than-usual line height that is annoyingly difficult to replicate, etc...,
// etc...).
//
@zbowling
zbowling / gist:2565244
Created May 1, 2012 05:05
nasty NSDateFormatter parsing bug.
static NSLocale *enUSLocale = nil;
static NSDateFormatter *timestampFormatter = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
enUSLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
timestampFormatter = [[NSDateFormatter alloc] init];
[timestampFormatter setLocale:enUSLocale];
[timestampFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss.S"];
@zbowling
zbowling / gist:2356293
Created April 11, 2012 01:48
WWDC dates
Year Days Announcement Day Start of WWDC Venue
2012 ?? ????????? ??? 11-Jun-12??? Moscone West
2011 70 28-Mar-11 Mon 06-Jun-11 Moscone West
2010 40 28-Apr-10 Wed 07-Jun-10 Moscone West
2009 74 26-Mar-09 Thu 08-Jun-09 Moscone West
2008 88 13-Mar-08 Thu 09-Jun-08 Moscone West
2007 126 05-Feb-07 Mon 11-Jun-07 Moscone West
2006 153 07-Mar-06 Tue 07-Aug-06 Moscone West
2005 111 15-Feb-05 Tue 06-Jun-05 Moscone West
2004 123 26-Feb-04 Thu 28-Jun-04 Moscone West