Skip to content

Instantly share code, notes, and snippets.

@dan-laskowski
dan-laskowski / rwd-embed-yt.css
Last active July 7, 2020 12:29
[Responsive YouTube Player] #youtube #responsive #embed #css #style
<style>
.iframe-container{
position: relative;
width: 100%;
padding-bottom: 56.25%;
height: 0;
}
.iframe-container iframe{
position: absolute;
top:0;
@dan-laskowski
dan-laskowski / additive-inverse.js
Created August 6, 2020 12:39
[Additive Inverse] #arrays #math #map #loops
function additiveInverse(arr) {
return arr.map(x => -x);
}
@dan-laskowski
dan-laskowski / count-syllables.js
Created August 6, 2020 12:42
[Count Syllables] #js #strings
function numberSyllables(word) {
return word.split(`-`).length
}
@dan-laskowski
dan-laskowski / convert-number-to-month.js
Created August 6, 2020 12:48
[Convert Number to Month Name] #arrays #js #formatting #dates
function monthName(num) {
return new Date(2000, num - 1).toLocaleString("en-us", {month: "long"});
}
@dan-laskowski
dan-laskowski / strikethrough.css
Created October 2, 2020 16:45
[Animated line-through text] #css #animation
.todo-item__text--completed {
display: inline-block;
position: relative;
transition: all .5 cubic-bezier(.55,0,.1,1);
/* text-decoration: line-through; */
}
.todo-item__text--completed:after {
content: '';
position: absolute;
@dan-laskowski
dan-laskowski / reset.css
Created November 6, 2020 13:25
[RESET CSS] #css #reset
/* http://meyerweb.com/eric/tools/css/reset/
v2.0-modified | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
@dan-laskowski
dan-laskowski / unique.js
Created November 7, 2020 11:38
[Array with unique categories] #js #javascript
const allCategories = ['all', ...new Set(items.map((item) => item.category))];
@dan-laskowski
dan-laskowski / sortUsersDsc
Created January 4, 2021 19:59
[Sort users by descending follow count] #javascript #js #array #sort
let sortUsersByDescendingFollowCount = users.sort((a, b) => a.followers < b.followers ? 1 : -1)
@dan-laskowski
dan-laskowski / capitalize.js
Created May 5, 2021 12:03
[Capitalize the first letter of a string] #javascript #js
// Capitalize the first letter of a string
const capitalize = str => `${str.charAt(0).toUpperCase()}${str.slice(1)}`;
capitalize("hello, you are a cool person!");
// Result: "Hello, you are a cool person!"
@dan-laskowski
dan-laskowski / sortNumbers.js
Created May 5, 2021 12:06
[Sort an array containing numbers] #javascript #js #array #sort #number
// Sort an array containing numbers
const sort = arr => arr.sort((a, b) => a - b);
sort([1, 5, 2, 4, 3]);
// Result: [1, 2, 3, 4, 5]