Skip to content

Instantly share code, notes, and snippets.

View coffeepostal's full-sized avatar

Adam Farnsworth coffeepostal

View GitHub Profile
@coffeepostal
coffeepostal / fine-and-remove-node_modules-folder.sh
Created June 17, 2020 19:50
Terminal: Find and Remove node_modules Folders En Masse
# Navigate to parent file of your sites, and run this to list the "node_modules" folders and their sizes
$ find . -name "node_modules" -type d -prune -print | xargs du -chs
# Then run this code to actually delete those "node_modules" folders, you will need to run `npm install` inside each folder you want to reinstall node_modules into
$ find . -name 'node_modules' -type d -prune -print -exec rm -rf '{}' \;
@coffeepostal
coffeepostal / javascript-native-scoll-to-link.js
Created April 1, 2020 18:50
JavaScript: Native Scroll To Link
@coffeepostal
coffeepostal / axios-send-multiple-requests.js
Created March 9, 2020 19:28
AxiosJS: Send Multiple Requests
import axios from 'axios';
let one = "https://api.storyblok.com/v1/cdn/stories/health?version=published&token=wANpEQEsMYGOwLxwXQ76Ggtt"
let two = "https://api.storyblok.com/v1/cdn/datasources/?token=wANpEQEsMYGOwLxwXQ76Ggtt"
let three = "https://api.storyblok.com/v1/cdn/stories/vue?version=published&token=wANpEQEsMYGOwLxwXQ76Ggtt"
axios.all([requestOne, requestTwo, requestThree]).then(axios.spread((...responses) => {
const responseOne = responses[0]
const responseTwo = responses[1]
const responesThree = responses[2]
@coffeepostal
coffeepostal / chrome-devtools-run-jquery-in-console
Created March 7, 2020 22:48
Chrome DevTools: Run jQuery on in the Console
var jqry = document.createElement('script');
jqry.src = "https://code.jquery.com/jquery-3.3.1.min.js";
document.getElementsByTagName('head')[0].appendChild(jqry);
jQuery.noConflict();
@coffeepostal
coffeepostal / .gitattributes
Created February 15, 2020 16:55
GIT: Basic .gitattributes File
*.js eol=lf
*.jsx eol=lf
*.json eol=lf
@coffeepostal
coffeepostal / node-wrte-to-json-file-using-filesystem.js
Last active April 18, 2019 01:13
NODE: Write to JSON File Using FileSystem
///////////////
// index.js: //
///////////////
var fs = require('fs')
fs.readFile('./users.json', 'utf-8', function(err, data) {
if (err) throw err
var arrayOfObjects = JSON.parse(data)
@coffeepostal
coffeepostal / generateFromFakerAndLodash.js
Last active February 16, 2019 19:42
JS: Using Faker and Lodash, Generate a JSON File of People
module.exports = function () {
var faker = require('faker');
var _ = require('lodash');
var numberOfRecords = 100;
return {
people: _.times(numberOfRecords, function (n) {
return {
id: n,
name: faker.name.findName(),
@coffeepostal
coffeepostal / html-default-html5-layout.htm
Last active December 31, 2018 21:17
HTML: Default HTML5 Layout
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Website</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="style/style.css">
</head>
<body>
<?php
$value = 12;
echo 'Text before ',($value > 10 ? 'true' : 'false');
@coffeepostal
coffeepostal / php-covert-sql-date-to-php.php
Created November 10, 2018 17:34
PHP: Convert SQL Date Format to PHP Readable
<?php
$timestamp = strtotime($result->datetime);
echo date("Y-m-d H:i:s", $timestamp);