Skip to content

Instantly share code, notes, and snippets.

@mixin for-phone-only {
@media (max-width: 599px) { @content; }
}
@mixin for-tablet-portrait-up {
@media (min-width: 600px) { @content; }
}
@mixin for-tablet-landscape-up {
@media (min-width: 900px) { @content; }
}
@mixin for-desktop-up {
@nkhil
nkhil / arrow.js
Created October 1, 2018 20:39
Lexical Scope of Arrow Functions
const something = ()=>{
console.log(this
}
@nkhil
nkhil / package.json
Created October 3, 2018 07:48 — forked from addyosmani/package.json
npm run-scripts boilerplate
{
"name": "my-app",
"version": "1.0.0",
"description": "My test app",
"main": "src/js/index.js",
"scripts": {
"jshint:dist": "jshint src/js/*.js",
"jshint": "npm run jshint:dist",
"jscs": "jscs src/*.js",
"browserify": "browserify -s Validating -o ./dist/js/build.js ./lib/index.js",
const endpoint = 'https://www.gov.uk/bank-holidays.json';
const ul = document.getElementById('holidays')
let bankHolidays;
let england;
fetch(endpoint)
.then(blob => blob.json())
.then(data => handleDates(data));
function handleDates(data) {
bankHolidays = data;
var elementsInsideBody = [...document.body.getElementsByTagName('*')];
// This makes an array of everything inside the body tag
//a function that loops through every single item
function findAndReplace(){
elementsInsideBody.forEach(element =>{
element.childNodes.forEach(child =>{
if(child.nodeType === 3){
replaceText(child);
@nkhil
nkhil / gist:c1a87c28bf44da7ec77fb1e2a33907a2
Created November 2, 2018 20:22 — forked from paulallies/gist:0052fab554b14bbfa3ef
Remove node_modules from git repo
#add 'node_modules' to .gitignore file
git rm -r --cached node_modules
git commit -m 'Remove the now ignored directory node_modules'
git push origin master
rm -rf node_modules && npm install
//ERROR:
//ReferenceError: internalBinding is not defined at fs.js:25:1
// SOLUTION:
// When you update node you need to run rm -rf node_modules && npm install
//to rebuild/reinstall your native modules against your new node version.
@nkhil
nkhil / github.js
Created November 25, 2018 00:29
How to close a repo, work on it and upload it to Github as a different repo
// GitHub: git clone someone else's repository & git push to your own repository
// Create a new repository at github.com. (this is your repository)
// Give it the same name as the other repository.
// Don't initialize it with a README, .gitignore, or license.
// Clone the other repository to your local machine. (if you haven't done so already)
// git clone https://github.com/other-account/other-repository.git
// Rename the local repository's current 'origin' to 'upstream'.
const order = [
{
width: 8,
height: 9,
depth: 7,
},
{
width: 18,
height: 29,
depth: 37,
class Parcel {
constructor(dimensions) {
this.dimensions = dimensions;
this.parcelSize = Parcel.returnParcelSize(dimensions);
this.price = Parcel.calculatePrice(dimensions);
}
static get prices() {
return {