Skip to content

Instantly share code, notes, and snippets.

@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 / 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
#!/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 / 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);
@Sigmus
Sigmus / youtube_extract.php
Created July 11, 2014 13:41
PHP Regex to get youtube video ID
<?php
/*
* From: http://stackoverflow.com/questions/3392993/php-regex-to-get-youtube-video-id
*/
$url = "http://www.youtube.com/watch?v=C4kxS1ksqtw&feature=relate";
parse_str( parse_url( $url, PHP_URL_QUERY ), $my_array_of_vars );
echo $my_array_of_vars['v'];
// Output: C4kxS1ksqtw
@Sigmus
Sigmus / example.js
Created July 12, 2014 16:10
A React Google Maps Component
var GmapComponent = require('./google-maps-component');
var component = GmapComponent({
lat: -23.5348644, lng: -46.6718231
});
var node = document.getElementById('main');
React.renderComponent(component, node);
@Sigmus
Sigmus / replace-parent.js
Created July 21, 2014 21:36
A small module that replaces it's parent element content with the provided html.
var _ = require('lodash');
module.exports = _.curry(replaceParent, 2);
function replaceParent(element, html) {
var parent = element.parentNode;
parent.innerHTML = html;
@Sigmus
Sigmus / collection+json.json
Created July 23, 2014 03:20
Collection+JSON document
{
"collection": {
"version": "1.0",
"href": "http://www.youtypeitwepostit.com/api/",
"items": [
{
"href": "/api/messages/21818525390699506",
"data": [
{
"name": "text",
<?php
class Scorer {
private $canonical;
private $game;
public function __construct($game)
{
<?php
class Krudder {
public static function add($route, $modelName)
{
App::bind("Krudder$route", function() use($route, $modelName)
{
return new KrudderController($route, $modelName);
});