Skip to content

Instantly share code, notes, and snippets.

View kevinnio's full-sized avatar

Kevin Perez kevinnio

View GitHub Profile
@kevinnio
kevinnio / AreaConocimiento.php
Last active February 27, 2020 05:25
Ejemplo para obtener areas de conocimiento según categoría
<?php
public class AreaConocimiento extends Siiutem\Modelo {
public categoria() {
return $this->belongsTo(CategoriaAreaConocimiento::class, "categoria_id");
}
}
@kevinnio
kevinnio / adding-jest-to-a-babel-6-project.md
Last active June 17, 2019 03:18
Adding Jest to a Babel 6 project

Jest is an amazing testing tool developed by the folks at Facebook and maintained by a vast community of developers. Is one of the best ways to write and run Javascript tests. It should be really easy to setup starting from scratch, but what if we want to integrate it into an already initialized project? One which uses Babel 6 and already has a .babelrc file.

The problem with Babel 6

Jest requires Babel to transpile Javascript code that doesn't normally run on NodeJS environments, most commonly ES2015 modules. Problem is Jest dropped support for Babel 6 since 24.0.0 in favour of Babel 7, which introduces a lot of changes to how devs work with Babel. Jest recommends upgrading if your project is still on Babel 6, but not all projects can upgrade quickly. This blog post is for those kinds of projects.

Alternative setup

Let's start by i

@kevinnio
kevinnio / rules.md
Last active May 27, 2019 15:04
Mario Kart Tournament Rules

Mario Kart Tournament Rules

First stage

  • Groups will be composed of 4 players max.
  • Each group will play 1 Versus Mode round with the following rules:
    • 150cc race
    • Teams: No
    • Items: Normal
    • CPU Level: Hard
@kevinnio
kevinnio / code.txt
Created May 22, 2019 19:54
Example of Fira Code on GitHub
// FIRA CODE OFFICIAL REPO: https://github.com/tonsky/FiraCode
object o;
if (o is int i || (o is string s &&
int.TryParse(s, out i)) { /* use i */ }
var x = 0xABCDEF;
-> --> ==> != === !== && ||<=<
</><tag> http://www.hanselman.com
<=><!-- HTML Comment -->
i++; #### ***
.CodeMirror-code,
.highlight pre,
.blob-code,
code {
font-family: 'Fira Code'
}
@kevinnio
kevinnio / md5rename
Last active May 2, 2019 01:56
Renames all files in the current dir using their MD5 checksums.
#! /bin/bash
md5 * | sed -e 's/MD5 (\([^.]*\)\(.[^)]*\)) = \(.*\)$/mv -v "\1\2" \3\2/' | sh
@kevinnio
kevinnio / spree_decorator.rb
Last active October 24, 2018 01:10
Spree/Solidus Module Decorator pattern
require 'active_support/concern'
module MyNamespace::SpreeDecorator
extend ActiveSupport::Concern
included do
# Call base class methods here!
some_class_method :foo
some_class_method_with_block do
another_class_method :bar
@kevinnio
kevinnio / app.rb
Last active October 4, 2018 17:38
The OddEven kata
require './oddeven'
oddeven = OddEven.new
(1..100).each { |number| puts oddeven.print_number(number) }
@kevinnio
kevinnio / app.rb
Last active October 4, 2018 16:18
The FizzBuzz kata
require './fizzbuzz'
fizzbuzz = FizzBuzz.new
(1..100).each { |number| puts fizzbuzz.print_number(number) }
Enterprise Key Buyer Organization Code Order No Revenue Requested Ship Date Order Date Status
5117452 SP_FL_55686 15 9/6/17 14:33 3300.100-Waved
5117452 SP_FL_55994 16.09 9/8/17 19:22 1300-Backordered
5117452 SP_FL_56005 20 9/9/17 1:32 3300.100-Waved
5117452 SP_FL_56070 15 9/9/17 10:56 3300.100-Waved
5117452 SP_FL_56449 15 9/12/17 14:14 3300.200-Picked
5117452 SP_FL_56454 15 9/12/17 16:02 3300.200-Picked
5117452 SP_FL_56599 15 9/13/17 13:49 3300.300-Manifested
5117452 SP_FL_56600 15 9/13/17 14:00 3300.300-Manifested
5117452 SP_FL_56601 0 9/13/17 14:06 3300.100-Waved