Skip to content

Instantly share code, notes, and snippets.

View erichocean's full-sized avatar

Erich Ocean erichocean

  • Xy Group Ltd
  • North Carolina
View GitHub Profile
@warrenm
warrenm / Shapes.metal
Created July 22, 2018 09:25
Drawing 2D shapes with Metal
#include <metal_stdlib>
using namespace metal;
struct VertexIn {
float2 position [[attribute(0)]]; // varies per-vertex
float4 color [[attribute(1)]]; // varies per-instance
float3 center [[attribute(2)]]; // varies per-instance
float radius [[attribute(3)]]; // varies per-instance
};
@vvvvalvalval
vvvvalvalval / datomic-erasing-data-migration.clj
Created April 25, 2018 09:59
Erasing data from Datomic via a manual data migration
;; # EMULATING DATOMIC EXCISION VIA MANUAL DATA MIGRATION
;; *************************************
;; ## Introduction
;; *************************************
;; This Gist demonstrates a generic way to migrate an entire Datomic database
;; from an existing 'Origin Connection' to a clean 'Destination Connection',
;; while getting rid of some undesirable data and otherwise preserving history.
global
log 127.0.0.1 local0 notice
maxconn 4096
user haproxy
group haproxy
ssl-server-verify none
defaults
log global
mode http
@steven2358
steven2358 / ffmpeg.md
Last active May 5, 2025 07:54
FFmpeg cheat sheet
@technomancy
technomancy / gist:cc0e7800878c39e4c245fc041c11df4b
Last active April 21, 2023 01:16
Clojure namespaces, spec, and why they're confusing

To me, "require-and-automatically-visible" is violating the beauty of namespace. But, maybe I felt this way because I don't understand Clojure's registry or how require works.

I thought about this more, and I think I have a better understanding of why this feels strange. Clojure has one thing called "namespaces" which are clojure.lang.Namespace objects created by the ns macro. Functionally speaking they are a storage location which mostly just contain vars and references to vars in other namespaces. They are used for code organization: specifically for organizing vars and occasionally Java classes and interfaces.

Clojure also has a completely different thing called "namespaces" which are prefixes that get attached to keywords and symbols. These can interact with ns namespaces thru the reader in a handful of ways (for instance, ::double-colon keywords and symbols inside backtick forms are resolved according to the current clojure.lang.Namespace) but for the most part should be considered a di

@GuilloOme
GuilloOme / background.js
Last active March 24, 2023 20:05
Puppeteer (v.0.12.0) navigation blocking workaround
(function() {
'use strict';
// keep track of all the opened tab
let tabs = {};
// Get all existing tabs
chrome.tabs.query({}, function(results) {
results.forEach(function(tab) {
tabs[tab.id] = tab;
@AtulKsol
AtulKsol / db_backup_commands.md
Last active December 28, 2024 02:23
Commands to backup & restore database
  1. pg_dump is a nifty utility designed to output a series of SQL statements that describes the schema and data of your database. You can control what goes into your backup by using additional flags.
    Backup: pg_dump -h localhost -p 5432 -U postgres -d mydb > backup.sql

    Restore: psql -h localhost -p 5432 -U postgres -d mydb < backup.sql

    -h is for host.
    -p is for port.
    -U is for username.
    -d is for database.

@tunabrain
tunabrain / Range.hpp
Last active August 1, 2019 08:30
Python ranges in C++
#ifndef RANGE_HPP_
#define RANGE_HPP_
template<typename T> class RangeIterator;
template<typename T>
class Range
{
T _start, _end, _step;
@jwilson8767
jwilson8767 / es6-element-ready.js
Last active February 24, 2025 08:50
Wait for an element to exist. ES6, Promise, MutationObserver
// MIT Licensed
// Author: jwilson8767
/**
* Waits for an element satisfying selector to exist, then resolves promise with the element.
* Useful for resolving race conditions.
*
* @param selector
* @returns {Promise}
*/
------------------------- MODULE GryadkaCasRegister -------------------------
EXTENDS Integers, Sequences, FiniteSets
-----------------------------------------------------------------------------
\* Timestamps is the set of possible timestamps for operations to choose from.
\* Each operation uses a unique timestamp.
\* Values is the set of possible values to set the register to.
\* Acceptors is the set of nodes which act as acceptors in the paxos sense.
\* Quorums is the set of all possible quorums, typically simple majorities.
CONSTANTS Timestamps, Values, Acceptors, Quorums