Skip to content

Instantly share code, notes, and snippets.

@madnil
madnil / slugify.js
Last active October 13, 2015 10:57 — forked from demoive/slugify.js
Converts a string to a "URL-safe" slug
/**
* Converts a string to a "URL-safe" slug.
* Allows for some customization with two optional parameters:
*
* @param {string} Delimiter used. If not specified, defaults to a dash "-"
* @param {array} Adds to the list of non-alphanumeric characters which
* will be converted to the delimiter. The default list includes:
* ['–', '—', '―', '~', '\\', '/', '|', '+', '\'', '‘', '’', ' ']
*/
if (!String.prototype.slugify) {
@madnil
madnil / check_location.applescript
Last active December 19, 2015 22:38
Determine your location by checking your IP address in the local area network
set theIP to do shell script "ifconfig | grep 'broadcast' | awk '{print $2}'"
try
set ip1 to first paragraph of theIP
on error
set ip1 to ""
end try
if ip1 contains "192.168.1" then
-- Location 1
@madnil
madnil / wp_modify_bloginfo.php
Last active December 19, 2015 07:29
This filter modifies the feed title. Copy the code in the functions.php of the theme and replace the placeholder NEW_TITLE with the desired title for the feed.
<?php
function mn_modify_bloginfo($content, $feedelementname) {
Switch ($feedelementname) {
case 'name' : // Feed title
return "NEW_TITLE";
break;
default :
return $content;
@madnil
madnil / wp_shortcode_sel.php
Last active December 18, 2015 14:29
This code snippet creates the shortcode "sel" under WordPress to automatically search for the surrounded words. The search engine can be defined by an argument. With no argument the search own your own WP site is used. The snippet needs to be included in the functions.php of the WordPress theme.
<?php
/*
Usage: [sel engine=ddg|bing|google]word1 word2 ...[/sel]
"ddg": DuckDuckGo
"bing": Bing
"google": Google
"": Site Search (Default)