Giter VIP home page Giter VIP logo

snippets's Introduction

Snippets

Collecting bits and pieces in one place

HTML

Protect target blank from mischief

<a href="https://hacks.mozilla.org/2022/04/mdn-plus-now-available-in-more-markets" target="_blank" rel="noopener noreferrer">Learn more</a>

Datalist

<label for="exampleDataList" class="form-label">Datalist example</label>
<input class="form-control" list="datalistOptions" id="exampleDataList" placeholder="Type to search...">
<datalist id="datalistOptions">
  <option value="San Francisco">
  <option value="New York">
  <option value="Seattle">
  <option value="Los Angeles">
  <option value="Chicago">
</datalist>

CSS

Debug

* {
  background: rgba(0 100 0 / 0.05);
  outline: 1px solid limegreen;
}

Sticky Footer

html {
  height: 100%;
}

body {
  height: 100%;
}

footer {
  position: sticky;
  top: 100%;
}

Container Without Inner Div

.content {
  padding: var(--gap) max(var(--edge), calc(50% - var(--width-xl)/2));
}

Autogrid

.results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--card-width), 1fr));
    gap: var(--gap);
    max-width: var(--max-width);
    padding: 0 var(--edge);
    margin: 0 auto;
}

Breakpoints

688px - 992px - 1312px

JavaScript

Console Log

console.log("(◡‿◡)")
const person = {name: 'Joe', age: 30. pets: ['cat','fish','dog']}

//old faithful
console.log(person)

//nicely formats objects
console.dir(person)

//displays message if the assertion fails
console.assert(person.pets.find(pet => pet === 'hamster'), 'Person does not own a hamster')

//increment a counter
person.pets.forEach(pet => console.count('Pets'))

//pretty table
console.table(person)

//start a timer, log the progress, show total elapsed
console.time() / timeLog() / timeEnd()

//
console.trace()

//group messages to avoid spamming the console
console.group()
console.groupCollapsed()

//styling
console.log('%c I am a logging master', 'font-weight: bold; background-color: cyan; color: navy; padding: 15px')

//specific styling
console.log(
  'CSS can make %cyour console logs%c %cawesome%c!',  // String to format
  // Each string is the CSS to apply for each consecutive %c
  'color: #fff; background: #1e90ff; padding: 4px',   // Apply styles
  '',                                                 // Clear any styles
  'color: #f00; font-weight: bold',                   // Apply styles
  ''                                                  // Clear any styles
);


// {x: 1, y: 2, z: 3}
console.log({x, y, z});

//threat levels
console.debug('Debug message');
console.info('Useful information');
console.warn('This is a warning');
console.error('Something went wrong!');

Simple Feed

let jsonData = JSON.parse(jobs);

const FEED_URL = `https://www.peoplebank.com/pb3/corporate/jksrestaurants/feed.php`;

let jobList = [];

fetch(FEED_URL)
  .then(response => response.json())
  .then(data => {

    data.sort((a, b) => (a.title.rendered > b.title.rendered) ? 1 : -1);

    console.log(data);

    let content = `<div class="headings"><div class="role">Role</div><div class="location">Location</div><div class="date">Date</div></div><div class="result"><div class="title">${data[0].title.rendered}</div><div class="location"><a href="${data[0].link}">${data[0].related_venue.title}</a>`;

    let currentTitle = data[0].title.rendered;

    for (let i = 1; i < data.length; i++) {
      if (data[i].title.rendered == currentTitle) {
        content = content + `<a href="${data[i].link}">${data[i].related_venue.title}</a>`;
      } else {
        content = content + `</div><div class="salary">${data[i].date}</div></div><div class="result"><div class="title">${data[i].title.rendered}</div><div class="location"><a href="${data[i].link}">${data[i].related_venue.title}</a>`;
        currentTitle = data[i].title.rendered;
      }
    }

    content = content + `</div><div class="salary">${data[data.length-1].date}</div></div>`;

    document.querySelector('#app').innerHTML = content;

  });

snippets's People

Contributors

dugbus avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.