Skip to content

Instantly share code, notes, and snippets.

View che-wf's full-sized avatar
👨‍💻
Working

Josh che-wf

👨‍💻
Working
View GitHub Profile
// Use this file as a starting point for your project's .eslintrc.
// Copy this file, and add rule overrides as needed.
{
"env": {
"node": true,
"es6": true
},
"rules": {
"array-bracket-spacing": [2, "never"],
"block-scoped-var": 2,
@che-wf
che-wf / .eslintrc
Created May 23, 2017 03:31
Personal ESLint File
// Use this file as a starting point for your project's .eslintrc.
// Copy this file, and add rule overrides as needed.
{
"env": {
"node": true,
"es6": true
},
"rules": {
"array-bracket-spacing": [2, "never"],
"block-scoped-var": 2,
@che-wf
che-wf / dry-picture-element-media-queries
Created April 4, 2017 20:56 — forked from bjankord/dry-picture-element-media-queries
DRY Picture element media queries
<?php
// Define picture element media query values here
$m_mqs = 'min-width:321px';
$l_mqs = 'min-width:641px';
$xl_mqs = 'min-width:1281px';
?>
<picture alt="Alt tag describing the image represented">
<source src="photo-s.jpg"/>
<source src="photo-m.jpg" media="<?php ehco $m_mqs; ?>"/>
@che-wf
che-wf / elementsLargerThanWindow.js
Created January 19, 2017 23:00
This is just a snippet that I run in console to find all elements larger than the windows width.
$("*").each(function() {
if ($(this).width() > $(window).width()) {
console.log(this);
}
});
@che-wf
che-wf / fix-wordpress-permissions.sh
Last active February 8, 2017 20:08 — forked from Adirael/fix-wordpress-permissions.sh
Fix wordpress file permissions
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro <mike [at] conigliaro [dot] org>
#
WP_OWNER=www-data # <-- wordpress owner
WP_GROUP=www-data # <-- wordpress group
WP_ROOT=$1 # <-- wordpress root directory
@che-wf
che-wf / rateLimiter.js
Last active February 22, 2017 18:28
If you need to performa a function, wait, and perform it again, here's a nice loop to help with that.
function rateLimiter(thisArray, callback) {
var count = 0, // Loop count
rateNum = 10, // Items per loop
rateTime = 5000, // Time between loops
items = []; // Temp array
var batches = thisArray.length / rateNum;
function splitArray() {
items = thisArray.splice(0, rateNum);
console.log('batch ' + (count + 1) + ' out of ' + batches);
@che-wf
che-wf / text-justifications.scss
Created August 24, 2016 18:35
For those who come from a designer background, these basic mixins will provide you with the various types of justification that you're used to.
@mixin center-justified {
text-align-last: center;
text-align: justify;
}
@mixin left-justified {
text-align-last: left;
text-align: justify;
}
@mixin right-justified {
text-align-last: right;
@che-wf
che-wf / findeDupes.js
Created July 22, 2016 17:39
This is an efficient approach to finding duplicates in an array or eliminating duplicates from an array.
var a = ["a","a","b","c","c"];
var dupes = a.filter((value,index,self)=>{ return (self.indexOf(value) !== index )});
var cleanArray = a.filter((value,index,self)=>{ return (self.indexOf(value) === index )});
console.log(dupes);
console.log(cleanArray);
@che-wf
che-wf / recursiveSetTimeout.js
Created July 22, 2016 16:55
If you're ever needing to run a loop and break for a set period of time before continuing a loop, this should help do that
var myArr = [],
count = 0,
batches = 0,
newArr = [];
for (var i = 0; i < 103; i++) {
myArr.push(i);
if (myArr.length > 9) {
batches = Math.ceil(myArr.length / 10);
}
@che-wf
che-wf / functions.php
Created June 14, 2016 19:01
Kill RSS Feed on Staging for WordPress
...
/**
** Disables RSS for staging
**/
function disable_rss() {
return null;
}
if($_SERVER["HTTP_HOST"] == "[staging server address]"){
add_filter('default_feed', 'disable_rss');
}