This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// compile as g++-4.7 --std=c++11 threads.cc -lpthread -o threads | |
// g++ 4.7.2 will compile fine without the -lpthread, but (at least on my machine) the resulting binary burns and dies. -lpthread does need to occur after the .cc to work, for reasons not clear to me. | |
#include <iostream> | |
#include <thread> | |
#include <mutex> | |
#include <chrono> // timing, aw yeah | |
#include <atomic> | |
#include <cmath> // later irrelevant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function(){c=document.querySelector('#comments');c.style.position='absolute';c.style.marginLeft='-100px';c.style.marginRight='40px';c.style.marginBottom='20px';document.querySelectorAll('#respond')[1].style.display='none';}()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:function c(l){return l.querySelectorAll('li.comment').length;}function s(e){var h=[];for(var i=0; i<e.children.length; ++i){h.push({'E':e.children[i],'C':c(e.children[i])});}var t=h.sort(function(a,b){return a.C-b.C;});for(var i=t.length-1;i>0;--i){e.insertBefore(t[i].E,t[0].E);}}s(document.querySelector('ol.commentlist'));var d=document.querySelectorAll('ul.children');for(var i=0;i<d.length;++i){s(d[i]);} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:function c(l){return l.querySelectorAll('li.comment').length;}function s(e){var h=[];for(var i=0; i<e.children.length; ++i){h.push({'E':e.children[i],'C':c(e.children[i])});}var t=h.sort(function(a,b){return a.C-b.C;});for(var i=t.length-1;i>0;--i){e.insertBefore(t[i].E,t[0].E);}}s(document.querySelector('ol.commentlist')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function countChildren(liCommentEle) { | |
return liCommentEle.querySelectorAll('li.comment').length; | |
} | |
function sortList(listEle) { | |
var children = []; | |
for(var i=0; i<listEle.children.length; ++i) { | |
children.push({'ele': listEle.children[i], 'childCount': countChildren(listEle.children[i])}); | |
} | |
var sorted = children.sort(function(a, b){return a.childCount - b.childCount;}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function(){cs=document.querySelectorAll('.depth-1 > .commentholder a.comment-reply-link:last-child');cs=Array.prototype.slice.call(cs);cs.reverse();cs.forEach(function(c){commentToggle.call(c);});})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function(){document.querySelector('.comments-floater').style.position='absolute';})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function x(){"use strict"; x = 1;}()); // TypeError | |
(function x(){x = 1; return x !== 1;}()); // write fails silently; function returns true | |
(function x(){"use strict"; x = (function(){throw 0;})();})() // Error 0 | |
// These three lines rely on ES6. | |
(function x(){const x = 1;})() // No-op. In particular, not a redeclaration of x. | |
(function (){"use strict"; const x = 1; x = 2;})() // TypeError | |
(function (){const x = 1; x = 2;})() // TypeError. contrast (function x(){x = 2;}()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import networkx as nx | |
from collections import deque | |
import random | |
random.seed(42) # determinism! | |
def unique(l): | |
return len(l) == len(set(l)) | |
def canonical(path): # path is a tuple. should also ensure sub-cycles are canonized, really, but fuck it | |
# picks the minimum-valued starting point. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
var g, h; | |
function x() { f = ""; } | |
function y() { h = f; } | |
{ | |
// var-scoped f is undefined, let-scoped f is a function | |
f = 1; // let-scoped f gets value 1 | |
x(); // var-scoped f gets value "" | |
y(); // h gets value of var-scoped f | |
function f() {} // var-scoped f gets value of let-scoped f |
OlderNewer