Skip to content

Instantly share code, notes, and snippets.

View metacritical's full-sized avatar
Creating Black holes.

Pankaj Doharey metacritical

Creating Black holes.
View GitHub Profile
@metacritical
metacritical / gist:f783f4e1159408eb0f821bfdfa42cb5b
Created August 19, 2021 01:05 — forked from zliuva/gist:1084476
A minimal Mach-o x64 executable for OS X
; 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.
; http://osxbook.com/blog/2009/03/15/crafting-a-tiny-mach-o-executable/ ( the original tiny mach-o executable )
@metacritical
metacritical / tiny_hello.asm
Created August 19, 2021 01:01 — forked from tilarids/tiny_hello.asm
A minimal Mach-o x32 executable for OS X El Capitan (with proper padding and symtable)
; A minimal Mach-o x32 executable for OS X El Capitan (with proper padding and symtable)
;
; Original (pre 10.10.5) version - https://gist.github.com/softboysxp/1084476
; $ nasm -O0 -f bin -o tiny_hello tiny_hello.asm
; $ chmod +x tiny_hello
; $ ./tiny_hello
; (returns 42)
; $
; c.f.
@metacritical
metacritical / headless-p5.md
Created August 15, 2021 12:07 — forked from dropmeaword/headless-p5.md
Headless processing

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
metacritical / System Design.md
Created August 6, 2021 19:48 — forked from vasanthk/System Design.md
System Design Cheatsheet

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
metacritical / router.clj
Created May 27, 2021 10:56 — forked from borkdude/router.clj
Small ring router using core.mach in babashka
(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!"]))})))
require 'nokogiri'
require 'open-uri'
# Get a Nokogiri::HTML:Document for the page we're interested in...
doc = Nokogiri::HTML(open('http://www.google.com/search?q=tenderlove'))
# Do funky things with it using Nokogiri::XML::Node methods...
####
@metacritical
metacritical / react-es6-flow-emacs-configuration.md
Created November 8, 2020 19:36 — forked from CodyReichert/react-es6-flow-emacs-configuration.md
Configuring Emacs for react, es6, and flow

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.

@metacritical
metacritical / postgres-brew.md
Last active October 31, 2020 01:02 — forked from ibraheem4/postgres-brew.md
Installing Postgres via Brew (OSX)

Installing Postgres via Brew (Read From below for issues)

Pre-Reqs

Brew Package Manager

In your command-line run the following commands:

  1. brew doctor
  2. brew update
@metacritical
metacritical / cprint.clj
Created August 4, 2019 19:10 — forked from kocubinski/cprint.clj
ClojureCLR println with colors in Windows cmd.exe
(assembly-load "ClojureClrEx")
(ns clync.core
(:use [clojure.clr.pinvoke :only [dllimports]]))
(dllimports
"Kernel32.dll"
(GetStdHandle IntPtr [Int32])
(SetConsoleTextAttribute Boolean [IntPtr UInt32]))
using UnityEngine;
public class BoidBehaviour : MonoBehaviour
{
void Update()
{
Boids.Core.update(transform);
}
}