Skip to content

Instantly share code, notes, and snippets.

View alenb's full-sized avatar

Alen Birindzic alenb

View GitHub Profile
@pavelthq
pavelthq / custom_view.js
Last active March 27, 2024 14:51
Visual Composer: Custom markup element example
(function($) {
window.VcCustomElementView = vc.shortcode_view.extend( {
elementTemplate: false,
$wrapper: false,
changeShortcodeParams: function ( model ) {
var params;
window.VcCustomElementView.__super__.changeShortcodeParams.call( this, model );
params = _.extend( {}, model.get( 'params' ) );
if ( ! this.elementTemplate ) {
import element from 'virtual-element'; // Using deku
// import React from 'react'; // Switch to this if you are using React
import pathToRegexp from 'path-to-regexp';
export function renderRoutes(path, routes) {
return Object.keys(routes).map(routePath => {
let paramsInfo = [];
let re = pathToRegexp(routePath, paramsInfo);
let paramNames = paramsInfo.map(p => p.name);
@Skatox
Skatox / wc-api-custom.php
Created November 16, 2015 21:19
Woocommerce API REST custom path
<?php
/**
* Custom API REST path class
*
* @package MyPlugin
* @author Skatox
*/
class WC_API_Custom extends WC_API_Resource
{
@ezekg
ezekg / import-store-locations.php
Last active December 22, 2022 08:35
Import CSV script for WP Store Locator plugin
<?php
/**
* This is a quick and dirty script. This should NEVER be run on a production server.
*
* Include this script at the bottom of your functions.php file, e.g.
*
* ```php
* // Your functions.php file
* // ...
@joech4n
joech4n / Configure Postfix for Gmail SMTP in Mac OSX.md
Last active June 19, 2024 11:37 — forked from larrybotha/readme.markdown
Configure Postfix for Gmail SMTP in Mac OSX
@tonymtz
tonymtz / gist:d75101d9bdf764c890ef
Last active May 7, 2024 13:07
Uninstall nodejs from OSX Yosemite
# first:
lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do sudo rm /usr/local/${f}; done
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
# To recap, the best way (I've found) to completely uninstall node + npm is to do the following:
# go to /usr/local/lib and delete any node and node_modules
cd /usr/local/lib
sudo rm -rf node*
@patriciogonzalezvivo
patriciogonzalezvivo / GLSL-Noise.md
Last active July 24, 2024 14:58
GLSL Noise Algorithms

Please consider using http://lygia.xyz instead of copy/pasting this functions. It expand suport for voronoi, voronoise, fbm, noise, worley, noise, derivatives and much more, through simple file dependencies. Take a look to https://github.com/patriciogonzalezvivo/lygia/tree/main/generative

Generic 1,2,3 Noise

float rand(float n){return fract(sin(n) * 43758.5453123);}

float noise(float p){
	float fl = floor(p);
  float fc = fract(p);
@tonyganch
tonyganch / abc.json
Created January 12, 2014 12:11
Alphabetical sort order for csscomb.js (based on csscomb.json)
{
"sort-order": [
"-webkit-animation",
"-moz-animation",
"-ms-animation",
"-o-animation",
"animation",
"-webkit-animation-delay",
"-moz-animation-delay",
"-ms-animation-delay",
@gerbenvandijk
gerbenvandijk / Mark parent navigation active when on custom post type single page
Last active July 16, 2024 16:53
Mark (highlight) custom post type parent as active item in Wordpress Navigation.When you visit a custom post type's single page, the parent menu item (the post type archive) isn't marked as active. This code solves it by comparing the slug of the current post type with the navigation items, and adds a class accordingly.
<?php
function add_current_nav_class($classes, $item) {
// Getting the current post details
global $post;
// Get post ID, if nothing found set to NULL
$id = ( isset( $post->ID ) ? get_the_ID() : NULL );
@hissy
hissy / gist:4324036
Created December 18, 2012 01:04
WordPress: get permalink by page path
<?php echo get_permalink( get_page_by_path( 'page-slug/children' ) ); ?>