Skip to content

Instantly share code, notes, and snippets.

View osnr's full-sized avatar

Omar Rizwan osnr

View GitHub Profile
// should work with tcc 0.9.27 from: https://bellard.org/tcc/ which I
// think merges minimal Darwin support from https://github.com/andreiw/tinycc
// (I think only `-run` works; it can't output a Mach-O executable?)
//
// but the header and libc situation on macOS for non-GCC/clang is
// such an incredible mess -- I did kinda get it working, but it's
// more fun to just write something that calls directly into the OS &
// has no dependencies (:
//
// $ tcc -nostdlib -nostdinc -run minimal-osx-tcc-hello.c
@osnr
osnr / tap.swift
Created December 22, 2017 21:27
//
// ScreenCapture.swift
// Screenotate
//
// Created by Omar Rizwan on 7/6/17.
// Copyright © 2017 Omar Rizwan. All rights reserved.
//
import Foundation
import Cocoa
/* ~/Library/KeyBindings/DefaultKeyBinding.dict */
{
/*
* Keybindings for emacs emulation.
*
* WARNING! After Mountain Lion, this file cannot be symbolic linked to another file,
* you need to put this file in ~/Library/KeyBindings/DefaultKeyBinding.dict directly
*
* Reference:

The American Negro has the great advantage of having never believed that collection of myths to which white Americans cling: that their ancestors were all freedom-loving heroes, that they were born in the greatest country the world has ever seen, or that Americans are invincible in battle and wise in peace, that Americans have always dealt honorably with Mexicans and Indians and all other neighbors or inferiors, that American men are the world's most direct and virile, that American women are pure. Negroes know far more about white Americans than that; it can almost be said, in fact, that they know about white Americans what parents -- or, anyway, mothers -- know about their children, and that they very often regard white Americans that way. And perhaps this attitude, held in spite of what they know and have endured, helps to explain why Negroes, on the whole, and until lately, have allowed themselves to feel so little hatred. The tendency has really been, insofar as this was possible, to dismiss white people

@osnr
osnr / Dfa.hs
Last active August 29, 2015 14:05
import Numeric
import Data.Char
import Data.Monoid
data State = Accept | S1 | S2 deriving (Show)
data Alphabet = Zero | One deriving (Show)
newtype Transition = Transition { runTransition :: State -> State }

Proposal: Outgoing Element ports and generalizing main

Let's allow outgoing ports to contain Elements, like this:

clicks : Input ()
clicks = Input ()

port takeClicks : Signal Element
port takeClicks = constant <| clickable clicks.handle () (spacer 40 40)
import Http
import Graphics.Input as I
import Graphics.Input.Field as F
inp : I.Input F.Content
inp = I.input F.noContent
urlify : String -> String
urlify t = "http://en.wikipedia.org/w/api.php?action=query&format=json&callback=?&titles=" ++ t ++ "&prop=revisions&rvprop=content"
@osnr
osnr / Bot.elm
Last active August 29, 2015 13:57
module Bot where
import Birdhouse as BH
port updates : Signal { status : String } -- Signal (BH.StatusUpdate {})
port updates = BH.update . show <~ count (every (10 * second))

Keybase proof

I hereby claim:

  • I am osnr on github.
  • I am osnr (https://keybase.io/osnr) on keybase.
  • I have a public key whose fingerprint is 8B05 2468 DA56 99A1 14AC EDEF 94B0 3760 DB70 6BD7

To claim this, I am signing this object:

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Test OTR</title>
</head>
<body></body>
<script>
var start = (new Date()).getTime();