Skip to content

Instantly share code, notes, and snippets.

View alexsandro-xpt's full-sized avatar

Alexsandro Souza Pereira alexsandro-xpt

View GitHub Profile
@duncansmart
duncansmart / progressive-ace.htm
Created March 28, 2013 23:29
Integrating ACE Editor in a progressive way
<textarea name="my-xml-editor" data-editor="xml" rows="15"></textarea>
...
<textarea name="my-markdown-editor" data-editor="markdown" rows="15"></textarea>
...
<script src="//d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js"></script>
<script>
// Hook up ACE editor to all textareas with data-editor attribute
$(function () {
/*****************************************************************************
* __ __ _ _ ___ _
* \ \/ _\ /\/\ (_)_ __ | |_ _ _ / __\ __ ___ ___| |__
* \ \ \ / \| | '_ \| __| | | | / _\| '__/ _ \/ __| '_ \
* /\_/ /\ \ / /\/\ \ | | | | |_| |_| | / / | | | __/\__ \ | | |
* \___/\__/ \/ \/_|_| |_|\__|\__, | \/ |_| \___||___/_| |_|
* |___/
*
* Identifying and Eliminating Code Smells
*
@netojoaobatista
netojoaobatista / php.doc.sh
Created February 19, 2013 22:03
Simple RSS2JSON using XSLT
#!/bin/sh
curl -s "http://news.php.net/group.php?group=php.doc&format=rss" |xsltproc rss2json.xsl /dev/stdin |json_reformat
@netojoaobatista
netojoaobatista / Colleague.php
Created February 13, 2013 14:51
Simulação dos grupos do Facebook utilizando Mediator
<?php
class Colleague extends Hashed
{
private $name;
public function __construct($name)
{
$this->name = $name;
}
@netojoaobatista
netojoaobatista / BusinessDaysTest.php
Created September 27, 2012 23:10
Algorítimo idiota (e caro) para cálculo de dias úteis entre duas datas.
<?php
require_once 'PHPUnit/Framework/TestCase.php';
require_once 'businessDays.php';
/**
* businessDays() test case.
*/
class BusinessDaysTest extends PHPUnit_Framework_TestCase {
protected function setUp() {
parent::setUp();
@vquaiato
vquaiato / facebook_csharp_sdk_shit.js
Created September 19, 2012 01:14
Facebook C# SDK, RLY?
// Do a post to the server to finish the logon
// This is a form post since we don't want to use AJAX
var form = document.createElement("form");
form.setAttribute("method", 'post');
form.setAttribute("action", '/FacebookLogin.ashx');
var field = document.createElement("input");
field.setAttribute("type", "hidden");
field.setAttribute("name", 'accessToken');
field.setAttribute("value", accessToken);
@netojoaobatista
netojoaobatista / lsp.php
Created September 14, 2012 04:39
LSP - Barbara Liskov substitution principle
<?php
class Rectangle {
private $width;
private $height;
public function getWidth() {
return $this->width;
}
public function getHeight() {
@cowboy
cowboy / abstraction-lite.js
Created August 31, 2012 20:57
Abstraction.js "Lite" (live-coded at BrazilJS 2012)
/*
* Abstraction.js "Lite"
*
* Copyright (c) 2012 "Cowboy" Ben Alman
* Licensed under the MIT license.
* http://benalman.com/about/license/
*/
var $elseif, $else;
var $if = function(state) {
@netojoaobatista
netojoaobatista / Array.range.js
Created August 2, 2012 17:29
ECMAScript 5 implementation of Python's range function
/**
* ECMAScript 5 implementation of Python's range function.
* @see {@link http://docs.python.org/release/1.5.1p1/tut/range.html}
* @param {Number} start
* @param {Number} end
* @param {Number} step
* @param {Boolean} includeEndpoint
* @return {Array}
*/
Object.defineProperty(Array, "range", {