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 seekSettings(time, increment, rated, ratingRange) { | |
var expectedVariant = 'Standard'; | |
var expectedTimeMode = 'Real time'; | |
if ($('#variant').find(':selected').text() !== expectedVariant) { | |
alert('Failed. Set variant to: ' + expectedVariant); | |
return; | |
} | |
if ($('#timeMode').find(':selected').text() !== expectedTimeMode) { | |
alert('Failed. Set time control to: ' + expectedTimeMode); | |
return; |
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
//////////////////////////////////////////////////////////////////////////////// | |
//// Seek modal | |
// Find rating... | |
// ...for active (currently visible) variant. Worth noting that "Standard" | |
// variant has multiple ratings (blitz, bullet, classical) | |
$('div.ratings div').filter((i, e) => e.style.display === 'block').find('strong').text() | |
// ...for classical | |
$('div.ratings div.classical strong').text() |
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
; Define variables a and b | |
:a :b | |
; Initialize a = 3, b = 2. $a is EBF for "go to the cell where a is stored." | |
$a 3+ | |
$b 2+ ; (1) See footnotes below if you're not familiar with BF. | |
; Define a "pour" macro. Pour is BF's simplest version of "add". In another | |
; language, it might look like this: (of course, it's a macro, not a function) | |
; |
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
# coding: utf-8 | |
x = range(4) | |
y = zip('1234', 'abcd') | |
def has_four_unique_elements(seq): | |
return len(set(seq)) == 4 | |
# This works fine. | |
print(1, has_four_unique_elements(x)) # -> True | |
# Still works fine. |
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
# https://gist.github.com/prendradjaja/35a2816c0b5750ffc91cc091e760dc00 | |
# for version with tabs | |
import unittest | |
class TestSomething(unittest.TestCase): | |
def test_something(self): | |
pass | |
if __name__ == '__main__': |
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
# https://gist.github.com/prendradjaja/a35b0dc59fb137dc71ef7703a330ab02 | |
# for version with spaces | |
import unittest | |
class TestSomething(unittest.TestCase): | |
def test_something(self): | |
pass | |
if __name__ == '__main__': |
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 sys | |
import os | |
assert len(sys.argv) == 3 | |
raw_url = sys.argv[2] | |
class FORMATS: | |
BITBUCKET = 'https://bitbucket.org' | |
GITHUB = 'https://github.com' |
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
BOOKMARKLET_NAME = 'xkcd-permalink.js'; | |
function main() { | |
var prev = $('a[rel="prev"]')[0].href; | |
var parts = prev.split('/'); | |
if (parts.length !== 5) { | |
fail('Expected exactly 4 slashes in "prev" link URL, e.g. https://www.xkcd.com/1000/. Actual URL: ' + prev); | |
} | |
if (!Number.isInteger(+parts[3])) { | |
fail('URL segment before last slash must be an integer. Actual: ' + parts[3]); |
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
// https://stackoverflow.com/questions/11778477/variable-in-chrome | |
// https://developer.mozilla.org/en-US/docs/Web/API/Element/querySelector | |
var homeStream = $('.js-homeStream'); | |
var stories = homeStream.children; | |
function getReadingTime (story) { | |
return +$('.readingTime', story).title.split(' ')[0]; | |
} |
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
// Minifier fork (with ES6 support): | |
// https://jadengore.github.io/bookmarkleter/ | |
// My usual minifier (no ES6 support): http://chriszarate.github.io/bookmarkleter/ | |
// GitHub issue: https://github.com/chriszarate/bookmarkleter/issues/7 | |
function main() { | |
prompt('Press Ctrl-C to copy', '#' + getTimeStamp()); | |
} | |
function getTimeStamp() { |
OlderNewer