Skip to content

Instantly share code, notes, and snippets.

View tarciozemel's full-sized avatar

Tárcio Zemel tarciozemel

View GitHub Profile
@tarciozemel
tarciozemel / gist:e34cd8ec7297cddd018e854f2c8cad86
Created January 20, 2023 15:24
Diagnostic Stylesheet: identify script[async][defer]
/* @see https://twitter.com/csswizardry/status/1616451810004242432 */
head,
script[async][defer],
script[async][defer]::before {
display: block !important;
}
script[async][defer]::before {
background-color: white !important;
const docWidth = document.documentElement.offsetWidth
document.querySelectorAll('*').forEach(el => {
if (el.offsetWidth > docWidth) {
console.log(el)
}
})
@tarciozemel
tarciozemel / git-temporary-ignore.md
Last active May 24, 2022 13:29 — forked from sloanlance/git-temporary-ignore.md
git: Ignorar temporariamente arquivos novos ou alterados sem alterar .gitignore

There are times notifications aren't wanted about either a changed repo file or a new file that needs to be added to the repo. However, adding the name of the file to .gitignore might not be a good option, either. For example, locally-generated files that other users aren't likely to generate (e.g., files created by an editor) or files of experimental test code might not be appropriate to appear in a .gitignore file.

In those cases, use one of these solutions:

  1. If the file is a changed repo file

    Use the command:

    git update-index --assume-unchanged "$FILE"

/* Headers out of order (i.e. h2 before h1 etc.)
Result: dotted blue outline
@see https://twitter.com/Una/status/1277652897606635523
*/
h2 ~ h1,
h3 ~ h1,
h4 ~ h1,
h5 ~ h1,
h6 ~ h1,
h3 ~ h2,
@tarciozemel
tarciozemel / slugify.js
Created January 22, 2018 17:17 — forked from eek/slugify.js
Vanilla JavaScript Slugify + Accent removal - Just another JavaScript Slugifier with an extra line for Accent Removal
function slugify(text) {
return text.toString().toLowerCase().trim()
.normalize('NFD') // separate accent from letter
.replace(/[\u0300-\u036f]/g, '') // remove all separated accents
.replace(/\s+/g, '-') // replace spaces with -
.replace(/&/g, '-and-') // replace & with 'and'
.replace(/[^\w\-]+/g, '') // remove all non-word chars
.replace(/\-\-+/g, '-') // replace multiple '-' with single '-'
}
@tarciozemel
tarciozemel / gist:0bf35374a64fe6c9e2d1
Created April 20, 2015 17:11
JavaScript: lightweight selector implementation
//
// Returns first element that matches CSS selector {expr}.
// Querying can optionally be restricted to {container}’s descendants
//
function $( expr, container ) {
return typeof expr === 'string' ? ( container || document ).querySelector( expr ) : expr || null;
}
//
@tarciozemel
tarciozemel / gist:7310567
Created November 4, 2013 22:46
PHP: email encode
function emailEncode($e)
{
$email_len = strlen($e);
for ($i = 0; $i < $email_len; $i++) {
$output .= '&#'.ord($e[$i]).';';
}
return $output;
}
@tarciozemel
tarciozemel / gist:6978074
Created October 14, 2013 16:08
Git: criar repo no GitHub
Create a new repository on the command line
-------------------------------------------
touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin [SSH GIT ADDRESS]
git push -u origin master
@tarciozemel
tarciozemel / gist:6452825
Last active December 22, 2015 09:38
htaccess: modo de manutenção
# MAINTENANCE-PAGE REDIRECT
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REMOTE_ADDR} !^123.456.789.000 # whatismyip.com
RewriteCond %{REQUEST_URI} !/maintenance.html$ [NC]
RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif) [NC]
RewriteRule .* /maintenance.html [R=302,L]
</IfModule>
@tarciozemel
tarciozemel / gist:4511190
Created January 11, 2013 14:46
WordPress: busca com Custom Fields
//
// By default, WordPress comes with a handy search but it only search in post
// titles and contents. If you are working on a custom post type, you most
// probably using custom fields to store its attributes. For example, A
// Property custom post type would have address, city and state custom fields.
// You may have used WP_Query object with meta_query setup, But, it does not
// work. If you do not use “s” attribute, it will overwrite the default search
// and If you use it, it will not return the expected results. This snippet will
// use posts_clauses filter to inject the meta query that will combine with the
// WordPress’s default search parameter.