Skip to content

Instantly share code, notes, and snippets.

View bitforth's full-sized avatar

Alan Chavez bitforth

View GitHub Profile
@bitforth
bitforth / .profile
Created July 29, 2018 17:55
my .profile
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
export PATH=$PATH:/Users/az/Library/Android/sdk/platform-tools/
export PS1="\[\033[36m\]\u\[\033[32m\]\[\033[97m\]@\[\033[32m\]\h:\[\033[93m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\]$ "
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
@bitforth
bitforth / .eslintrc
Created September 10, 2017 16:53
ESLint configuration file
{
"parserOptions": {
"ecmaVersion": 6,
"ecmaFeatures": {
"experimentalObjectRestSpread": true
}
},
"rules": {
"no-alert": "off",
"no-array-constructor": "off",
@bitforth
bitforth / sitelocking.as
Created December 19, 2013 23:41
Sitelocking en Flash AS3
var dominioValido:String = "alanchavez.com";
var dominioQueCarga:String = this.root.loaderInfo.url.split("/")[2];
trace("Ubicacion de la película=" + dominioQueCarga);
if (dominioQueCarga.indexOf(dominioValido) != (dominioQueCarga.length - dominioValido.length)) {
dominioNoPermitido();
}
function dominioNoPermitido():void {
trace("Hola estimado visitante. Permiteme informarte que yo, el administrador de "+dominioQueCarga+" soy un rata cola larga, y esta película fue especialmente programada para ser visualizada en "+dominioValido+" y en unos momentos seras redireccionado a la página del autor original. Gracias");
navigateToURL(new URLRequest("http://www.alanchavez.com"),'newwindow');
@bitforth
bitforth / cliente.php
Last active December 31, 2015 11:29
Cliente de la Factory en PHP
<?php
$camioneta = CarrosFactory::crearCarro(MOTOR::DIESEL, 8);
$sedan = CarrosFactory::crearCarro(MOTOR::GASOLINA, 4);
$autobus = CarrosFactory::crearCarro(MOTOR::DIESEL, 8);
$hibrido = CarrosFactory::crearCarro(MOTOR::BIODIESEL, 4);
$camioneta->enciende();
$sedan->enciende();
$autobus->enciende();
$hibrido->enciende();
@bitforth
bitforth / InyeccionDependenciasProblemas.php
Created December 15, 2013 23:36
Inyeccion de dependencias en PHP. Los objetos "carro" comparten el mismo motor, por lo cual el motor solamente se puede encender una vez
<?php
class Motor {
private $prendido;
public function __construct() {}
public function arranca() {
if(!$this->prendido) {
echo "run run run run...";
$this->prendido = true;
} else {
throw new Exception("Ehh!! Ya estoy prendido me vas a descomponer!!");
@bitforth
bitforth / CarrosFactory.php
Last active December 31, 2015 11:29
Implementacion de Factory en PHP
<?php
class CarrosFactory {
public function __construct();
public static function crearCarro($tipoMotor, $cilindros) {
switch($tipoMotor) {
case MOTOR::DIESEL:
return new CarroDiesel($cilindros);
break;
case MOTOR::GASOLINA:
return new CarroGasolina($cilindros);
@bitforth
bitforth / ProductosConcretos.php
Created December 15, 2013 23:44
Clases concretas para los Productos en PHP
<?php
class MotorDiesel extends Motor {
public function __construct($cilindros) {
$this->cilindros = $cilindros;
}
}
class MotorGasolina extends Motor {
public function __construct($cilindros) {
$this->cilindros = $cilindros;
@bitforth
bitforth / Productos.php
Created December 15, 2013 23:43
Los productos de las Factory en PHP
<?php
abstract class Motor {
const DIESEL = 0;
const GASOLINA = 1;
const BIODIESEL = 2;
protected $encendido = false;
protected $cilindros;
public function enciende() {
@bitforth
bitforth / InyectaDependencias.php
Last active December 31, 2015 07:19
Ejemplo de inyeccion de dependencias en PHP
<?php
class Motor {
public function __construct(){}
public function arranca() {
return "run run run run...";
}
}
class MotorDiesel extends Motor {
public function __construct() {}
}
@bitforth
bitforth / Carro.php
Created December 13, 2013 23:45
Clase Carro con Inyeccion de Dependencia
<?php
class Carro {
private $motor;
public function __construct(Motor $motor) {
$this->motor = $motor;
$this->motor->arranca();
}
}