Skip to content

Instantly share code, notes, and snippets.

Avatar

Lawrence Okoth-Odida lokothodida

View GitHub Profile
@lokothodida
lokothodida / README.md
Last active Oct 20, 2021
Small bookmarklet to help change app drawer icons for Chrome OS web apps
View README.md
  • 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);
  }
@lokothodida
lokothodida / README.md
Last active Mar 26, 2016
GetSimple Tutorial: Setting up a Plugin Development Environment
View README.md

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 Mar 25, 2016
GetSimple Theme Developer Language Helper Functions
View README.md

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 / powerset.iterative.js
Last active Aug 10, 2017
Javascript implementation(s) of a Power Set function
View powerset.iterative.js
/* 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 / getsimple-tutorial-shortcodes.md
Last active Dec 18, 2017
GetSimple tutorial for adding shortcode-like to the admin panel.
View getsimple-tutorial-shortcodes.md

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 / getsimple-tutorial-i18n-customfields-conditional-rendering.md
Last active Aug 29, 2015
GetSimple tutorial for rendering a (i18n) custom field conditionally.
View getsimple-tutorial-i18n-customfields-conditional-rendering.md

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-sidebars.md
Last active Aug 29, 2015
GetSimple tutorial for integrating page-specific sidebars on your site.
View getsimple-tutorial-sidebars.md

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-archiving-with-i18n.md
Created Aug 16, 2015
GetSimple tutorial for archiving pages (in news/blogging fashion) with i18n.
View getsimple-tutorial-archiving-with-i18n.md

One feature that I thought was missing from the i18n News system is that of providing automatic archives for news results. However, such a feat is actually achievable with the current i18n Search plugin if you take a moment to think outside of the box...

Plugins you'll need

The importance of tags

Tags are the lifeblood of i18n Search. They are the key to filtering out your results to output exactly the kind of content that you are looking for and ordering them in a sensible way. Initially, tags were simply there as key-words to be involved in the “meta” information of the page – words that would help your site/page be indexed by search engines and found by users. With i18n Search however, these tags can be used to set up virtual categories and a filtering system, provided that you can maintain some kind of logical structure and consistency with the tags that you utilise.

@lokothodida
lokothodida / getsimple-tutorial-i18n-randomize-results.md
Last active Feb 7, 2019
GetSimple tutorial on providing random search results for i18n search.
View getsimple-tutorial-i18n-randomize-results.md

Ever wanted to have random items put into the search results pulled from I18N Search?

It's actually not that difficult. The technique hinges on the return_i18n_search_results function, specifically designed for doing custom results rendering.

We call the function with the desired paramters to get the results. To ensure a properly random selection, we'll set the maximum number of results to a high number (e.g. 999).

$search = return_i18n_search_results($tags, $words, 0, 999, $order, $lang);
@lokothodida
lokothodida / getsimple-tutorial-i18n-news-v2.md
Created Aug 16, 2015
GetSimple tutorial for creating a news system with the i18n plugin(s) (version 3)
View getsimple-tutorial-i18n-news-v2.md