Skip to content

Instantly share code, notes, and snippets.

View matismasters's full-sized avatar

Matis matismasters

View GitHub Profile
@matismasters
matismasters / sanitizer.js
Created June 22, 2018 18:51
Weird to see functional programming after so much OO
const maxLength = (firstString) => (secondString) => {
return firstString.length > secondString.length ?
firstString.length :
secondString.length
}
module.exports = { maxLength }
require 'yaml'
# For some weird reason I ended up creating a script to create specs
# for testing the I18n Locale file. It happens that I never used it anyway
# but it might be of use to someone so I'll leave it here.
#
# This assumes you use I18n, and also uses the YAML gem. The example is
# default configured for the Rails path to the locale file, but off course
# you can change it.
#
# Note: This is just a generator in case you already started your project
@matismasters
matismasters / extended_specs.md
Last active December 18, 2015 10:09
Generate rake tasks dynamically based on Rails + Engines folder structure for running tests using RSpec + Factory Girl

Rake spec tasks for engines

Dependencies:

  • rails 3.2+
  • rspec-rails
  • factory-girl

Scenario:

  • You have a Rails application with several engines.
@matismasters
matismasters / user_stories.markdown
Last active December 14, 2015 16:48
Few tips gathered through the Internet about wirting user stories

User stories writing guide

This quick tips would help you write better user stories, and group them in themes. As a quick reference here are a few examples

  • As a customer role, I want goal/desire so that benefit
  • As an admin, I want to send register invitations so that I can invite user lists from the old application
  • As a regular user I want to have a search bar in the top so that I can easily find what I am looking for
  • As a regular user I want to create and save playlists so that I can have my songs organized, and accesible
  1. Focus on the user: As its name suggests, a user story should tell a story about a customer or user employing the product. Write stories from the user’s perspective and employ user roles, such as corporate user, consumer, admin, marketer.
@matismasters
matismasters / state_machine_usage_example.rb
Created November 13, 2012 18:30
Example of state machine usage
state_machine :initial => :unassigned do
after_transition :on => [:accept, :assign], :do => :save
# Reject
event :reject do
transition :assigned => :unassigned
end
after_transition :on => :reject do
@matismasters
matismasters / mProducto.php
Created December 14, 2011 20:20
Modelo de producto
<?php
// Importamos el archivo que tiene las funciones para conectar a la base de datos
require_once("c:/wamp/www/ejercicio/modelos/bd_con.php");
class mProducto{
public static $categorias = array("Bazar", "Carniceria", "Panaderia", "Regaleria");
public static $tags = array("Oferta 10%", "Oferta 20%", "Oferta 30%");
public static $nombreTabla = "Productos";
private $id;
private $codigo_de_barras;
private $titulo;
@matismasters
matismasters / mLibros.php
Created November 7, 2011 21:35
Modelo Libros ejemplo 1 MVC
<?php
function conectar_con_bd(){
$user = "root";
$pass = "";
$server = "localhost";
$bd = "bdLibros";
$link = mysql_connect($server,$user,$pass);
mysql_select_db($bd,$link);
return $link;
}
body, h1, h2, h3, div, p, u, strong, img, ul, li, a { margin:0; padding:0;}
#contenedor { width:900px; margin:auto;}
div#cabecera { margin-bottom:20px;}
div div h3 { font-size:28px; color:purple; text-decoration:underline;}
div div #logo h3 { font-size:38px; color:red;}
#logo h3 { color:blue;}
#contenido h1 { padding:2px;}
#contenido h1 { font-size:26px; color:red; padding:5px;}
h1 { border:1px solid black;}
.noticia img { width:200px; height:200px; float:left;}
<?php
function devolver_ordinal($elem, $ordenados){
for($x=0;$x<count($ordenados);$x++){
$ordenado = $ordenados[$x];
if($elem == $ordenado){
return $x;
}
}
return 999999;
}