Skip to content

Instantly share code, notes, and snippets.

@anova
anova / inject-style-and-html.js
Created April 3, 2020 08:00
Add some additional css and html on runtime. (I am using this method for landing pages)
(function () {
const base_path = 'https://example.com/base/path/';
function addStyle(name) {
const path = base_path + 'css/' + name + '?v=' + Date.now();
const link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = path;
document.head.appendChild(link);
}
@anova
anova / change-db-prefix.sql
Created May 15, 2019 10:57
Change db prefix wp-admin inaccessible.
-- https://www.bishoy.me/changed-wp-table-prefix-now-cannot-access-wp-admin/
-- http://www.neoegm.com/tech/wordpress/how-to-fix-the-you-do-not-have-sufficient-permissions-to-access-this-page-message-in-wordpress/
UPDATE `new_prefix_wp_usermeta` SET `meta_key` = REPLACE(`meta_key`,'old_prefix_wp_','new_prefix_wp_');
UPDATE `new_prefix_wp_options` SET `option_name` = REPLACE(`option_name`,'old_prefix_wp_','new_prefix_wp_');
@anova
anova / jquery-mask-plugin-phone-ignore-first-zero.js
Created April 26, 2019 14:32
ignores first zero at phone number for jquery mask plugin
//http://igorescobar.github.io/jQuery-Mask-Plugin/docs.html#callback-examples
$('.phone-mask').mask('(A00) 000 00 00',{ translation: { 'A': { pattern: /[1-9]/, optional: false } } });
<!--
https://github.com/igorescobar/jQuery-Mask-Plugin/issues/25#issuecomment-20642590
cmwelsh
-->
<input type="text" pattern="[0-9]*" /> <!-- display a numeric keyboard -->
<!-- azerafati -->
<input type="tel" /> <!-- display a telephone keypad -->
@anova
anova / turkish-capitalize-words.js
Last active June 28, 2022 08:45
Capitalize, lowercase, uppercase for Turkish alphabet.
//http://stackoverflow.com/a/1026087/181295
String.prototype.turkishUpperCase = function () {
return this.replace(/ğ/g, 'Ğ')
.replace(/ü/g, 'Ü')
.replace(/ş/g, 'Ş')
.replace(/ı/g, 'I')
.replace(/i/g, 'İ')
.replace(/ö/g, 'Ö')
.replace(/ç/g, 'Ç')
.toUpperCase();