Skip to content

Instantly share code, notes, and snippets.

View ricardoriogo's full-sized avatar

Ricardo Riogo ricardoriogo

View GitHub Profile
/*
Copyright 2011 Martin Hawksey
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
(function(){
var timeout;
var isHidden = false;
document.addEventListener("mousemove", function() {
if (timeout) {
clearTimeout(timeout);
}
timeout = setTimeout(function() {
@ricardoriogo
ricardoriogo / glob.js
Last active December 6, 2015 15:32
Little file to create a autoimport SASS files.
var glob = require("glob"),
fs = require('fs'),
contents = '',
prefix = 'app/',
importFile = '_app-import.scss';
glob(prefix + "*/**/*.scss", function (er, files) {
for(file in files){
contents += "@import '" + files[file].replace(prefix, '') +"'; \n";
}
@ricardoriogo
ricardoriogo / strpad.js
Created June 29, 2015 17:02
Pad string
function pad(n, width, z) {
z = z || '0';
n = n + '';
return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
}
@ricardoriogo
ricardoriogo / LaravelModules.md
Last active July 19, 2016 10:20
Laravel Modules #laravel

Laravel Modules

Add app/modules to classmap autoload on composer.json.

Example of ServiceProvider for Product Module on app/modules/product.

<?php namespace App\Modules\Product;
 
<?php
/**
* Create a web friendly URL slug from a string.
*
* Although supported, transliteration is discouraged because
* 1) most web browsers support UTF-8 characters in URLs
* 2) transliteration causes a loss of information
*
* @author Sean Murphy <[email protected]>
* @copyright Copyright 2012 Sean Murphy. All rights reserved.
@ricardoriogo
ricardoriogo / jquery.placeholder-fallback.js
Created August 31, 2014 00:52
jQuery placeholder fallback
/**
* jQuery placeholder fallback
*/
$(document).ready(function() {
if ( !("placeholder" in document.createElement("input")) ) {
$("input[placeholder], textarea[placeholder]").each(function() {
var val = $(this).attr("placeholder");
if ( this.value == "" ) {
this.value = val;
@ricardoriogo
ricardoriogo / gist:5b4fcd3c4b65ef0cae2c
Last active August 29, 2015 14:01
Camelize and Decamelize
<?php
function decamelize($word) {
$word = preg_replace_callback (
'/([A-Z])/',
function($matches){
return strtolower('_' . $matches[0]);
},
$word
);
@ricardoriogo
ricardoriogo / convertPolyToPath.js
Created April 14, 2014 16:13
Convert SVG polygon element to path element.
var polys = document.querySelectorAll('polygon,polyline');
[].forEach.call(polys,convertPolyToPath);
function convertPolyToPath(poly){
var svgNS = poly.ownerSVGElement.namespaceURI;
var path = document.createElementNS(svgNS,'path');
var points = poly.getAttribute('points').split(/\s+|,/);
var x0=points.shift(), y0=points.shift();
var pathdata = 'M'+x0+','+y0+'L'+points.join(' ');
if (poly.tagName=='polygon') pathdata+='z';
@echo off
:: BatchGotAdmin
:-------------------------------------
REM --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...