Skip to content

Instantly share code, notes, and snippets.

@hdodov
hdodov / _media-smart.scss
Last active December 6, 2018 20:03
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).
// ----
// Sass (v3.4.21)
// Compass (v1.0.3)
// ----
$screens: (
"xs": 0px,
"sm": 768px,
"md": 992px,
"lg": 1200px
@hdodov
hdodov / cordova-release.md
Last active June 13, 2017 09:47
In-depth, step-by-step guide to building a Cordova release APK in Windows.
  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 / cordova-permission-removal.md
Last active July 15, 2021 10:00
How to completely remove an Android permission from Cordova app.

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 / nomin.htaccess
Last active November 20, 2017 04:16
.htaccess file that allows you to visit a page with unminified versions of all files inside
<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 / iframechange.js
Last active September 23, 2024 14:17
HTML iframe URL change listener for tracking when a new iframe page starts to load
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 / mixin-to-rule.scss
Created January 16, 2018 07:42
Regex to convert all SCSS mixins to simple CSS rules for transitioning from Bourbon to Autoprefixer.
// 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);
basicConstraints=CA:FALSE
keyUsage=digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
authorityKeyIdentifier=keyid,issuer
subjectAltName = @alt_names
[alt_names]
DNS.1=localhost
@hdodov
hdodov / google-sheets-append-rows.php
Created January 9, 2020 12:40
Script that appends rows to a spreadsheet via the Google Sheets API.
<?php
require __DIR__ . '/vendor/autoload.php';
$creds = 'credentials.json';
$sheedId = '1IMwiyCa1gCfh1lacyzZqFrYFsqCe-hOSRlaHIc2gFDw';
$range = 'Sheet1';
$client = new Google_Client();
$client->setAuthConfigFile($creds);
$client->useApplicationDefaultCredentials();
@hdodov
hdodov / superhosting-ssh.md
Created November 20, 2020 17:11
SuperHosting Kirby Git SSH setup instructions
  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 [email protected]

    Expected output:

@hdodov
hdodov / replace-variables-hook.ts
Last active January 16, 2023 06:33
Payload CMS dynamic variables with `{{` and `}}`. You can also add modifiers, e.g. `{{ my_var:millions }}` and divide the value by 1e6.
import payload from "payload";
import { CollectionAfterReadHook } from "payload/types";
import { Variable } from "../payload-types";
const pattern = /{{\s*(.*?)\s*}}/g;
const modifiers: { [key: string]: (input: string) => string } = {
millions: (value) => Math.floor(parseInt(value) / 1e6).toString(),
};
/**