Skip to content

Instantly share code, notes, and snippets.

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

Josh che-wf

👨‍💻
Working
View GitHub Profile
@che-wf
che-wf / ngEnter.js
Created May 25, 2015 20:42
ngEnter
/* Directive for Hitting Enter for Search */
function ngEnter() {
return function (scope, element, attrs) {
element.bind("keydown keypress", function (event) {
if (event.which === 13) {
scope.$apply(function () {
scope.$eval(attrs.ngEnter);
});
event.preventDefault();
}
@che-wf
che-wf / index.html
Created August 20, 2015 04:49
Convert Time from Argentine Time to Local Time
<html>
<head>
<title>Convert Time from Argentine Time to Local Time</title>
</head>
<body>
<span id="time"></span>
<script>
function toLocalTime(time) {
var splitTime = time.split(':');
var currDate = new Date();
@che-wf
che-wf / flipCounterCountingUp.js
Last active April 22, 2016 13:35
Flip Counter Counting Up
var startD = new Date("April 7, 2015")/3600;
var currD = new Date()/3600;
var diffD = Math.abs(currD - startD);
var time = Math.ceil(diffD)+10000;
var clock = $('.flip-counter').FlipClock(time, {
clockFace: 'Counter'
});
setTimeout(function() {
@che-wf
che-wf / superscriptAllTheThings.js
Last active April 22, 2016 13:35
Superscript all Trademark, Registered, and Copyright scripts (unless already superscripted)
$('body :not(script,sup)').contents().filter(function() {
return this.nodeType === 3;
}).replaceWith(function() {
return this.nodeValue.replace(/[™®©]/g, '$&');
});
@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');
}
@che-wf
che-wf / ngFindDupes.js
Last active July 22, 2016 17:11
Angular Find Duplicates in Array
Array.prototype.findDupes = function () {
return this.reduce(function (accum, current) {
if (angular.lowercase(accum).indexOf(
angular.lowercase(current)) < 0) {
accum.push(angular.lowercase(current));
}
return accum;
}, []);
};
@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 / 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