Skip to content

Instantly share code, notes, and snippets.

View jorendorff's full-sized avatar

Jason Orendorff jorendorff

View GitHub Profile
@jorendorff
jorendorff / gist:2662282
Created May 11, 2012 20:40 — forked from anonymous/gist:2661058
Ziggurat for Firefox
// This is the code that goes with this screencast: https://www.youtube.com/watch?v=mT-6IQB4vi4
var win = gBrowser.selectedBrowser.contentWindow;
var doc = win.document;
var output = doc.createElement("div");
output.id = "output";
doc.body.appendChild(output);
var style = doc.createElement("style");
style.innerHTML = "div#output { margin-top: 10em; white-space: pre; } div#output span { padding: 0.6em; margin: 0 0.6em; border: 1px solid rgba(0, 0, 0, 0.8); border-radius: 0.2em; box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.4); position: relative; bottom: 1em; background-color: #ff5454; } div#output span > span { background-color: #ffa054; } div#output span > span > span { background-color: #ffff54; } div#output span > span > span > span { background-color: #8cd446; } div#output span > span > span > span > span { background-color: #45d2b0; } div#output span > span > span > span > span > span { background-color: #438ccb; } div#output span > span > span > span > span > span > span { background-color: #8c3fc0; } div#o
@jorendorff
jorendorff / gist:4224908
Created December 6, 2012 14:43 — forked from slevithan/gist:4222600
Thoughts on use of template strings with XRegExp and ES6

When browsers implement ES6 template strings, add tags XRegExp.r (regex as raw string) and XRegExp.rx (regex with implicit free-spacing, as raw string). Don't need tag XRegExp.raw (raw string), because you should be able to use, e.g., XRegExp(String.raw\w). Don't need to support flags /gy (which XRegExp doesn't allow in mode modifiers) with XRegExp.r/rx, since XRegExp methods provide alternate mechanisms for /gy (scope 'all', the sticky option, lack of need for lastIndex updating, and the XRegExp.globalize method if you really need it). All other flags (e.g., /im and custom flags /snxA) can be applied via a leading mode modifier (e.g., XRegExp.r(?s).).

If the above sounds confusing, keep in mind that you can simply maintain the status quo but still gain the benefits of raw multiline template strings (no more double escaping!) via, e.g.,

python shell.py
python <<END
from glu import db
db.create_all()
END
@jorendorff
jorendorff / post.rb
Created December 19, 2012 00:58 — forked from sam452/post.rb
require 'video_title_validator'
class Post < ActiveRecord::Base
attr_accessible :body, :title, :image, :video_title, :video_url
validates :video_url, :presence => true, :if => :video_title_present?
def video_title_present?
puts "YES IT IS BEING CALLED, FINALLY"
!self.video_title.blank?

Good-bye constructor functions?

tl;dr

Constructor function were workaround to specify constructor for a class without class. Now, having class nothing presribes the class being equivalent to its constructor. It always brought confusion and now with constructor empowered, it brings two-space problem. The class keyword can return plain objects, which have [[Construct]] calling the constructor of the class.

Problems

@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()
@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);
%COMPILE(`eval(%expr)`, %env)

==>

do {
  let $callee = %COMPILE(`eval`, %env);
  let $arg = %COMPILE(%expr, %env);
  if ($callee === $runtime.crockEval) {
 let eval = $runtime.es7Eval;
# 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)
@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.