Skip to content

Instantly share code, notes, and snippets.

View takkaria's full-sized avatar

Anna Sidwell takkaria

  • @PeopleRetrofit
  • Berlin, DE
View GitHub Profile
import React, { createContext, useContext, ReactElement } from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
/*** Shared ***/
/*
* A function that returns a promise that resolves to a message.
*
* We do this to keep the length of lines down a bit. It also matches with the
* terminology used in Elm.
#!/usr/bin/env node
const { readdirSync, readFileSync } = require('fs');
const model = require('../mhep/dev/static/dev/js/model');
const datasets = require('../mhep/dev/static/dev/js/model-datasets');
const process = require('process');
function lines(obj, prefix = '.') {
return Object.entries(obj).flatMap(([ k, v ]) => {
if (typeof v === 'object' && v !== null ) {
@takkaria
takkaria / hmm.txt
Created May 4, 2021 19:27
sketch for a django template autoformatter
<img src="...">
<img {{ variable }}>
<img {{ variable }}="...">
<img {% tag %}>
<img {% if variable %}attr="..."{% else %}attr=",,,"{% endif %}>
<img src="{{ variable }}">
<img src="{% tag %}">
<img src="{% if variable %}...{% else %}...{% endif %}">
<img class="className {% if variable %}freddo{% else %}greggo{% endif %} meowMeow">
@takkaria
takkaria / cherrybranch.sh
Created April 13, 2021 16:20
cherry-branch
cherry-branch () {
if (test $# -lt 3); then
echo "Usage: cherry-branch [-p] <branch> <origin> <refs...>";
echo " -p push to upstream with same name"
echo " <branch> new branch name"
echo " <origin> origin ref, e.g. origin/master"
echo " <refs> commit IDs to cherry-pick"
return;
fi

Existing ways to do this:

  1. Are not type safe (DRF)
  2. Require the same structure between the JSON and the serialization (dataclasses_json)

payload:

{
    "date": "2020-12-12",
@takkaria
takkaria / macquette-react.jsx
Last active December 3, 2020 16:37
macquette react
import React, { useState } from "react";
import { render } from "react-dom";
// This is obviously not a 'real' assessment class.
// I often try to practice API-first design and in this case this is the interface
// that fell out from trying to write the React views how I'd like to.
// We'll need something different for the actual assessment class.
class Assessment {
constructor() {
@takkaria
takkaria / notes.md
Last active November 13, 2020 00:34
finn c pointers

I understand the intent of what you were doing, which was to return an array from ziffern_extrahieren() and copy the results of that array into the array in is_armstrong_number(). I'll point out the mistakes in what you wrote and explain how you do this in C.

Compiler errors

int *ziffern_extrahieren(int candidate, int laenge) {
	int *ziffern = malloc(...);
	...
	return *ziffern;
}
@takkaria
takkaria / panic 1
Last active November 6, 2020 14:25
kernel panics
Anonymous UUID: 3D69F6D2-EBDF-7C47-DF12-EA9BAE226D2E
Thu Nov 5 12:45:37 2020
*** MCA Error Report ***
CPU Machine Check Architecture Error Dump (CPU: Intel(R) Core(TM) i7-5557U CPU @ 3.10GHz, CPUID: 0x306D4)
Core: 0
IA32_MC0_STATUS=0xF200000000090005
IA32_MC0_CTL=0x0
Core: 0
INSERT INTO crm_membershipstatus (created, status, membership_id)
SELECT p.end_date AS created, m.status AS status, p.membership_id AS membership_id
FROM crm_membership m
LEFT JOIN crm_membershipstatus s ON m.contact_id = s.membership_id
LEFT JOIN (
SELECT
period1.membership_id, period1.end_date
FROM
crm_membershipperiod AS period1
LEFT OUTER JOIN