Skip to content

Instantly share code, notes, and snippets.

View jorendorff's full-sized avatar

Jason Orendorff jorendorff

View GitHub Profile

This was written in response to: https://twitter.com/hillelogram/status/1227118562373963776


People mix the predicate "If a directed graph is a tree, it's a DAG" with the proposition "For all directed graphs, if a directed graph is a tree, it's a DAG".

First, for simplification: let's assume we're talking here about all graphs in the world with up to 10 nodes to be able to enumerate them. Also, note that we're talking about directed, not undirected, graphs.

To prove the proposition "For all..." is true, which is "(For graph G1, if it's a tree, it's a DAG) AND (For graph G2, if it's a tree, it's a DAG) AND...", since it's ANDs, we need to prove (For graph G1, if...) is true and we need to prove (For graph G2, if...) is true, ... etc.

@jorendorff
jorendorff / playground.rs
Created October 11, 2017 19:19 — forked from anonymous/playground.rs
Rust code shared from the playground
use std::fmt::Debug;
struct Reader<'a> {
buf: &'a [u8],
}
impl<'a> Reader<'a> {
fn read<'b>(&'b mut self, len: usize) -> Result<&'a [u8], ()> {
if len <= self.buf.len() {
let (read, remains) = self.buf.split_at(len);
@jorendorff
jorendorff / heads.py
Created August 4, 2017 04:21 — forked from jimblandy/heads.py
There must be a better way to compute this...
import random
random.seed()
def flip():
return random.choice([True, False])
def run():
b = flip()
n = 1
@jorendorff
jorendorff / editor.rs
Last active July 20, 2017 17:59 — forked from levicole/editor.rs
extern crate termion;
use std::io::{Write, Stdout, stdout, stdin};
use termion::event::{Key, Event};
use termion::input::TermRead;
use termion::raw::{IntoRawMode, RawTerminal};
use termion::screen::AlternateScreen;
pub struct Editor {
screen: AlternateScreen<Stdout>,
# Some more privileged methods, with some private data.
class Availability:
def __init__(self):
self._is_open = False
def open(self):
self._is_open = True
def close(self):
self._is_open = False
@jorendorff
jorendorff / 7.md
Last active February 20, 2017 13:54 — forked from anonymous/7.md

CIS claims 72 terrorists have come to the US from the 7 countries in Trump's travel ban. Here's what I learned.

  • These cases aren't about actual attacks in the U.S. The Ninth Circuit said "The Government has pointed to no evidence that any alien from any of the countries named in the Order has perpetrated a terrorist attack in the United States." The reason I got into this mess is people claiming the court lied. They did not lie. Nor is CIS lying. This list is mainly people who aided terrorist groups, and a few FBI sting operations. In all 11 cases I got to, no attack occurred.

  • These people were not all admitted to the U.S. under current vetting procedures. See the last case listed below.

Cases

I had an hour to spend. I looked into these cases, mostly relying on news accounts.

# To run this code, you'll need the sample data (133 MB download, unzips to 492 MB):
# http://bit.ly/2avfASU
# tar xjf sample.tar.bz2
defmodule Elindex.Searcher do
def search(word) do
File.ls!("sample")
|> Stream.map(fn(filename) ->
fn ->
Path.join("sample", filename)
%COMPILE(`eval(%expr)`, %env)

==>

do {
  let $callee = %COMPILE(`eval`, %env);
  let $arg = %COMPILE(%expr, %env);
  if ($callee === $runtime.crockEval) {
 let eval = $runtime.es7Eval;
@jorendorff
jorendorff / gist:9192015
Last active August 29, 2015 13:56 — forked from getify/gist:9105362
function* range(start, stop, step=1) {
for (var i = start; i < stop; i += step)
yield i;
}
for (var n of range(0, 100, 3))
console.log(n);
@jorendorff
jorendorff / gist:5156063
Last active December 14, 2015 22:09 — forked from fflorent/gist:5155923
function evaluate(context, expr, origExpr, onSuccess, onError)
{
var result;
var commandLine = createFirebugCommandLine(context, win);
// gets the debuggee object:
var dglobal = DebuggerLib.getDebuggeeGlobal(context.window, context);
var resObj;
// that works:
commandLine.someFunction = dglobal.makeDebuggeeValue(function()