Skip to content

Instantly share code, notes, and snippets.

#Node - File Paths

##File Paths Node has a path module which can be used to manipulate paths.

###Normalizing Paths Paths can be stored in different ways and it is neccessary to ensure that the path is standardized.

var path = require('path');
path.normalize('/foo/bar//baz/asdf/quux/..');
@dgrammatiko
dgrammatiko / my.cnf
Created July 15, 2017 18:37 — forked from fevangelou/my.cnf
Optimized MySQL configuration for cPanel servers (updated July 2017)
# Optimized MySQL configuration for cPanel servers by Fotis Evangelou - Updated July 2017
#
# The settings provided below are a starting point for a 4GB - 8GB RAM server with 4 CPU cores.
# If you have less or more resources available you should adjust accordingly to save CPU,
# RAM and disk I/O usage.
# The settings marked with a specific comment or the word "UPD" after the value
# should be adjusted for your system by using MySQL DB diagnostics tools like:
# http://mysqltuner.com/
# or
# https://launchpad.net/mysql-tuning-primer (supports MySQL up to v5.6)
@dgrammatiko
dgrammatiko / css-supports.js
Created May 22, 2017 17:37 — forked from codler/css-supports.js
CSS.supports() Polyfill
/*! CSS.supports() Polyfill
* https://gist.github.com/codler/03a0995195aa2859465f
* Copyright (c) 2014 Han Lin Yap http://yap.nu; MIT license */
if (!('CSS' in window)) {
window.CSS = {};
}
if (!('supports' in window.CSS)) {
window.CSS._cacheSupports = {};
window.CSS.supports = function(propertyName, value) {
var initCalendar = function()
{
var id = $(this).attr('id');
var btnId = id + "_btn";
$(btnId).setAttr('data-dayformat', "%Y-%m-%d");
$(btnId).setAttr('data-firstday', 1);
JoomlaCalendar.init( $(this).parent('.field-calendar')[0] );
@dgrammatiko
dgrammatiko / ultimate-ut-cheat-sheet.md
Created March 16, 2017 04:27 — forked from yoavniran/ultimate-ut-cheat-sheet.md
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai and Sinon

The Ultimate Unit Testing Cheat-sheet

For Mocha, Chai and Sinon

using mocha/chai/sinon for node.js unit-tests? check out my utility: mocha-stirrer to easily reuse test components and mock require dependencies


@dgrammatiko
dgrammatiko / fiddle.css
Created October 14, 2016 18:46 — forked from scopevale/fiddle.css
jsFiddle demo - Table Sort (vanilla JS)
table {
border: solid 1px #fc0;
border-collapse: collapse;
}
table caption {
font-weight: bold;
font-size: 125%;
text-transform: uppercase;
}
@dgrammatiko
dgrammatiko / osx-for-hackers.sh
Created August 22, 2016 11:09 — forked from brandonb927/osx-for-hackers.sh
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned. Also, please don't email me about this script, my poor inbox...
#!/bin/sh
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
@dgrammatiko
dgrammatiko / fix.sh
Created August 18, 2016 16:21 — forked from kopiro/fix.sh
Solve `/dev/tty/ bug in Tower / GIT UI when signing commits with GPG
echo 'no-tty' >> ~/.gnupg/gpg.conf
<!DOCTYPE html>
<!-- This is the shortest Image Uploader ever :)
And you can even make it shorter if you don't
want all the drag'n drop thing. -->
<!--
AUTHOR: @paulrouget <paul@mozilla.com>
LICENSE:
(function() {
var CSSCriticalPath = function(w, d, opts) {
var opt = opts || {};
var css = {};
var pushCSS = function(r) {
if(!!css[r.selectorText] === false) css[r.selectorText] = {};
var styles = r.style.cssText.split(/;(?![A-Za-z0-9])/);
for(var i = 0; i < styles.length; i++) {
if(!!styles[i] === false) continue;
var pair = styles[i].split(": ");