Skip to content

Instantly share code, notes, and snippets.

View anova's full-sized avatar

Necat Bolpaça anova

View GitHub Profile
@anova
anova / mac-font-smoothing-antialiased.css
Created May 3, 2021 19:48
MAC renders fonts heavier, this trick solves
/* https://www.c2software.com/c2-blog/fonts-appearing-bold-on-mac.aspx */
.selector {
-webkit-font-smoothing: antialiased;
}
@anova
anova / custom-media-upload.js
Last active September 20, 2022 20:47
Custom media upload component for Wordpress Gutenberg.
import { MediaUpload } from '@wordpress/block-editor';
import { Button } from '@wordpress/components';
function CustomMediaUpload(props){
return <MediaUpload
onSelect={ media => { props.onMediaSelected(media.url) } }
type="image"
value={ props.mediaUrl }
render={
({open}) => {
'use strict';
const { series, parallel, src, watch, dest } = require('gulp');
const sass = require('gulp-sass');
const autoprefixer = require('gulp-autoprefixer');
sass.compiler = require('dart-sass');
const browserSync = require('browser-sync').create();
const sass_src = 'wp-content/themes/theme-name/sass/**/{*.scss,_*.scss}';
<?php
$pages = get_pages( [
'meta_key' => '_wp_page_template',
'meta_value' => 'template-example.php',
] );
//$pages now contains pages which uses `template-example.php` as template.
$pages = get_pages([
'child_of' => get_the_ID(),
'meta_key' => '_wp_page_template',
@anova
anova / table-to-array.js
Created December 3, 2020 09:26
Extract table text into nested arrays.
[...document.querySelector('table').querySelectorAll('tr')].map(tr => [...tr.querySelectorAll('td')].map(td => td.innerText))
@anova
anova / .htaccess
Last active March 15, 2023 12:38
Multisite and giving wordpress its own directory
<IfModule mod_rewrite.c>
# not localhost:
# RewriteCond %{HTTP_HOST} \.
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
#eliminate root path access denied: (without placeholder index.php)
RewriteRule ^(/)?$ wp/index.php [L]
# add a trailing slash to /wp-admin
@anova
anova / img-tags-without-an-alt-attribute.md
Created November 26, 2020 12:41
Using regular expressions to find img tags without an alt attribute
@anova
anova / zend-framework-1-set-include-path.php
Created November 24, 2020 12:58
ZF1 set include path
<?php
// https://stackoverflow.com/a/6840407
set_include_path(implode(PATH_SEPARATOR, array(
__DIR__ . '/',
get_include_path()
)));
@anova
anova / _Rating.cshtml
Created October 14, 2020 12:13
Pass a variable to partial (asp.net razor c# cshtml)
@{
double rating = 0;
if (this.ViewData.ContainsKey("Rating"))
{
rating = Convert.ToDouble(ViewData["Rating"]);
}
}
@anova
anova / shortenName.js
Created September 26, 2020 08:47
Name Surname -> N. S.
function shortenName(name) {
return name.split(' ').map(word => `${word.charAt(0)}.`).join(' ');
}