Skip to content

Instantly share code, notes, and snippets.

View diegochavez's full-sized avatar
🎯
Focusing

Diego Chavez diegochavez

🎯
Focusing
View GitHub Profile
@diegochavez
diegochavez / multiFilter.js
Last active January 16, 2022 12:38 — forked from jherax/filterArray.js
Multi filters an array of objects
/**
* Multi-filter an array of objects
* @param {Array} array : list of elements to apply a multiple criteria filter
* @param {Object} filters: Contains multiple criteria filters by the property names of the objects to filter
* @return {Array}
*/
function multiFilter(array, filters) {
let filterKeys = Object.keys(filters);
// filters all elements passing the criteria
return array.filter((item) => filterKeys.every((key) => (filters[key].indexOf(item[key]) !== -1)));
add_filter('json_api_encode', 'json_api_encode_acf');
function json_api_encode_acf($response)
{
if (isset($response['posts'])) {
foreach ($response['posts'] as $post) {
json_api_add_acf($post); // Add specs to each post
}
}
### Keybase proof
I hereby claim:
* I am diegochavez on github.
* I am diegochavez (https://keybase.io/diegochavez) on keybase.
* I have a public key ASDsYbqzKu0JDEcVYoD-6cDNIgJCQzIH7iWmBIntkpEaCwo
To claim this, I am signing this object:
@diegochavez
diegochavez / findCarrier.js
Last active March 16, 2017 23:21
Detect Mobile Phone Carrier Guatemala
function findCarrier(MSISDN){
num = MSISDN * 1;
if(num < 30000000 || num >= 60000000)
return {"carrier":null,"error":true};
if(
((30000000<= num) && (num <= 33599999)) ||
((40000000<= num) && (num <= 40999999)) ||
((44760000<= num) && (num <= 46999999)) ||
((47730000<= num) && (num <= 48199999)) ||
((48220000<= num) && (num <= 50099999)) ||
@diegochavez
diegochavez / country-tourism-slogans.json
Created December 29, 2016 17:52
Country Slogans, Tourism messages, JSON file,
{
"Albania": "Go your own way!",
"Algeria": "Tourism for everybody",
"Andorra": "The Pyrenean Country",
"Antigua and Barbuda": "The beach is just the beginning",
"Argentina": "Beats to your rhythm",
"Armenia": "Visit Armenia, It is Beautiful",
"Australia": "There’s NOTHING like Australia",
"Austria": "Arrive and revive",
"Bahamas": "Life Is Grand",
@diegochavez
diegochavez / examples.md
Created November 24, 2016 15:08 — forked from mattpodwysocki/examples.md
RxJS Demos
import angular from 'angular';
import uiRouter from 'angular-ui-router';
import ocLazyLoad from 'oclazyload';
let aboutModule = angular.module('about', [
uiRouter,
ocLazyLoad
])
.config(($stateProvider, $compileProvider) => {
@diegochavez
diegochavez / Introduccion.ts
Last active April 4, 2016 20:13
Introducción basica de TypeScript.
// Texto de tipo String o cadena,
let texto: String = 'hello world'
texto = 2 // Error no puede asignar un Numero a un tipo Cadena o String
// Una constante no puede ser reasignada
const PI: Number = 3.1416
PI = 3543 // Error: no puede asignar un valor a una constante
// Tipos de array lo cual es muy conveniente para evitar mutación de los datos con tipos invalidos
let nombres:Array<String> = ['David','Jose','Maria']
@diegochavez
diegochavez / config.rb
Created November 13, 2013 18:54
Compass regular configuration file config.rb I use this on sublimetext with livereload wich export the file in the same directory of the compass file.
http_path = "/"
css_dir = "."
sass_dir = "."
images_dir = "img"
javascripts_dir = "js"
output_style = :compact
relative_assets=true
line_comments = false
@diegochavez
diegochavez / gist:6731825
Created September 27, 2013 17:10
My custom wp_bootstrap_navwalker based on https://github.com/twittem/wp-bootstrap-navwalker
<?php
/**
* Class Name: wp_bootstrap_navwalker
* GitHub URI: https://github.com/twittem/wp-bootstrap-navwalker
* Description: A custom WordPress nav walker class to implement the Twitter Bootstrap 2.3.2 navigation style in a custom theme using the WordPress built in menu manager.
* Version: 2.0.1
* Author: Edward McIntyre - @twittem
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt