Skip to content

Instantly share code, notes, and snippets.

View dotNetCorePractice.cs
using System;
using System.Collections.Generic;
// test at https://dotnetfiddle.net/
public class Program
{
public static void Main()
{
Console.WriteLine("List practice");
@townivan
townivan / setup.js
Last active Dec 26, 2019
quick gulp4 project setup
View setup.js
npm i gulp -D
npm i browser-sync -D
npm i gulp-sass -D
// favicon fix for index.html
<link rel="icon" href="data:;base64,iVBORw0KGgo=">
touch gulpfile.js
// This gulpfiles expect a 'dist' and 'src' folder (for easy ftp, less easy for github pages)
View ie11-DOM-looping.js
// converting nodelist to an array...for ie11:
// ie11 won't like [...nodelist] or Array.from(nodelist) so use:
let elements = Array.prototype.slice.call(document.querySelectorAll('.things'));
// looping through the array....for ie11:
// ie11 won't like elements.map() so use:
elements.forEach(function(el) {
console.log('el:', el);
});
View destructuring_useful.js
/**
* Be amazed at this use for destructuring
* If you pass args as an obj instead of
* distinct values like f('red','male',23)
* You can use destructuring in the function
* to get what you want without needing to
* figure out which position it should be in!
*/
function f( {name, age} = {}){ // destructure the received {} to name and age.
console.log('age:',age); // age: 23
@townivan
townivan / local-php-on-mac.txt
Created Aug 22, 2019
Run php locally on mac
View local-php-on-mac.txt
php -S 127.0.0.1:8080
@townivan
townivan / find-that-object.js
Created Aug 16, 2019
Get a matching object from an array of objects with a specific value for a property
View find-that-object.js
thingArray.filter(thing => (thing.Name === "Larry"));
@townivan
townivan / .htaccess
Created Jul 15, 2019
htaccess which redirects http://domain, https://domain, http://www.domain to https://www.domain
View .htaccess
# if host contains www - skip redirect to www
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule .? - [S=1]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# redirect all to https
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
@townivan
townivan / gulpfile.esm.js
Created May 31, 2019
Gulp4 gulpfile w/ basic browserSync+sass. This uses es6 modules via the esm package, hence the .esm.js extension
View gulpfile.esm.js
// renames to gulpfile.esm.js to use the esm package support of es6 module 'import' syntax
import gulp from 'gulp';
import sass from 'gulp-sass';
import browserSync from 'browser-sync';
const myGlobs = {
scssSource: './app/scss/**/*.scss', // includes .scss files in any subfolders of ./scss also
cssDest: './app/css',
htmlSource: './app/*.html',
@townivan
townivan / stuff.js
Created Jan 8, 2019
Read all of the .html files in a folder without using a library like glob
View stuff.js
const fs = require('fs');
const targetPath = './src/pages/'
// *.html files
let fileNamesArray = fs.readdirSync(targetPath).filter( (file) => {
return file.includes('.html')
})
// 'all-comps.html', 'c090.html', 'c100.html', 'c101.html', 'c102.html', 'index.html' ]
View favicon-chrome-error-quick-fix.html
<link rel="icon" href="data:;base64,iVBORw0KGgo=">
<!-- credit: https://vsparrow.com/2017/05/01/favicon-ico-failed-to-load-resource-the-server-responded-with-a-status-of-404-not-found/ -->
You can’t perform that action at this time.