Skip to content

Instantly share code, notes, and snippets.

View ricardoriogo's full-sized avatar

Ricardo Riogo ricardoriogo

View GitHub Profile
@ricardoriogo
ricardoriogo / gsync.bat
Last active April 7, 2017 00:10
Script para abrir mais de uma instância do Google Drive (Windows) e sincronizar múltiplas contas. Lembrando que neste caso a pasta do Google Drive está na variável PATH do sistema.
@ECHO OFF
SET [email protected]
SET USERPROFILE=%~dp0%USERNAME%
MD "%USERPROFILE%\AppData\Roaming">nul
MD "%USERPROFILE%\AppData\Local\Application Data">nul
MD "%USERPROFILE%\Application Data">nul
MD "%USERPROFILE%\Local Settings\Application Data">nul
MD "%USERPROFILE%\My Documents">nul
MD "%USERPROFILE%\Documents">nul
START googledrivesync
@ricardoriogo
ricardoriogo / apsite.bat
Last active January 1, 2016 19:39
Cria um novo arquivo de configuração VHOST do Apache.
@ECHO OFF
SET appath=D:\xampp\apache\conf\sites\
SET /p dominio=Indique o dom¡nio ^*.dev a ser usado:
SET /p folder=Digite o caminho ROOT ou tecle ENTER para usar a pasta atual:
SET /p group=Digite o nome do grupo ao qual este dominio pertence:
IF "%folder%" == "" SET folder=%~dp0
IF NOT "%group%" == "" SET group=%group%\
@ricardoriogo
ricardoriogo / Gruntfile.js
Created January 4, 2014 16:37
Grunt base files.
module.exports = function(grunt) {
// Load all grunt tasks
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
less: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
@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...
@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';
@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 / 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;
<?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 / 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;
 
@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;
}