Skip to content

Instantly share code, notes, and snippets.

@odahcam
odahcam / raf.js
Last active August 24, 2016 12:13 — forked from rwaldron/raf.js
requestAnimationFrame, browser prefix detection
var rAF = "equestAnimationFrame";
window["r"+rAF] = window["r"+rAF] ||
window["webkitR"+rAF] ||
window["mozR"+rAF] ||
window["msR"+rAF] ||
window["oR"+rAF];
// A list
@odahcam
odahcam / getSkuById.php
Last active October 5, 2018 22:32
Function to retrieve a product SKU based on it's ID on Magento (1.8) platform.
<?php
include_once '../app/Mage.php';
/**
* @author odahcam
*
* @version 1.0.0
*
* @param {string|int} $product_id
@odahcam
odahcam / ImageGD.php
Created September 27, 2017 04:13
A PHP class to wrap imageGD PHP library into a OO class.
<?php
/**
* @author Luiz Filipe Machado Barni <luiz@h2k.com.br>
*
* @version 0.2.0
*/
class ImageGD
{
public $image_src; // the source of the image
@odahcam
odahcam / isFunction.js
Created October 7, 2017 12:26
Checks if a value is a fucntion.
function isFunction(functionToCheck) {
var getType = {};
return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
}
@odahcam
odahcam / getType.js
Created October 7, 2017 12:33
Gets the type of the given object.
function getType(obj) {
return ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase();
}
@odahcam
odahcam / fancyBox-as-activity-indicator.md
Created November 22, 2017 12:02
Usando o FancyBox como loading (activity-indicator) dialog.

title: Diálogos de carregamento com o fancyBox 3 author: Luiz Barni type: post date: 2017-09-24 image: https://i.ytimg.com/vi/djlx7xdwlpI/maxresdefault.jpg excerpt: Como utilizar os diálogos de carregamento do fancyBox 3 para melhorar a UX do seu site! categories:

  • JavaScript
  • UX e Design
@odahcam
odahcam / README.md
Last active March 9, 2021 15:41
Validação de CPF e CNPJ com integração com React Forms, implementado com Angular 6.

Exemplos

Uso com reactive forms

new FormGroup({
    cpfManualLength: new FormControl('', [
        Validators.required,
        Validators.pattern(/^(\d{3}\.){2}\d{3}\-\d{2}$/),
        Validators.minLength(14), // digits + word characters
@odahcam
odahcam / delete-with-left-join.mysql
Created August 1, 2018 23:40
Delete from T1 using LEFT JOIN conditions in MySQL
DELETE p FROM persistences AS p
LEFT JOIN users AS u
ON u.id = p.user_id
WHERE u.id IS NULL
@odahcam
odahcam / parallax.directive.ts
Created October 5, 2018 22:31
Parallax effect built on top of Angular 6 CDK Scrollable.
import { Directive, Input, ElementRef } from '@angular/core';
import { ScrollDispatcher, CdkScrollable } from '@angular/cdk/overlay';
@Directive({
selector: '[appParallax]'
})
export class ParallaxDirective {
el: HTMLElement;