Skip to content

Instantly share code, notes, and snippets.

<?php
class Arrays{
/**
* Sample $obj = Users::all();
* @param Object(Eloquent) $obj
* Key usage for assoc with value in the array $data
* @param string $key
* Value usage for fill array $data
* @param string $value
* Enable first element
@fabriziomachado
fabriziomachado / omniauth.rb
Created December 21, 2011 23:18 — forked from dira/omniauth.rb
OmniAuth strategy for a custom provider
# config/initializers/omniauth.rb
module OmniAuth
module Strategies
# tell OmniAuth to load our strategy
autoload :Pixelation, 'lib/pixelation_strategy'
end
end
Rails.application.config.middleware.use OmniAuth::Builder do
provider :twitter, "app_name", "secret"
@fabriziomachado
fabriziomachado / MY_Controller.php
Created December 9, 2011 22:27
application/core/MY_Controller.php
<?php
class MY_Controller extends CI_Controller
{
#public $layout = 'default';
public $title = 'Unesc - Universidade do Extremo Sul Catarinense';
public $css = array('application','libs/blueprint/screen',
'libs/jquery-ui-1.8.16.custom','libs/ui.notify');
public $js = array('libs/modernizr-2.0.6',
'libs/jquery-1.6.2.min', 'libs/jquery-ui-1.8.16.custom.min',
@fabriziomachado
fabriziomachado / server-now-test.js
Created December 8, 2011 09:40
application/servers/spec/server-now-test.js
// division-by-zero-test.js
var vows = require('vows'),
assert = require('assert'),
tobi = require('tobi'),
auth = require('basic-auth')
var suite = vows.describe('Server NowJS')
, now = new Date().getTime()
@fabriziomachado
fabriziomachado / ResizeImageJobSpec.php
Created December 8, 2011 09:37
spec/ResizeImageJobSpec.php
<?php
include_once dirname(__FILE__) . '/spec_helper.php';
include_once APPPATH . '/workers/resize_image_job.php';
require_once 'PHPSpec/Mocks/Functions.php';
use \Mockery as m;
class DescribeResizeImageJob extends \PHPSpec\Context
{
@fabriziomachado
fabriziomachado / package.json
Created December 8, 2011 09:32
application/servers/node_modules/basic-auth/package.json
{
"author": "",
"name": "basi-auth",
"description": "Simple HTTP Basic Authentication",
"version": "0.0.1",
"repository": {
"url": ""
},
"main": "./basic-auth",
"engines": {
@fabriziomachado
fabriziomachado / _notify.php
Created December 8, 2011 09:28
application/views/layout/_notify.php
<!--- container to hold notifications, and default templates --->
<div id="container" style="display:inline">
<div id="sticky">
<a class="ui-notify-close ui-notify-cross" href="#">x</a>
<h1>#{title}</h1>
<p>#{text}</p>
</div>
</div>
@fabriziomachado
fabriziomachado / application.php
Created December 8, 2011 09:28
application/views/layouts/application.php
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="utf-8">
<title>{title_for_layout}</title>
{css_for_layout}
{js_for_layout}
<!--[if lt IE 8]><link rel="stylesheet" href="assets/css/blueprint/ie.css" type="text/css" media="screen, projection"><![endif]-->
</head>
<body>
@fabriziomachado
fabriziomachado / gist:1443363
Created December 7, 2011 16:07
assets/js/application.js
var url = 'http://localhost/codeigniter-academic/assets/images/photos/';
// with NowJs
$(document).ready(function(){
// JQuery notify
$container = $("#container").notify();
//Channel to emit notify
now.notify = function(title, message){
$("#container").notify("create", "sticky", {
@fabriziomachado
fabriziomachado / basic-auth.js
Created December 7, 2011 16:06
application/servers/node_modules/basic-auth/basic-auth.js
// middleware basic authentication
exports.basicAuth = function(req, res, next) {
if (req.headers.authorization && req.headers.authorization.search('Basic ') === 0) {
// Get the username and password
var header = new Buffer(req.headers.authorization.split(' ')[1], 'base64').toString();
header = header.split(":");
var username = header[0];
var password = header[1];
//console.log(request.headers.authorization);