Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
// From @NT3RP on https://stackoverflow.com/questions/5454235/shorten-string-without-cutting-words-in-javascript | |
var yourString = "The quick brown fox jumps over the lazy dog"; //replace with your string. | |
var maxLength = 6 // maximum number of characters to extract | |
//trim the string to the maximum length | |
var trimmedString = yourString.substr(0, maxLength); | |
//re-trim if we are in the middle of a word | |
trimmedString = trimmedString.substr(0, Math.min(trimmedString.length, trimmedString.lastIndexOf(" "))) |
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
// Taken from https://stackoverflow.com/a/79986/4187621 | |
function tokenTruncate($string, $your_desired_width) { | |
$parts = preg_split('/([\s\n\r]+)/u', $string, null, PREG_SPLIT_DELIM_CAPTURE); | |
$parts_count = count($parts); | |
$length = 0; | |
$last_part = 0; | |
for (; $last_part < $parts_count; ++$last_part) { | |
$length += strlen($parts[$last_part]); | |
if ($length > $your_desired_width) { break; } |
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
module.exports = { | |
env: { | |
es6: true, | |
jest: true, | |
browser: true | |
}, | |
extends: ["airbnb", "prettier", "prettier/react"], | |
globals: { | |
Atomics: "readonly", | |
SharedArrayBuffer: "readonly", |
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
docker run --name postgres -e POSTGRES_PASSWORD=password -p 5432:5432 -d -t postgres | |
docker run --name mongo -p 27017:27017 -d -t mongo | |
docker run --name redis -p 6379:6379 -d -t redis:alpine | |
docker exec -i -t postgres /bin/sh | |
su postgres | |
CREATE DATABASE bootcampnodejs; | |
\q | |
exit | |
exit |
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 smoothScrollByViewports(herodelay, viewports, duration) { | |
// Hide scrollbar | |
var style = document.createElement('style'); | |
style.type = 'text/css'; | |
style.innerHTML = `html::-webkit-scrollbar { width: 0px; }`; | |
document.getElementsByTagName('head')[0].appendChild(style); | |
var start = null; | |
var initialScrollTop = document.documentElement.scrollTop || document.body.scrollTop; | |
var distanceToScroll = window.innerHeight * viewports; |