Skip to content

Instantly share code, notes, and snippets.

@lokothodida
lokothodida / getsimple-tutorial-sidebars.md
Last active August 29, 2015 14:27
GetSimple tutorial for integrating page-specific sidebars on your site.

GetSimple Tutorial: Sidebars

A common request people have when it comes to having a dynamic site is the ability to create content displayed adjacently to the main content: a “side-bar” if you will. Sometimes it will be content that should be displayed universally, regardless of the page that you're viewing, such as a 'Latest News/Blog/Tweet' block, or a calendar widget. Other times it is a very page-specific piece of content, like an extra menu to a set of relevant links to the main content, or the latest comments made on the current page. The biggest problem that people tend to have is the difficulty of maintenance of such sidebar content – often you have to hard-wire the code into your layout and continually have to edit the content from the template file or as a component, which can be very grating when you have page-specific sidebars and a lot of pages to boot.

This article will outline a way that I think is a pretty efficient way of providing yourself either universal sidebar widgets, page-specific s

@lokothodida
lokothodida / getsimple-tutorial-i18n-customfields-conditional-rendering.md
Last active August 29, 2015 14:27
GetSimple tutorial for rendering a (i18n) custom field conditionally.

GetSimple Tutorial: i18n Custom Fields: Conditional Rendering

Oleg06 of the GetSimple forums once asked about displaying certain content from a Special/Custom field based on whether or not the field is filled.

To do this, you simply form a conditional using the return_special_field function, checking that the result (a string) is non-empty:

<?php
  if (return_special_field($field) !== '') {
    // output
@lokothodida
lokothodida / getsimple-tutorial-shortcodes.md
Last active December 18, 2017 04:56
GetSimple tutorial for adding shortcode-like to the admin panel.

GetSimple Tutorial: Shortcodes

Sometimes you have content that you want to place onto a page that requires a bit of messy HTML, CSS and PHP coding. This can be very frustrating when there are multiple occurrences of said piece of content within your page, and when each occurrence requires something different about it. What is even worse is when the person who needs to manipulate this content isn't very confident with the above markup (HTML, CSS) and code (PHP) languages, yet they need to be able to edit the necessary pieces without breaking a crucial piece of the markup. Wouldn't it be great if GetSimple had such a function?

Other content management systems such as forums and Wordpress do have such functions, called BBCode and Shortcodes respectively, which allow for dynamic content to be output on pages without knowledge of the messy code that goes in beforehand. For example, on forums you can often place a link on the page by simply using [url][/url] tags instead of knowing how to use HTML anchors and p

@lokothodida
lokothodida / powerset.iterative.js
Last active August 10, 2017 01:11
Javascript implementation(s) of a Power Set function
/* Calculates the power set, P(s) := { s' : s' is a subset of s }
* Assumes an implementation of a Set that has the following methods:
* add, equals, forEach, clone
*/
var powerSet = function(set) {
var prevSet = new Set(); // prevSet := {}
var currSet = new Set().add(new Set()); // currSet := { {} }
// Main loop will continually add elements to currSet until no
// new elements are added
@lokothodida
lokothodida / README.md
Last active March 25, 2016 19:46
GetSimple Theme Developer Language Helper Functions

GetSimple Theme Developer Language Helper Functions

Allows GetSimple theme designers to have theme-dependent language strings in a lang folder of their theme.

Usage

  1. Add language_functions.php (from this gist) to your current theme's folder.
  2. Create a lang folder in your current theme
  3. Create language files for your theme with file names corresponding to language codes:
@lokothodida
lokothodida / README.md
Last active March 26, 2016 10:45
GetSimple Tutorial: Setting up a Plugin Development Environment

GetSimple Tutorial: Setting up a Plugin Development Environment

These are the steps I take for setting up an environment for developing GetSimple plugins. It allows me to Keep my individual plugin's repository separate from the plugins folder.

  1. Install GetSimple to your desired root directory (for now we will refer to it as root/).
  2. Create your plugin's working directory/clone your repository to the root/ directory.
  3. Symbollically the plugin's registration file and assets folders to the plugins directory:
@lokothodida
lokothodida / README.md
Last active October 20, 2021 10:11
Small bookmarklet to help change app drawer icons for Chrome OS web apps
  • Create a bookmark with the following text in the URL field:
javascript:(function() {
  if (!document.querySelectorAll('link[rel*=icon]').length) {
      const link = document.createElement('link');
      link.rel   = 'icon';
      document.querySelector('head').appendChild(link);
  }