Skip to content

Instantly share code, notes, and snippets.

View racer161's full-sized avatar
🍑
Building the Singularity

Ethan Spurlock racer161

🍑
Building the Singularity
View GitHub Profile
@donny-dont
donny-dont / aligned_allocator.cpp
Created December 13, 2011 09:11
An aligned allocator for placing SIMD types in std::vector
#ifdef _WIN32
#include <malloc.h>
#endif
#include <cstdint>
#include <vector>
#include <iostream>
/**
* Allocator for aligned data.
@irsal
irsal / binary_heap.cs
Last active April 3, 2023 13:36
Binary Heap Implementation C#
using System;
namespace PathPlanner
{
/// <summary>
/// A min-type priority queue of Nodes
/// </summary>
public class BinaryHeap
{
#region Instance variables
@nathansobo
nathansobo / log-linear-goto-intuition.md
Last active June 27, 2019 08:11
Intuition for `merge_op` in Raph Levein's GOTO implementation

When merging an operation O, there may be several operations scattered through the local history that are concurrent to O. We need to rearrange our history so that all of these concurrent operations are moved to the end of the history. Then we can transform O against each of these concurrent operations and append it to the end.

Say we're adding O a history with the following suffix. The operations surrounded by vertical bars are concurrent to O. Otherwise the operations causally precede O.

EO0 |EO1| EO2 EO3 |EO4| |EO5| EO6

We need to rearrange this history so it looks like this.

.css-selector {
    background: linear-gradient(160deg, #ff4ff5, #ca63ff, #f74a4a, #ffefef);
    background-size: 800% 800%;
    -webkit-animation: racer161Background 8s ease infinite;
    -moz-animation: racer161Background 8s ease infinite;
    -o-animation: racer161Background 8s ease infinite;
    animation: racer161Background 8s ease infinite;
}
@-webkit-keyframes racer161Background {
    0%{background-position:82% 0%}
@dabit3
dabit3 / add-user-trigger.js
Last active November 7, 2022 10:17
Add a user to DynamoDB after signing up
var aws = require('aws-sdk')
var ddb = new aws.DynamoDB()
exports.handler = async (event, context) => {
let date = new Date()
if (event.request.userAttributes.sub) {
let params = {
Item: {
'id': {S: event.request.userAttributes.sub},
'__typename': {S: 'User'},
@arabold
arabold / useDataStoreQuery.tsx
Last active February 23, 2023 18:07
Simplify querying the Amplify DataStore using React hooks
import {
DataStore,
PersistentModel,
PersistentModelConstructor,
ProducerModelPredicate,
SortPredicate,
ProducerPaginationInput
} from '@aws-amplify/datastore'
import { useCallback, useEffect, useState } from 'react'