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
const MAX_NUMBER = 10000000; | |
var numbers = {}; | |
var interval = null; | |
function getRandomInt(min, max) { | |
min = Math.ceil(min); | |
max = Math.floor(max); | |
return Math.floor(Math.random() * (max - min + 1)) + min; | |
} |
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 checkMaxPresent() { | |
if (numbers[MAX_NUMBER]) { | |
numbers[MAX_NUMBER].css('background-color', 'red'); | |
stop(); | |
alert('SUCCESS'); | |
return; | |
} | |
$('#numbers').html(''); | |
numbers = {}; // usuwa referencje do niepotrzebnych div-ów |
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
def find_quotes(self): | |
quotes_regex = r'(\".*?\"|((?<!\\)\'.*?(?<!\\)\'))' | |
iterator = re.finditer(quotes_regex, self.current_line()) | |
for match in iterator: | |
quote_span = match.span() | |
region = sublime.Region(quote_span[0] + self.current_line_start(), quote_span[1] + self.current_line_start()) | |
if region.contains(self.cursor_position): | |
return (quote_span[0], quote_span[1]) |
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
class SentenceNegator: | |
IRREGULAR_ES_VERB_ENDINGS = ["ss", "x", "ch", "sh", "o"] | |
CONSONANTS = ['a', 'e', 'i', 'o', 'u', 'y'] | |
def negate(self, sentence): | |
# is | |
if sentence.find("isn't") > -1: | |
return sentence.replace("isn't", "is") | |
if sentence.find("isn\\'t") > -1: |
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 sublime | |
import sys | |
from unittest import TestCase | |
class TestNegateSentence(TestCase): | |
def setUp(self): | |
self.view = sublime.active_window().new_file() | |
# make sure we have a window to work with | |
s = sublime.load_settings("Preferences.sublime-settings") | |
s.set("close_windows_when_empty", False) |
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
var oauth = {}; | |
/** @const */ | |
oauth.OAUTH_CLIENT_ID = 'OAUTH_CLIENT_ID'; | |
/** @const */ | |
oauth.OAUTH_CLIENT_SECRET = 'OAUTH_CLIENT_SECRET'; | |
/** | |
* This builds an OAuth2 service for connecting to Spotify |
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 fetchPlays(startDate, endDate) { | |
var headers = { | |
Authorization: 'Bearer ' + getOAuthService().getAccessToken() | |
} | |
var start = new Date(startDate).getTime(); | |
var end = new Date(endDate).getTime(); | |
var url = 'https://api.spotify.com/v1/me/player/recently-played?before=' + end; | |
var data = []; |
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
/** | |
* Constructor for DataCache. | |
* More info on caching: https://developers.google.com/apps-script/reference/cache/cache | |
* | |
* @param {object} cacheService - GDS caching service | |
* @param {Date} startDate - beggining of GDS request interval | |
* @param {Date} endDate - end of GDS request interval | |
* | |
* @return {object} DataCache. | |
*/ |
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 getData(request) { | |
// ... | |
var startDate = request.dateRange.startDate; | |
var endDate = request.dateRange.endDate; | |
var cache = new DataCache(CacheService.getUserCache(), startDate, endDate); | |
var plays = null; |
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
/** | |
* Constructor for DataCache. | |
* More info on caching: https://developers.google.com/apps-script/reference/cache/cache | |
* | |
* @param {object} cacheService - GDS caching service | |
* @param {Date} startDate - beggining of GDS request interval | |
* @param {Date} endDate - end of GDS request interval | |
* | |
* @return {object} DataCache. | |
*/ |