Skip to content

Instantly share code, notes, and snippets.

@Sigmus
Sigmus / slug.php
Created July 10, 2014 14:23
PHP slug function
<?php
// Extracted from the Laravel Framework (http://laravel.com)
function toSlug($title, $separator = '-', $to_lower = true) {
// Convert all dashes/underscores into separator
$flip = $separator == '-' ? '_' : '-';
$title = preg_replace('!['.preg_quote($flip).']+!u', $separator, $title);
#!/bin/bash
while [ 1 ]
do
if [ $(networksetup -getinfo Wi-Fi | grep -c 'IP address:') = '1' ]
then $(networksetup -setairportnetwork en1 DigitalBox q2w3e4r5)
fi
sleep 3
done
@Sigmus
Sigmus / install.sh
Created June 30, 2014 13:39
Install Composer and Envoy
# You can run the following commands from any directory.
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composerecho 'alias composer="/usr/local/bin/composer.phar"' >> ~/.bash_profile
composer global require "laravel/envoy=~1.0"
echo 'alias envoy=".composer/vendor/laravel/envoy/envoy"' >> ~/.bash_profile
@Sigmus
Sigmus / diag.php
Created May 21, 2014 19:14
Diagnósticos do projeto em PHP
<?php
// Altere as configurações
$config = array(
'version' => '5.3.7',
'max_size' => '10M',
'dir' => 'exemplo_escrita',
'database' => array(
'host' => 'localhost',
@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

@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 / 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 / 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 / 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 / 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)) {