Skip to content

Instantly share code, notes, and snippets.

@g-cassie
g-cassie / main.zig
Last active March 7, 2023 15:17
Computer Enhance Part 1 - Lesson 2 in Zig
const std = @import("std");
const Ops = enum { mov, imm, imm_mem, mem_acc, acc_mem };
const Mod = enum { reg, mem0, mem8, mem16 };
pub fn parseMod(byte: u8) Mod {
return switch (byte & 0b11_000_000) {
0b11_000000 => Mod.reg,
0b01_000000 => Mod.mem8,
0b10_000000 => Mod.mem16,
0b00_000000 => Mod.mem0,
@g-cassie
g-cassie / main.zig
Last active March 4, 2023 04:18
Computer Enhance Part 1 in Zig
// I am a complete Zig noob so please be kind!
const std = @import("std");
pub fn getName(addr: u8, w: bool, dest: []u8) void {
if (w) {
std.mem.copy(u8, dest, switch (addr) {
0b00_000_000 => "ax",
0b00_000_001 => "cx",
0b00_000_010 => "dx",

Keybase proof

I hereby claim:

  • I am g-cassie on github.
  • I am gcassie (https://keybase.io/gcassie) on keybase.
  • I have a public key ASD9neDIs0Tf_0oGyWZqGg3dxsdDb9VfBGiZvYSyl2IFHwo

To claim this, I am signing this object:

// my-addon/templates/components/addon-componenent.hbs
We are going to render a component here:
{{component selectedComponent}}
// my-app/components/app-component.js
Ember.Component.extend({
// using ember inspect myService === undefined when using the application template below
myService: Ember.inject.service()
});
import md5
def find_key(secret):
"""
>>> find_key('abcdef')
609043
>>> find_key('pqrstuv')
1048970
"""
@g-cassie
g-cassie / application.controller.js
Last active December 2, 2015 18:38
Advent of Code Day 2 - Ember Solver
import Ember from 'ember';
const BoxToWrap = Ember.Object.extend({
length: 0,
height: 0,
width: 0,
sides: Ember.computed('length', 'width', 'height', function(){
const dims = ['length', 'width', 'height'];
const sides = [];
from firm.precedents.corporate.agreements import StartupShareholdersAgreement
from firm.precedents.corporate.mixins import DragAlongMixin, RightOfRefusalMixin
from jursidictions import Delaware
from votes import super_majority
from legal_entities import Corporation, Individual
# First lets create some parties to be part of our agreement
john = Individual(name='John Smith', jurisdiction=UK)
sam = Individual(name='Sam Smith', jurisdiction=Delaware)
# this uses the models setout in this gist: https://gist.github.com/g-cassie/6b9b0f29371677f48659
from projects.models import Project, User, UserProjectAccess
class UserProjectChildProfile(permissions.Profile):
# ProjectChild refers to any model that has a ForeignKey to Project
def __init__(self, request):
self.user = request.user
def get_queryset_filters(self, request, queryset):
@g-cassie
g-cassie / models.py
Created August 20, 2015 14:12
This is how we are handling complex permissions right now (this is actually a grossly simplified version). The main problem is permissions logic is split between multiple places. It would be nice to consolidate all permissions logic in permissions.py. Additionally it would be nice to make this more composable so you can have AdminPermission and …
class Organization(models.Model):
name = models.CharField()
class Project(models.Model):
name = models.CharField()
users = models.ManyToManyField('User', related_name='users', through='UserProjectPermission')
organization = models.ForeignKey(Organization)
@g-cassie
g-cassie / fields.py
Last active August 29, 2015 14:24
Django Rest Framework Custom Field - Embedded on read / Primary Key on write
from __future__ import unicode_literals
from django.core.exceptions import ObjectDoesNotExist
from rest_framework.relations import RelatedField
class EmbeddedPrimaryKeyRelatedField(RelatedField):
default_error_messages = {
'required': 'This field is required.',
'does_not_exist': "Invalid pk '{pk_value}' - object does not exist.",
'incorrect_type': 'Incorrect type. Expected pk value, received '