Skip to content

Instantly share code, notes, and snippets.

@tvisser
tvisser / Afas.class.php
Last active September 19, 2017 13:24
PHP Class for easily using the Afas GetConnector or UpdateConnector
<?php
/**
* Class Afas
*
* This class has 3 static functions for accessing data using the Afas GetConnectors and UpdateConnectors.
* It includes the GET, POST and PUT request in their valid format.
*
* IMPORTANT: For it to work, remember to change the BASE_URL and TOKEN constants in the class.
*
@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 );
@douglasrodrigo
douglasrodrigo / gist:3707089
Created September 12, 2012 14:42
lambda-calculus factorial
True = ->(a,b) {a}
False = ->(a,b) {b}
#Church encodings
zero = ->(f){->(x) {x}}
one = ->(f){->(x) { f.(x)}}
two = ->(f){->(x) { f.(f.(x))}}
three =->(f){->(x) { f.(f.(f.(x)))}}
#operations