This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Pythagorean() {} | |
Pythagorean.prototype.calculate = function(obj) { | |
if (Object.keys(obj).length > 3 ) { | |
throw 'This function accepts object with maximum of 3 properties'; | |
} | |
if ( typeof obj.c === 'object' ) { | |
return Math.sqrt(Math.pow(obj.a,2) + Math.pow(obj.b,2)); | |
} | |
else { | |
if ( obj.c <= obj.a || obj.c <= obj.b ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hostname = "localhost.dev" | |
boxname = "VBlocalhost" | |
server_ip = "192.168.22.10" | |
server_cpus = "1" | |
server_memory = "512" # in MB | |
Vagrant.configure("2") do |config| | |
config.vm.box = "ubuntu/trusty64" | |
config.vm.hostname = hostname | |
config.vm.network :private_network, ip: server_ip |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# DigitalOcean Ubuntu Droplet | |
# Random things I encountered when working | |
# with DigitalOcean's Ubuntu VM Instance | |
# and some one liners like... | |
# Restart Server | |
sudo shutdown -r now | |
# Update Individual Package |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function(e, t) { | |
function l(e, n, r) { | |
if (r === t && e.nodeType === 1) { | |
var i = "data-" + n.replace(f, "$1-$2").toLowerCase(); | |
r = e.getAttribute(i); | |
if (typeof r == "string") { | |
try { | |
r = r === "true" ? !0 : r === "false" ? !1 : r === "null" ? null : s.isNaN(r) ? a.test(r) ? s.parseJSON(r) : r : parseFloat(r) | |
} catch (o) {} | |
s.data(e, n, r) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
if ( 'serviceWorker' in navigator ) { | |
navigator.serviceWorker.register('/service-worker.js', { scope: '/' }) | |
.then(function(registration) { | |
console.log("Service Worker Registered"); | |
}); | |
navigator.serviceWorker.ready.then(function(registration) { | |
console.log("Service Worker Ready"); | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Check to see if .webp image is supported in the browser | |
# Serve .webp image, if avaiable, instead of .jpeg / .png | |
location / { | |
if ( $http_accept ~ "image/webp" ) { | |
rewrite (.+)\.(jpe?g|png)$ /$1.webp; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* -------------------------------------------------------- | |
* Gets the id of the topmost ancestor of the current page. | |
* Returns the current page's id if there is no parent. | |
* @uses Object $post | |
* @return Int | |
* -------------------------------------------------------- | |
*/ | |
function get_post_top_ancestor_id () { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'init', 'block_access_to_wp_dashboard_init' ); | |
/** | |
* | |
*/ | |
function block_access_to_wp_dashboard_init() { | |
if ( is_admin() && ! current_user_can( 'edit_users' ) && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { | |
wp_redirect( home_url() ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ---------------------------------------------------------------------- | |
# | Application Redirects | |
# ---------------------------------------------------------------------- | |
Redirect 301 /old http://www.example.com/new | |
# ---------------------------------------------------------------------- | |
# | Cross-origin images | |
# ---------------------------------------------------------------------- | |
<IfModule mod_setenvif.c> | |
<IfModule mod_headers.c> |