Skip to content

Instantly share code, notes, and snippets.

View coffeepostal's full-sized avatar

Adam Farnsworth coffeepostal

View GitHub Profile
@coffeepostal
coffeepostal / css-striped-bg.css
Created November 10, 2018 17:27
CSS: Striped Background Using Repeating Linear Gradient
background: repeating-linear-gradient(
45deg,
#606dbc,
#606dbc 10px,
#465298 10px,
#465298 20px
);
@coffeepostal
coffeepostal / sql-selecting-day-week-and-last-week.sql
Last active November 10, 2018 17:32
SQL: Selecting Records from Today, the Current Week, and Last Week
/* Today */
SELECT * FROM ('table') WHERE date = CURDATE()
/* Current Week */
SELECT * price FROM ('table') WHERE YEARWEEK('date') = YEARWEEK(CURDATE())
/* Last Week */
SELECT * FROM ('table') WHERE YEARWEEK('date') = YEARWEEK( CURDATE( ) + INTERVAL 1 WEEK ) LIMIT 0 , 30
@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);
<?php
$value = 12;
echo 'Text before ',($value > 10 ? 'true' : 'false');
@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>
@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 / 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 / .gitattributes
Created February 15, 2020 16:55
GIT: Basic .gitattributes File
*.js eol=lf
*.jsx eol=lf
*.json eol=lf
@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 / 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]