Skip to content

Instantly share code, notes, and snippets.

Creating Black holes.

Pankaj Doharey metacritical

Creating Black holes.
View GitHub Profile
metacritical / LICENSE
Created Sep 16, 2021 — forked from mattyclarkson/LICENSE
Compile time Murmur3_32 implementation using C++11 constexpr
The MIT License (MIT)
Copyright (c) <year> <copyright holders>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
metacritical / murmur3_constexpr.cpp
Created Sep 13, 2021 — forked from komiga/murmur3_constexpr.cpp
MurmurHash3 in C++11 using constexpr!
View murmur3_constexpr.cpp
#include <cstddef>
#include <cstdint>
#include <cstdio>
namespace util {
struct funcs;
template <typename S> struct mh3_internal;
template <typename S, S default_seed> struct mh3;
typedef mh3<uint32_t, 0> mh3_default;
metacritical / lisp.cpp
Created Sep 7, 2021 — forked from ofan/lisp.cpp
Lisp interpreter in 90 lines of C++
View lisp.cpp
Lisp interpreter in 90 lines of C++
I've enjoyed reading Peter Norvig's recent articles on Lisp. He implements a Scheme interpreter in 90 lines of Python in the first, and develops it further in the second.
Just for fun I wondered if I could write one in C++. My goals would be
1. A Lisp interpreter that would complete Peter's test cases correctly...
2. no more than 90 lines of C++.
Although I've been thinking about this for a few weeks, as I write this I have not written a line of the code. I'm pretty sure I will achieve 1, and 2 will be... a piece of cake!
metacritical / gist:f783f4e1159408eb0f821bfdfa42cb5b
Created Aug 19, 2021 — forked from zliuva/gist:1084476
A minimal Mach-o x64 executable for OS X
View gist:f783f4e1159408eb0f821bfdfa42cb5b
; A minimal Mach-o x64 executable for OS X (also see below Mountain Lion version)
; $ nasm -f bin -o tiny_hello tiny_hello.s
; $ chmod +x tiny_hello
; $ ./tiny_hello
; Hello World!
; $
; c.f.
; ( the original tiny mach-o executable )
metacritical / tiny_hello.asm
Created Aug 19, 2021 — forked from tilarids/tiny_hello.asm
A minimal Mach-o x32 executable for OS X El Capitan (with proper padding and symtable)
View tiny_hello.asm
; A minimal Mach-o x32 executable for OS X El Capitan (with proper padding and symtable)
; Original (pre 10.10.5) version -
; $ nasm -O0 -f bin -o tiny_hello tiny_hello.asm
; $ chmod +x tiny_hello
; $ ./tiny_hello
; (returns 42)
; $
; c.f.

Running processing without a screen

Let's say you want to run a Processing sketch on a server. Like maybe you want to generate several million PDF and JPEG images using a handful of Amazon EC2 instances.

This is called “headless” mode, and to do so, it's necessary to install what's known as a virtual frame buffer.

On Ubuntu 14.04, these are the things you need to install first:

sudo apt-get install xvfb libxrender1 libxtst6 libxi6 
metacritical / System
Created Aug 6, 2021 — forked from vasanthk/System
System Design Cheatsheet
View System

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
metacritical / router.clj
Created May 27, 2021 — forked from borkdude/router.clj
Small ring router using core.mach in babashka
View router.clj
(require '[clojure.core.match :refer [match]]
'[clojure.string :as str]
'[hiccup2.core :refer [html]]
'[org.httpkit.server :as server])
(defn router [req]
(let [paths (vec (rest (str/split (:uri req) #"/")))]
(match [(:request-method req) paths]
[:get ["users" id]] {:body (str (html [:div id]))}
:else {:body (str (html [:html "Welcome!"]))})))
View *nokogiri-commandline-ref.txt
require 'nokogiri'
require 'open-uri'
# Get a Nokogiri::HTML:Document for the page we're interested in...
doc = Nokogiri::HTML(open(''))
# Do funky things with it using Nokogiri::XML::Node methods...

Configuring Emacs for react, es6, and flow

For a while, JSX and new es6 syntax had flaky support in emacs, but there's been huge work on a lot of packages. Using emacs for JavaScript with React, ES6, and Flow (or Typescript, etc) is really easy and powerful in Emacs these days.

This is how you can work on modern web development projects with full support for tooling like JSX, Flow types, live eslint errors, automatic prettier.js formatting, and more.

Set up web-mode

web-mode provides most of the underlying functionality, so a huge shout-out to the maintainer(s) there.