Skip to content

Instantly share code, notes, and snippets.

View freekrai's full-sized avatar

Roger Stringer freekrai

View GitHub Profile
@freekrai
freekrai / multisite_functions.php
Created July 19, 2011 14:20
Some handy wordpress multisite functions
<?php
$posts = multisite_latest_post( array(
"how_many"=>10,
"how_long_days"=>30,
"how_many_words"=>50,
"more_text"=>"[...]",
"remove_html"=>true,
"sort_by"=>"post_date",
// if paginating:
"paginate"=>true,
@freekrai
freekrai / dnsmasq OS X.md
Created July 20, 2021 16:39 — forked from ogrrd/dnsmasq OS X.md
Setup dnsmasq on OS X

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.

Requirements

Install

@freekrai
freekrai / wordpress-using-multisite-domain-mapping-on-a-mediatemple-grid-server.md
Created August 27, 2015 00:44
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, originalsite.com is the main root domain, and I am going to create newsite.com.

  1. Add the domains you’d like to use (newsite.com in this example) as alternate domains in the AccountCenter.
  2. Log into your (gs) via SSH, move into the domains direc
@freekrai
freekrai / V2.sql
Last active April 17, 2021 00:42 — forked from kez/slugify.sql
Generating Slugs in Postgres
CREATE EXTENSION IF NOT EXISTS "unaccent";
CREATE OR REPLACE FUNCTION slugify(t text) RETURNS text
AS $$
BEGIN
t := regexp_replace(t, '[Ää]', 'ae', 'g');
t := regexp_replace(t, '[Öö]', 'oe', 'g');
t := regexp_replace(t, '[Üü]', 'ue', 'g');
t := unaccent(t);
t := lower(t);
@freekrai
freekrai / browser-mockup.png
Created March 31, 2021 18:05 — forked from jarthod/browser-mockup.png
Pure CSS browser mockups
browser-mockup.png
@freekrai
freekrai / AuthyToOtherAuthenticator.md
Created March 31, 2021 17:38 — forked from gboudreau/AuthyToOtherAuthenticator.md
Export TOTP tokens from Authy

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

@freekrai
freekrai / log_js_errors.js
Created March 26, 2021 16:25 — forked from levelsio/log_js_errors.js
Log JS errors as a POST to your server
// <log errors to server>
window.onerror = function (messageOrEvent, source, lineno, colno, error) {
try {
console.log({
//error message(string).Available as event (sic!) in HTML onerror = "" handler.
messageOrEvent: messageOrEvent,
//URL of the script where the error was raised(string)
source: source,
//Line number where error was raised(number)
@freekrai
freekrai / app_GraphQL_schema.json
Created March 21, 2021 17:59 — forked from 4levels/app_GraphQL_schema.json
Sample setup Lighthouse with Lumen
# Just the basics: User with Images
scalar DateTime @scalar(class: "DateTime")
type User {
id: ID! @globalId
name: String
email: String
created_at: DateTime!
updated_at: DateTime!
@freekrai
freekrai / README.md
Created March 20, 2021 15:59 — forked from ppoffice/README.md
Install Visual Studio Code (actually code-server) on Android
  1. Install Termux, an Android terminal emulator that provides a Linux execution environment and various tools.

  2. Update system packages in Termux:

    $ pkg update -y