This file contains hidden or 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
const CONCURRENCY = 5; | |
function sleep(ms) { | |
return new Promise(resolve => setTimeout(resolve, ms)); | |
} | |
const doWork = async (work) => { | |
const duration = Math.random() > 0.5 ? 1000 : 10000 | |
await sleep(duration) | |
return console.log("doing work", work) | |
} |
This file contains hidden or 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
# Script runs on mac. Would need to be adapted to run on windows. | |
require 'sqlite3' | |
require 'json' | |
require 'zip' | |
require 'tmpdir' | |
require 'find' | |
# Function to unzip the file | |
def unzip_file(file, destination) |
This file contains hidden or 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
<:Title> | |
New Poll | |
<:Body> | |
<h1>New Poll</h1> | |
<form> | |
<h3>Question</h3> | |
<input type="text" value="{{ page._todo._question }}"> | |
{{ page._todo._answers.each do |answer| }} | |
<div><input type="text" value="{{ answer._text }}"></div> |
This file contains hidden or 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
Alternating 2 opposite walls and 2 adjacent walls 4 times guarantees freedom for the subset of problems where half of the buttons are in each position. | |
Then flip a random switch and the problem has been reduced to one that has already been solved. |
This file contains hidden or 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
<html> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> | |
<body></body> | |
<script src="frontend.js"></script> | |
<script src="frontendDev.js"></script> | |
</html> |
This file contains hidden or 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
def rotx(x, string, encrypt=true) | |
offset = encrypt ? x : -x | |
uppers = Hash[("A".."Z").zip(("A".."Z").to_a.rotate(offset))] | |
lowers = Hash[("a".."z").zip(("a".."z").to_a.rotate(offset))] | |
dictionary = uppers.merge(lowers) | |
output = "" | |
string.length.times do |idx| | |
char = string[idx] | |
if dictionary[char] | |
output += dictionary[char] |
This file contains hidden or 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
Promise = function(){ | |
this.result = undefined; | |
this.complete = false | |
this.failure = false; | |
this.onFailure = []; | |
this.onSuccess = []; | |
}; | |
Promise.prototype.resolve = function(fnResult){ | |
if (this.complete){ |