Skip to content

Instantly share code, notes, and snippets.

View simaovergalho's full-sized avatar

simaovergalho

View GitHub Profile
@simaovergalho
simaovergalho / PHP-normalize_global_path
Last active December 16, 2015 18:58
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"
@simaovergalho
simaovergalho / Javascript-jQuery_replacer
Created May 12, 2013 12:07
Javascript: Stop Using jQuery
<div class="container">
<ul>
<li id="pink">Pink</li>
<li id="salmon">Salmon</li>
<li id="blue">Blue</li>
<li id="green">Green</li>
<li id="red">Red</li>
</ul>
</div>
@simaovergalho
simaovergalho / jQuery-preloadFunction
Last active December 17, 2015 20:48
jQuery: Preload Images, CSS and JS
/*!
* $.preload() function for jQuery – http://mths.be/preload
* Preload images, CSS and JavaScript files without executing them
* Script by Stoyan Stefanov – http://www.phpied.com/preload-cssjavascript-without-execution/
* Slightly rewritten by Mathias Bynens – http://mathiasbynens.be/
* Note that since this script relies on jQuery, the preloading process will not start until jQuery has finished loading.
*/
jQuery.preload = function(array) {
var length = array.length,
@simaovergalho
simaovergalho / JS-rAF.js
Last active December 20, 2015 19:59 — forked from paulirish/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'];
@simaovergalho
simaovergalho / JS-Module_pattern.js
Created January 27, 2014 14:15
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...
@simaovergalho
simaovergalho / disable-emoji-wordpress.php
Last active August 29, 2015 14:24
Disable Emojis on Wordpress
<?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>
@simaovergalho
simaovergalho / private-members.js
Last active August 29, 2015 14:24
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
@simaovergalho
simaovergalho / index.php
Created July 16, 2015 18:48
Add index.php with this to folder to prevent direct folder access or to file to prevent direct file access.
if( ! defined('ABSPATH') ) {
header( 'Status: 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit;
}
//OR
if ( !defined('ABSPATH') ) { die('-1'); }
@simaovergalho
simaovergalho / font_face_helper.css.scss
Last active August 29, 2015 14:25 — forked from eduardojmatos/font_face_helper.css.scss
Sass helper for font-face
@each $font-face in
"MyFont-Regular",
"MyFont-Bold",
"MyFont-Medium" {
@font-face {
font-family: $font-face;
font-style: normal; font-weight: normal;
src: font-url('#{$font-face}.eot');
src: font-url('#{$font-face}.eot?#iefix') format('embedded-opentype'),