Skip to content

Instantly share code, notes, and snippets.

Jo Liss joliss

Block or report user

Report or block joliss

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View flamegraph.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@joliss
joliss / gist:bce6017904544a11da00d28abf4005a3
Last active Jun 20, 2017
for next time I need to understand how Monads, higher-kinded types, sorts, and dependent types fit together
View gist:bce6017904544a11da00d28abf4005a3
// let's turn Promise and List into Monads
Promise::bind (then but must get promise)
List::bind (flatmap)
Promise::pure = Promise.resolve
List::pure = [x]
// This works in JS:
map(f: Fn, m: Monad) {
View parent-objects.md

How about having "parent objects" instead of "lifetimes"?

Language design question: I wonder if we can replace or supplant the notion of "lifetimes" in languages like Rust with a notion of "parent objects" (or "context objects").

In Rust (and most languages), iterators into vectors are (ptr, end) pairs. Having a notion of "parent" objects allows us to make them plain ptr values, and additionally allows for safely appending to vectors while iterating.

Some background first. In Rust, iterators into vectors (technically, into slices) are internally represented as (ptr, end) pairs. Thus if we create an iterator,

let mut i = vec.iter();
View benchmark.js
#!/usr/bin/node
const N = 1000000;
// 130 ms
(function() {
console.time('+=');
let a = '';
for (let i = 0; i < N; i++) {
a += 'x';
View fso.js
// module: fso, for in-memory file system objects
// FSObject is the raw object that will be part of the
// internal Broccoli plugin API. Need better name?
// (Git terminology: File = blob, Directory = tree,
// FSObject = object.)
class FSObject { }
class File extends FSObject {
View gist:fe9ed40417e326a20338c23a1986730b

Broccoli 1.0: What's New?

  • API future-proofed to allow for changes without breaking backwards compatibility
  • Temporary files now live in system-wide tmp dir (/tmp)
  • broccoli-sane-watcher pulled into core, now used by default
View poll_watcher.js
var helpers = require('broccoli-kitchen-sink-helpers')
var RSVP = require('rsvp')
module.exports = PollWatcher
RSVP.EventTarget.mixin(PollWatcher.prototype)
function PollWatcher(options) {
this.options = options || {}
if (this.options.interval == null) this.options.interval = 100
this.treeHash = null
View velocity.js.patch
diff --git a/velocity.js b/velocity.js
index c8b59e7..71ed48b 100644
--- a/velocity.js
+++ b/velocity.js
@@ -3365,7 +3365,7 @@ return function (global, window, document, undefined) {
if (timestamp) {
/* We ignore RAF's high resolution timestamp since it can be significantly offset when the browser is
under high stress; we opt for choppiness over allowing the browser to drop huge chunks of frames. */
- var timeCurrent = (new Date).getTime();
+ var timeCurrent = window.VELOCITY_TIME_FUNCTION(timestamp);
View nvm-benchmark
$ cd ~/.nvm && for commit in `git rev-list --first-parent --reverse v0.26.1..master`; do git checkout --quiet $commit && echo -n "$commit " && bash -c 'time . ~/.nvm/nvm.sh' 2>&1 | grep real; done
f34fef96d8ab3d7e6fba3574d122177de1140a88 real 0m0.062s
0181821b51609fe20ef72f8bf45523fe317be81a real 0m0.064s
0d898b0aa478cf86ea7afb6a733e8d2ff6ae75dd real 0m0.066s
0ef20199dcf6d4a21226a66cb8eccf23c6e16c7a real 0m0.064s
d4caf9fb670435a184a40242e6c215021187b46a real 0m0.065s
1e2a7a8de447c9b872fbf4cbe6c959cfc8d02a55 real 0m0.066s
c92effc6dabe8fc85252909e24ee49cbea89f3e7 real 0m0.068s
c9215a127feae213e9b09ca660f27801b0c52611 real 0m0.063s
014a44e15408ddcd6dc8c2ed9f781b2bfbd084d0 real 0m0.064s
View gist:48abfbaf5a3e097b3c92
Let a, b ∈ G, and let b be a right inverse of a, i.e. a*b = e.
Then we can show that b is also a left inverse of a:
b*a
=b*a*((b*a)*(b*a)^-1)
=((b*a)*(b*a))*(b*a)^-1 (by associativity)
=(b*(a*b)*a))*(b*a)^-1 (by associativity)
=(b*a)*(b*a)^-1 (by assumption)
=e
You can’t perform that action at this time.