Skip to content

Instantly share code, notes, and snippets.

@afonsograca
afonsograca / colorSorting.js
Created April 25, 2018 00:50
Color sorting in JavaScript
//Sorting Hex Color:
var scheme = [
"#4C4C4C","#1F2029","#35404E","#282938","#00A0BE","#C67C48","#32CF72", "#4155D1","#B86838","#D81196","#149C92","#786DC4","#DB2C38","#83C057", "#A4A4A4","#55747C","#FFFFFF"
];
var Color = function Color(hexVal) { //define a Color class for the color objects
this.hex = hexVal;
};
@bcnzer
bcnzer / postman-pre-request.js
Last active May 14, 2024 08:23
Postman pre-request script to automatically get a bearer token from Auth0 and save it for reuse
const echoPostRequest = {
url: 'https://<my url>.auth0.com/oauth/token',
method: 'POST',
header: 'Content-Type:application/json',
body: {
mode: 'application/json',
raw: JSON.stringify(
{
client_id:'<your client ID>',
client_secret:'<your client secret>',
@brunogaspar
brunogaspar / macro.md
Last active May 1, 2024 07:24
Recursive Laravel Collection Macros

What?

If a nested array is passed into a Laravel Collection, by default these will be threaded as normal arrays.

However, that's not always the ideal case and it would be nice if we could have nested collections in a cleaner way.

This is where this macro comes in handy.

Setup

@jimmyrolando
jimmyrolando / Cors.php
Last active October 24, 2020 23:28
Cors/Preflight Middleware for Laravel 5.2
<?php
namespace App\Http\Middleware;
use Closure;
use Symfony\Component\HttpFoundation\Response;
class Cors
{
/**
@carlodaniele
carlodaniele / custom_menu_admin.php
Last active May 26, 2022 20:32
A basic plugin showing how to add menu metaboxes to admin menu page
<?php
/**
* @package Custom_menu_admin
* @version 1.0
*/
/*
Plugin Name: Custom menu admin
Plugin URI: http://wordpress.org/extend/plugins/#
Description: This is an example plugin
Author: Carlo Daniele
@pelmered
pelmered / gist:e5633068658e75ba9a80
Last active October 13, 2021 14:55
Cleanup orphaned ACF data
# This might ruin your database and I do not take any responsibility for that. Backup your database before continuing
!
# Check the results throughly
SELECT * FROM `wp_postmeta`
WHERE `meta_key` IN
( SELECT TRIM(LEADING '_' FROM `meta_key`) AS mk
FROM `wp_postmeta`
WHERE `meta_value` regexp '^field_[0-9a-f]+'
AND `meta_value` NOT IN
@johnpolacek
johnpolacek / .gitconfig
Last active May 8, 2024 04:05
My current .gitconfig aliases
[alias]
co = checkout
cob = checkout -b
coo = !git fetch && git checkout
br = branch
brd = branch -d
brD = branch -D
merged = branch --merged
st = status
aa = add -A .
@lazarofl
lazarofl / app.js
Created April 17, 2014 21:29
Aplica uma diretiva para executar o Owl Carousel
var app = angular.module('app', []);
app.controller("ListagemController", function($scope){
$scope.itens = [];
for (var i = 1; i <= 16; i++) {
$scope.itens.push({text: i});
};
})