Skip to content

Instantly share code, notes, and snippets.

@hdodov
hdodov / superhosting-ssh.md
Created Nov 20, 2020
SuperHosting Kirby Git SSH setup instructions
View superhosting-ssh.md
  1. Open a terminal from cPanel

  2. Use ssh-keygen to generate a key (with no passphrase)

    Note: You can't use SuperHosting's GUI SSH key manager because it demands a passphrase, and that's not an option since kirby-git can't fill it in.

  3. Run cat ~/.ssh/id_rsa.pub to print the public key and copy it

  4. Go to GitHub and paste the public key (in the Deploy Keys settings panel)

  5. Test with ssh -T -p 443 git@ssh.github.com

    Expected output:

@hdodov
hdodov / google-sheets-append-rows.php
Created Jan 9, 2020
Script that appends rows to a spreadsheet via the Google Sheets API.
View google-sheets-append-rows.php
<?php
require __DIR__ . '/vendor/autoload.php';
$creds = 'credentials.json';
$sheedId = '1IMwiyCa1gCfh1lacyzZqFrYFsqCe-hOSRlaHIc2gFDw';
$range = 'Sheet1';
$client = new Google_Client();
$client->setAuthConfigFile($creds);
$client->useApplicationDefaultCredentials();
View v3.ext
basicConstraints=CA:FALSE
keyUsage=digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
authorityKeyIdentifier=keyid,issuer
subjectAltName = @alt_names
[alt_names]
DNS.1=localhost
@hdodov
hdodov / mixin-to-rule.scss
Created Jan 16, 2018
Regex to convert all SCSS mixins to simple CSS rules for transitioning from Bourbon to Autoprefixer.
View mixin-to-rule.scss
// Find (add properties as needed):
@include\s*(animation|appearance|transform|transition|display|align-items|justify-content|flex-flow|flex|backface-visibility|user-select)\(([^;]+)\);
// Replace:
$1: $2;
// ----------------------------------
// Transforms this:
@include display(flex);
@hdodov
hdodov / iframechange.js
Last active May 7, 2021
HTML iframe URL change listener for tracking when a new iframe page starts to load
View iframechange.js
function iframeURLChange(iframe, callback) {
var lastDispatched = null;
var dispatchChange = function () {
var newHref = iframe.contentWindow.location.href;
if (newHref !== lastDispatched) {
callback(newHref);
lastDispatched = newHref;
}
@hdodov
hdodov / nomin.htaccess
Last active Nov 20, 2017
.htaccess file that allows you to visit a page with unminified versions of all files inside
View nomin.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} \/nomin(\/|$)
RewriteRule (.+)\/nomin(.*) $1$2 [E=NO_MINIFICATION:1]
RewriteCond %{ENV:NO_MINIFICATION} 1 [OR]
RewriteCond %{ENV:REDIRECT_NO_MINIFICATION} 1
RewriteCond %{REQUEST_URI} (.+)\.min(\.[^.].*) [NC]
RewriteCond %{DOCUMENT_ROOT}/%1%2 -f
@hdodov
hdodov / cordova-permission-removal.md
Last active Jun 13, 2017
How to completely remove an Android permission from Cordova app.
View cordova-permission-removal.md

In this example, I'll show how to remove the RECORD_AUDIO permission.


  1. Navigate to the plugins directory in your Cordova folder.

  2. Open the plugin.xml file of each plugin and search for something like:

<uses-permission android:name="android.permission.RECORD_AUDIO"/>
@hdodov
hdodov / cordova-release.md
Last active Jun 13, 2017
In-depth, step-by-step guide to building a Cordova release APK in Windows.
View cordova-release.md
  1. Open CMD as administartor
  2. Go to your JDK's bin folder:
C:\Program Files\Java\jdk1.8.0_121\bin
  1. Run:
keytool -genkey -v -keystore C:\myKeystoreName.keystore -alias myName -keyalg RSA -keysize 2048 -validity 10000
  1. Add a build.json file to your Cordova folder (where the platforms and www folders reside). It should look like this:
@hdodov
hdodov / _media-smart.scss
Last active Dec 6, 2018
Flexible Sass media queries with no hardcoding. Specify your breakpoints and you'll have mixins for media queries that are smaller, larger or inside the device ranges. Mobile first (like Bootstrap).
View _media-smart.scss
// ----
// Sass (v3.4.21)
// Compass (v1.0.3)
// ----
$screens: (
"xs": 0px,
"sm": 768px,
"md": 992px,
"lg": 1200px