Skip to content

Instantly share code, notes, and snippets.

View Narayon's full-sized avatar
🛠️

Rui Barbosa Narayon

🛠️
View GitHub Profile
@Narayon
Narayon / index.php
Last active April 8, 2018 01:52 — forked from simaovergalho/index.php
PHP: prevent direct folder/file access
if( ! defined('ABSPATH') ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit;
}
//OR
if ( ! defined('ABSPATH') ) { die('-1'); }
<?php
/**
* Disable Emojis
*
* @package Package
* @subpackage Package/SubPackage
* @copyright Copyright (c) 2014, Your Name
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
* @since 0.0.1
* @author Your Name <email@domain.com>
@Narayon
Narayon / JS-rAF.js
Last active April 8, 2018 01:52 — forked from simaovergalho/JS-rAF.js
Javascript: Request Animation Frame
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
@Narayon
Narayon / JS-Module_pattern.js
Last active April 8, 2018 01:52 — forked from simaovergalho/JS-Module_pattern.js
Javascript: Module Pattern
var UTIL = (function (parent, $) {
var my = parent.ajax = parent.ajax || {};
my.get = function (url, params, callback) {
// ok, so I'm cheating a bit :)
return $.getJSON(url, params, callback);
};
// etc...
@Narayon
Narayon / private-members.js
Last active April 8, 2018 01:52 — forked from simaovergalho/private-members.js
Javascript: Embed Private Members Into an Object
//reference to: http://code.tutsplus.com/tutorials/javascript-how-to-embed-private-members-into-an-object--cms-24287
var createProperty = function (obj, prop) {
var currentValue = obj[prop];
Object.defineProperty(obj, prop, {
get: function () { return currentValue; },
set: function (value) {
currentValue = value;
},
enumerable: true,
configurable: true
@Narayon
Narayon / block-scroll.css
Last active April 8, 2018 01:53 — forked from davidgilbertson/block-scroll.css
Don't resize the body when you open a modal
/* the page should not change width as content is loaded */
body {
overflow-y: scroll;
}
/* block scrolling without losing the scroll bar and shifting the page */
/* add this class when a modal is open */
body.block-scroll {
overflow: hidden;
overflow-y: scroll !important;
@Narayon
Narayon / gulpfile.js
Created August 25, 2016 10:05 — forked from jadsalhani/gulpfile.js
Ionic Tutorial
var gulp = require('gulp');
var gutil = require('gulp-util');
var bower = require('bower');
var concat = require('gulp-concat');
var sass = require('gulp-sass');
var minifyCss = require('gulp-minify-css');
var rename = require('gulp-rename');
var sh = require('shelljs');
var uglify = require('gulp-uglify');
var mainBowerFiles = require('main-bower-files');
@Narayon
Narayon / vagrant-scp
Last active April 8, 2018 01:53 — forked from geedew/vagrant-scp
Copying files from and to a Vagrant VM
#!/bin/sh
# Change these settings to match what you are wanting to do
FILE=/File/To/Copy
PATH=/Where/To/Put/File
OPTIONS=`vagrant ssh-config | grep -v '^Host ' | awk -v ORS=' ' 'NF{print "-o " $1 "=" $2}'`
# copy from host to vagrant
# scp ${OPTIONS} $FILE v:$PATH
@Narayon
Narayon / gist:6c56a8591c7cbb2454ab
Last active April 8, 2018 02:52 — forked from jameskoster/functions.php
WooCommerce: dequeue css (2.1+)
// Remove each style one by one
add_filter( 'woocommerce_enqueue_styles', 'jk_dequeue_styles' );
function jk_dequeue_styles( $enqueue_styles ) {
unset( $enqueue_styles['woocommerce-general'] ); // Remove the gloss
unset( $enqueue_styles['woocommerce-layout'] ); // Remove the layout
unset( $enqueue_styles['woocommerce-smallscreen'] ); // Remove the smallscreen optimisation
return $enqueue_styles;
}
// Or just remove them all in one line
@Narayon
Narayon / PHP-normalize_global_path
Last active April 8, 2018 02:52 — forked from simaovergalho/PHP-normalize_global_path
PHP: global vars for normalizing the ROOT and HTTP paths of the app.
<?php
// a.php: assuming this included everywhere at very first line
// and located in root directory
// preferable, define a constant instead of variable, cos it
// may used in functions directly without "global $ROOT";
// to use for "include"
define('ROOT', __DIR__); // for PHP >= 5.3
define('ROOT', realpath(dirname(__FILE__))); // for PHP < 5.3
// to use for "src,href"