Create a function that returns Tic-Tac-Toe game winners. You can represent the board with a tuple of nine elements, where each group of three items is a row. The return of the function should be a tuple. When we have a winner, the first element should be the atom :winner
, and the second should be the player. When we have no winner, the tuple should contain one item that is the atom :no_winner
. It should work like this:
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
function loadJquery(version = "3.4.1") { | |
var jqry = document.createElement('script'); | |
jqry.src = `https://cdnjs.cloudflare.com/ajax/libs/jquery/${version}/jquery.js`; | |
document.getElementsByTagName('head')[0].appendChild(jqry); | |
return jQuery.noConflict(); | |
} | |
function getCredentials($) { | |
const $credential = $("h3:contains(Credentials)").parent() | |
const $servers = $credential.find(".credential-topic-label").map(function getParent() { |
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
#!/usr/bin/env bash | |
# Expected to be in a scripts directory | |
set -e | |
DATABASE_NAME="your-database" | |
SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | |
PROJECT_DIR="$( cd "${SCRIPTS_DIR}" && cd .. && pwd )" | |
echo "==== Start database and running all migration and seed scripts ====" | |
cd "${PROJECT_DIR}" |
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
// --- Directions | |
// Given an array and chunk size, divide the array into many subarrays | |
// where each subarray is of length size | |
// --- Examples | |
// chunk([1, 2, 3, 4], 2) --> [[ 1, 2], [3, 4]] | |
// chunk([1, 2, 3, 4, 5], 2) --> [[ 1, 2], [3, 4], [5]] | |
// chunk([1, 2, 3, 4, 5, 6, 7, 8], 3) --> [[ 1, 2, 3], [4, 5, 6], [7, 8]] | |
// chunk([1, 2, 3, 4, 5], 4) --> [[ 1, 2, 3, 4], [5]] | |
// chunk([1, 2, 3, 4, 5], 10) --> [[ 1, 2, 3, 4, 5]] |
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 arr = [ 100, 1,3,4,6,0,8,11, 2,30,5]; | |
function sort<T>(items: T[]) { | |
const copy = [...items]; | |
quickSort(copy); | |
return copy; | |
} | |
function quickSort<T>(items: T[], start: number = 0, end:number = items.length) { | |
const length = end - start; |
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 splitAt = (index: number) => (x: string) => [x.slice(0, index), x.slice(index)]; | |
const splitFirst = splitAt(1); | |
class ContactNode { | |
contactsCount: number = 0; | |
data: { [letter:string]: ContactNode } = {} | |
add(contact: string) { | |
this.contactsCount++; |
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
Show hidden characters
{ | |
"presets": [ | |
"@babel/preset-react", | |
[ | |
"@babel/preset-env", | |
{ | |
"targets": { "browsers": "last 2 versions" }, | |
"loose": true, | |
"modules": false | |
} |
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
[ | |
{ | |
"key": "ctrl+`", | |
"command": "workbench.action.terminal.focus", | |
"when": "!terminalFocus" | |
}, | |
{ | |
"key": "ctrl+`", | |
"command": "workbench.action.focusActiveEditorGroup", | |
"when": "terminalFocus" |
From a night of researching and playing around with a simple node container and how to get a docker-compose.yml
configuration to launch it behind an nginx proxy and get Let's Encrypt certificates.
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
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v /etc:/etc spotify/docker-gc |