Skip to content

Instantly share code, notes, and snippets.


Roger Stringer freekrai

View GitHub Profile
freekrai / grab thumb url.php
Last active Nov 15, 2021 — forked from jlengstorf/grab thumb url.php
If no featured image... Grab the first image in the post content.. Or generate a thumbnail based on youtube or vimeo video if that is included instead of an image... then save the image as featured image...
View grab thumb url.php
* Retrieves the thumbnail URL to use for a post
* @param string $text The body of the post (get_content)
* @param string $size The image size to retrieve
* @return string The image URL to use
function get_thumb_url($text, $size){
global $post;
$imageurl = FALSE;
freekrai /
Created Dec 3, 2012
Post to Pinboard
import console
import urllib
from urllib import urlencode
import bs4
import requests
import webbrowser
import sys
import sound
freekrai / multisite_functions.php
Created Jul 19, 2011
Some handy wordpress multisite functions
View multisite_functions.php
$posts = multisite_latest_post( array(
// if paginating:
freekrai / dnsmasq OS
Created Jul 20, 2021 — forked from ogrrd/dnsmasq OS
Setup dnsmasq on OS X
View dnsmasq OS

Never touch your local /etc/hosts file in OS X again

To setup your computer to work with *.test domains, e.g. project.test, awesome.test and so on, without having to add to your hosts file each time.



freekrai / demo.php
Last active Jul 2, 2021
PHP session-based rate limiter for APIs
View demo.php
// in this sample, we are using the originating IP, but you can modify to use API keys, or tokens or what-have-you.
$rateLimiter = new RateLimiter($_SERVER["REMOTE_ADDR"]);
$limit = 100; // number of connections to limit user to per $minutes
$minutes = 1; // number of $minutes to check for.
freekrai /
Created Aug 27, 2015
WordPress: Using multisite domain mapping on a mediatemple grid server

This won’t get into setting up multisite in wordpress, but it will help you set up multisite domain mapping on a grid server from media temple. If you need to see a good intro article on setting up multisite mode in wordpress, check this article out or this article for a good multisite .htaccess intro.

First, install WordPress MU Domain Mapping plugin, and follow the instructions for setting that up.

Now, to add a new domain to media temple that will show up on your site, the big catch is to redirect this domain to the existing main domain.

For example, is the main root domain, and I am going to create

  1. Add the domains you’d like to use ( in this example) as alternate domains in the AccountCenter.
  2. Log into your (gs) via SSH, move into the domains direc
freekrai / V2.sql
Last active Apr 17, 2021 — forked from kez/slugify.sql
Generating Slugs in Postgres
View V2.sql
AS $$
t := regexp_replace(t, '[Ää]', 'ae', 'g');
t := regexp_replace(t, '[Öö]', 'oe', 'g');
t := regexp_replace(t, '[Üü]', 'ue', 'g');
t := unaccent(t);
t := lower(t);

Generating Authy passwords on other authenticators

There is an increasing count of applications which use Authy for two-factor authentication. However many users who aren't using Authy, have their own authenticator setup up already and do not wish to use two applications for generating passwords.

Since I use 1Password for all of my password storing/generating needs, I was looking for a solution to use Authy passwords on that. I couldn't find any completely working solutions, however I stumbled upon a gist by Brian Hartvigsen. His post had a neat code with it to generate QR codes for you to use on your favorite authenticator.

His method is to extract the secret keys using Authy's Google Chrome app via Developer Tools. If this was not possible, I guess people would be reverse engineering the Android app or something like that. But when I tried that code, nothing appeared on the screen. My guess is that Brian used the