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
/* | |
You are given a string S. Find a string T that has the most number of occurrences as a substring in S. | |
If the solution is not unique, you should find the one with maximum length. If the solution is still not unique, find the smallest lexicographical one. | |
cabdab | |
ab | |
cabcabc | |
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
// can try http://mathworld.wolfram.com/ConvexHull.html, but overkill.. | |
#include <algorithm> | |
#include <iostream> | |
#include <vector> | |
using namespace std; | |
int Dist(pair<int, int> a, pair<int, int> b) { | |
return (a.first - b.first) * (a.first - b.first) + | |
(a.second - b.second) * (a.second - b.second); | |
} |
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://csacademy.com/contest/round-51/task/manhattan-distances/ | |
#include <iostream> | |
#include <algorithm> | |
#include <vector> | |
using namespace std; | |
int main() { | |
int T, a, b, c, h; | |
cin >> T; |
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
/** | |
* @param {string} name | |
* @returns {string|null} | |
* getQueryParam('a') returns '1' on page http://domain.com/page.html?a=1&b=2 | |
**/ | |
function getQueryParam(name) { | |
const q = window.location.search.match( | |
new RegExp('[?&]' + name + '=([^&#]*)') | |
); | |
return q && q[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
/** | |
* disable clicked button before jQuery ajax request and enable after ajax request finished | |
* @param {Function} ajaxFn | |
* ajaxFn should return executed jQuery AJAX function | |
* @returns {Function} | |
* returned function should be placed in event listener of Element | |
* | |
* Usage: | |
* $('#deactivate-btn').click(disableBtnDuringAjax(function(e) { | |
* return $.get('/api/users', function (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
def get_iso_format(): | |
""" | |
this returns utc iso8601 string. for example: '2018-06-19T08:51:56+00:00' | |
""" | |
import datetime | |
return datetime.datetime.now(tz=datetime.timezone.utc).replace(microsecond=0).isoformat() |
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
files: | |
/etc/nginx/conf.d/proxy.conf: | |
mode: "000644" | |
owner: root | |
group: root | |
content: | | |
upstream nodejs { | |
server 127.0.0.1:5000; | |
keepalive 256; | |
} |
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
# --------------------------------------------------------------------------- | |
# | |
# Description: This file holds all my BASH configurations and aliases | |
# | |
# Sections: | |
# 1. Environment Configuration | |
# 2. Make Terminal Better (remapping defaults and adding functionality) | |
# 3. File and Folder Management | |
# 4. Searching | |
# 5. Process Management |
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
# --------------------------------------------------------------------------- | |
# | |
# Description: This file holds all my BASH configurations and aliases. | |
# Much of this was originally copied from: | |
# http://natelandau.com/my-mac-osx-bash_profile/ | |
# | |
# Sections: | |
# 1. Environment Configuration | |
# 2. Make Terminal Better (remapping defaults and adding functionality) | |
# 3. File and Folder Management |
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 itertools | |
abs_min_support = 771 | |
freq_items = [None, {}] | |
# part1 | |
counting = {} | |
with open('categories.txt', 'r') as f: | |
while True: | |
line = f.readline() |