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
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 / 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
//
// SMOperationQueueOperation.m
// DorsiaFoundation
//
// Created by Zac Bowling on 4/4/12.
// Copyright (c) 2012 SeatMe, Inc. All rights reserved.
//
#import "SMOperationQueueOperation.h"
@zbowling
zbowling / Adblock opitons.md
Created January 18, 2012 05:57
Un-blackout Wikipedia methods

#Un-blackout Wikipedia methods.

I'm totally with Wikipedia and support them blacking out the site. These methods work for the technical people out there that still/want access. I hope you use these methods only after contacting congress to help fight SOPA and PIPA.

##AdBlock and NoScript method

Add this option to your AdBlock or NoScript settings. In Google Chrome, you can add a javascript exception in your preferences for this URL as well.

|http://meta.wikimedia.org/w/index.php?title=Special:BannerLoader&banner=blackout&campaign=English+Wikipedia+Blackout*