Skip to content

Instantly share code, notes, and snippets.

View hitautodestruct's full-sized avatar

Yotam hitautodestruct

View GitHub Profile
@hitautodestruct
hitautodestruct / readme.md
Last active September 26, 2022 11:25 — forked from anonymous/gist:4344870
Generate a custom structure for Wordpress menus.

This gist is for showing an example of a custom wordpress menu.

If you want to get more from the menu item simply have a look at the $item object. i.e:

// Will return a large object with lots of props like title, url, description, id etc.
var_dump( $item );

This code works on Wordpress 4.1.1 as of 31st of March 2015

@hitautodestruct
hitautodestruct / html_entity_escape.js
Created May 6, 2013 11:48
This function converts special chars into html enteties. This is a nodejs module form this answer: http://stackoverflow.com/a/1354715/414385 on StackOverflow. Usage: var ee = require('./html_entity_escape'); ee.convert('Special § £ Chars'); // Special § £ Chars
module.exports = {
convert: function( text ){
// all HTML4 entities as defined here: http://www.w3.org/TR/html4/sgml/entities.html
// added: amp, lt, gt, quot and apos
this.entityTable = {
34 : 'quot',
38 : 'amp',
39 : 'apos',
@hitautodestruct
hitautodestruct / flat_wp_nav_menu.php
Created May 13, 2013 11:36
A short wordpress menu generator with only top level links. No hierarchy.
<?php
$menu_name = 'sidebar_nav';
$locations = get_nav_menu_locations();
$menu = wp_get_nav_menu_object( $locations[ $menu_name ] );
$menuitems = wp_get_nav_menu_items( $menu->term_id, array( 'order' => 'DESC' ) );
?>
<ul class="side-menu">
<?php
@hitautodestruct
hitautodestruct / console_log.php
Created August 27, 2013 08:15
Better implementation of a `var_dump` function for web debugging.
function console_log ( $output ) {
echo '<script>';
echo 'console.log('. json_encode( $output ) .');';
echo '</script>';
}
@hitautodestruct
hitautodestruct / fb-profile-picture.html
Created October 7, 2013 08:28
Get any profile picture (by ID) from facebook.
<img src="http://graph.facebook.com/4/picture?type=large" alt="Mark Zukerberg's Profile Picture">
@hitautodestruct
hitautodestruct / btn-directive.js
Created October 8, 2013 10:10
Angularjs directive for simplifying bootstrap buttons. Removes the need to add a `class="btn btn-lg btn-success"` etc. http://jsbin.com/ibinASA/1/edit
var app = angular.module('boostrapButton', []);
app.directive('btn', function () {
return function ( scope, element, attrs ) {
var classes = attrs.btn.split(' ');
classes.unshift('btn');
@hitautodestruct
hitautodestruct / desktop-first.css
Created October 20, 2013 12:12
Smallest example of desktop first media query.
.wide { height: 10px; background-color: red; }
@media all and (max-width: 20em) {
.wide { background-color: blue; }
}
@hitautodestruct
hitautodestruct / mobile-first.css
Created October 20, 2013 12:14
Tiny example of mobile first media query.
.wide { height: 10px; background-color: red; }
@media all and (min-width: 20em) {
.wide { background-color: blue; }
}
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="An example of using the open weather map api.">
<script src="http://code.jquery.com/jquery-latest.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
@hitautodestruct
hitautodestruct / box-sizing.css
Created January 20, 2014 14:28
Quick reference to Paul Irish's box-sizing method. http://www.paulirish.com/2012/box-sizing-border-box-ftw
/* apply a natural box layout model to all elements */
*, *:before, *:after {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}