Skip to content

Instantly share code, notes, and snippets.

<?php
class CropFoto extends Eloquent {
private $cropper;
private $upload;
private $ratio;
private $scale;
private $config;
@Sigmus
Sigmus / romanos.js
Last active December 24, 2015 00:49
//
// Escolhe qual conversão utilizar dependendo do input
//
function converter(input) {
if (typeof input === 'number') {
return toRoman(input);
}
else {
return toIndu(input);
@Sigmus
Sigmus / slugify.js
Last active February 6, 2016 22:31
Slugify
var slugify = function(text){
/** Cria um nome web-safe sem acentos e espaços a partir de um nome. */
var lettersFrom = 'áàãâäéèêëíìîïóòõôöúùûüçñ', lettersTo = 'aaaaaeeeeiiiiooooouuuucn', newText = '', text = text.toLowerCase().replace(' ', '-');
for (var i = 0; i < text.length; i++) {
if (lettersFrom.search(text.substr(i,1)) >= 0) newText += lettersTo.substr(lettersFrom.search(text.substr(i, 1)), 1);
else newText += text.substr(i, 1);
}
return newText;
};
@Sigmus
Sigmus / gulpfile.js
Created December 29, 2013 14:37
Migrating some configuration from Gruntfile.js to gulpfile.js
var gulp = require('gulp');
var browserify = require('gulp-browserify');
var less = require('gulp-less');
var concat = require('gulp-concat');
var jshint = require('gulp-jshint');
var outDir = null;
var sources = {
scripts: './app/scripts/**/*.js',
@Sigmus
Sigmus / events.js
Created January 30, 2014 18:11
A simple event repository. (bugged)
var Events = {
registry: {},
nameExists: function(name) {
return typeof this.registry[name] !== 'undefined';
},
on: function(name, callback) {
if ( ! this.nameExists(name)) {
@Sigmus
Sigmus / laravel.md
Last active August 29, 2015 13:56
Guia instalação Laravel 4.1

Instalando Laravel 4.1

Requisitos mínimos

  • PHP >= 5.3.7
  • MCrypt PHP Extension
  • MySQL 5 com PDO_MYSQL
  • Composer (package manager)
@Sigmus
Sigmus / next.js
Created February 7, 2014 15:15
Returns next array item. Circular.
var nextArrayItem = function(arr) {
var len = arr.length;
return function(current) {
var currentIndex = arr.indexOf(current);
return currentIndex + 1 === len
? arr[0] : arr[currentIndex + 1]
};
}
var nextStatus = nextArrayItem(['fred', 'angela', 'mark']);
@Sigmus
Sigmus / ispropequal.js
Created February 9, 2014 23:17
is property equal
var isPropEqual = function(propName) {
return function(subject) {
return function(obj) {
return obj[propName] === subject;
};
}
};
var isStatus = isPropEqual('status');
@Sigmus
Sigmus / gulpfile.js
Last active November 15, 2017 11:55
gulpfile.js with browserify, reactify, watchify and gulp-notify.
var source = require('vinyl-source-stream');
var gulp = require('gulp');
var gutil = require('gulp-util');
var browserify = require('browserify');
var reactify = require('reactify');
var watchify = require('watchify');
var notify = require("gulp-notify");
var scriptsDir = './scripts';
var buildDir = './build';
@Sigmus
Sigmus / laravel-4.1.md
Created May 21, 2014 19:13
Instalando Laravel 4.1 sem composer

Requisitos mínimos

  • mod_rewrite do Apache
  • PHP >= 5.3.7
  • MCrypt PHP Extension
  • MySQL 5 com PDO_MYSQL

Passos