Skip to content

Instantly share code, notes, and snippets.

View trevorblades's full-sized avatar
🌵
#AlwaysLearning

Trevor Blades trevorblades

🌵
#AlwaysLearning
View GitHub Profile

Boolean() or !! (double bang, double negation)?

What's the best way to answer the question "true or false?" in JavaScript

JavaScript does not bother you too much with types (at first), which is both a blessing and a cure. But we all know the Boolean type. Boolean variables can either be true or false. Yes or no.

Every value in JavaScript can be translated into a boolean, true or false. Values that translate to true are truthy, values that translate to false are falsy. Simple.

This is about two ways to make that translation.

#!/bin/bash
open -na "/Applications/Google Chrome.app" "https://www.youtube.com/watch?v=5qap5aO4i9A"
echo Enjoy!
{
"dogBreeds": [{
"breed": "Labrador Retriever",
"breedType": "Purebred",
"origin": "Canada,USA",
"popularity": "1",
"temperament": ["Cheerful", "Gentle", "Friendly", "Intelligent"],
"hypoallergenic": "No",
"intelligence": 7,
"photo": "https://learnwebcode.github.io/json-example/images/cat-2.jpg"
@threepointone
threepointone / for-snook.md
Last active August 26, 2023 15:43
For Snook

https://twitter.com/snookca/status/1073299331262889984?s=21

‪“‬In what way is JS any more maintainable than CSS? How does writing CSS in JS make it any more maintainable?”

‪Happy to chat about this. There’s an obvious disclaimer that there’s a cost to css-in-js solutions, but that cost is paid specifically for the benefits it brings; as such it’s useful for some usecases, and not meant as a replacement for all workflows. ‬

‪(These conversations always get heated on twitter, so please believe that I’m here to converse, not to convince. In return, I promise to listen to you too and change my opinions; I’ve had mad respect for you for years and would consider your feedback a gift. Also, some of the stuff I’m writing might seem obvious to you; I’m not trying to tell you if all people of some of the details, but it might be useful to someone else who bumps into this who doesn’t have context)‬

So the big deal about css-in-js (cij) is selectors.

Unusual Shapes

Ask any of my friends, and they'll tell you I'm a big fan of shapes. Here are some of my all time favorites:

  • The circle
  • The hexagon
  • The triangle
  • The 'play button' (a triangle on its side)
  • The square
  • The fast square (a skewed square)
@trevorblades
trevorblades / consoles.json
Last active September 25, 2018 18:27
Console prices and sales adjusted for inflation
{
"Nintendo": [
{
"name": "N64",
"year": 1996,
"price": 289,
"sales": 32.93
},
{
"name": "Gamecube",
@timReynolds
timReynolds / example.js
Created June 17, 2017 12:04
Segment.com with next.js
<Head>
<script dangerouslySetInnerHTML={{ __html: `
var analytics=window.analytics=window.analytics||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","debug","page","once","off","on"];analytics.factory=function(t){return function(){var e=Array.prototype.slice.call(arguments);e.unshift(t);analytics.push(e);return analytics}};for(var t=0;t<analytics.methods.length;t++){var e=analytics.methods[t];analytics[e]=analytics.factory(e)}analytics.load=function(t){var e=document.createElement("script");e.type="text/javascript";e.async=!0;e.src=("https:"===document.location.protocol?"https://":"http://")+"cdn.segment.com/analytics.js/v1/"+t+"/analytics.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(e,n)};analytics.SNIPPET_VERSION="4.0.0";
@sadikay
sadikay / google_fonts.css
Created April 26, 2017 22:34
All Google Fonts In One CSS File
@font-face {
font-family: 'ABeeZee';
font-style: normal;
font-weight: 400;
src: local('ABeeZee'), local('ABeeZee-Regular'), url(http://fonts.gstatic.com/s/abeezee/v9/JYPhMn-3Xw-JGuyB-fEdNA.ttf) format('truetype');
}
@font-face {
font-family: 'Abel';
font-style: normal;
font-weight: 400;
@henriquemenezes
henriquemenezes / postgresql-set-id-seq.sql
Created March 31, 2016 12:23
PostgreSQL set Next ID Sequence Value to MAX(id) from Table
-- Get Max ID from table
SELECT MAX(id) FROM table;
-- Get Next ID from table
SELECT nextval('table_id_seq');
-- Set Next ID Value to MAX ID
SELECT setval('table_id_seq', (SELECT MAX(id) FROM table));
@rxaviers
rxaviers / gist:7360908
Last active June 26, 2024 12:22
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue: