Skip to content

Instantly share code, notes, and snippets.

View vyskoczilova's full-sized avatar

Karolína Vyskočilová vyskoczilova

View GitHub Profile
@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@pitch-gist
pitch-gist / gist:2999707
Created June 26, 2012 22:21
HTML: Simple Maintenance Page
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
@amurrell
amurrell / custom-post-hierarchy.php
Last active March 26, 2024 20:13
Allow wordpress posts to have hierarchy - figures out slugs
<?php
add_action('registered_post_type', 'make_posts_hierarchical', 99, 2);
/**
* Ensure posts post type is hierarchal and allows page attributes
*
* Initial Setup - Runs after each post type is registered
*/
function make_posts_hierarchical($post_type, $pto)
@KevinBatdorf
KevinBatdorf / gutenberg-helpers.js
Last active March 22, 2024 20:00
WordPress check Gutenberg editor is ready
import { select, subscribe } from '@wordpress/data'
export function whenEditorIsReady() {
return new Promise((resolve) => {
const unsubscribe = subscribe(() => {
// This will trigger after the initial render blocking, before the window load event
// This seems currently more reliable than using __unstableIsEditorReady
if (select('core/editor').isCleanNewPost() || select('core/block-editor').getBlockCount() > 0) {
unsubscribe()
resolve()
@nickcernis
nickcernis / mariadb-brew-macos.md
Created July 13, 2020 15:13
Install MariaDB with brew on macOS and fix the “access denied” issue

Attempting mysql -u root fails with Access denied for user 'root'@'localhost immediately after doing brew install mariadb and starting mariadb with brew services start mariadb.

To fix it (with MariaDB still running):

  1. sudo mysql then enter your Mac user password
  2. ALTER USER 'root'@'localhost' IDENTIFIED BY 'newrootpassword'; replacing newrootpassword with the password you wish to use for the MariaDB root user.
  3. Ctrl-C to exit mysql.

You should then be able to connect to MariaDB with mysql -u root -p, then entering the root password when prompted.

@spyesx
spyesx / string-to-slug.js
Last active March 15, 2024 12:05
String to slug in JS (wordpress sanitize_title)
var string_to_slug = function (str)
{
str = str.replace(/^\s+|\s+$/g, ''); // trim
str = str.toLowerCase();
// remove accents, swap ñ for n, etc
var from = "àáäâèéëêìíïîòóöôùúüûñçěščřžýúůďťň·/_,:;";
var to = "aaaaeeeeiiiioooouuuuncescrzyuudtn------";
for (var i=0, l=from.length ; i<l ; i++)
@jenssogaard
jenssogaard / ACF Gutenberg get block fields
Created February 22, 2019 21:08
Helper class for ACF and Gutenberg. Get blocks fields by passing block_id and post_id.
<?php
namespace JensSogaard;
class BlockHelper
{
/**
* Gets ACF fields for a specific block on a given post
* @author Jens Soegaard <jens@jenssogaard.com>
*/
public function getBlockFromPage(string $block_id, int $post_id)
@taufik-nurrohman
taufik-nurrohman / php-html-css-js-minifier.php
Last active February 23, 2024 04:30
PHP Function to Minify HTML, CSS and JavaScript
<?php
// Based on <https://github.com/mecha-cms/x.minify>
namespace x\minify\_ { // start namespace
$n = __NAMESPACE__;
\define($n . "\\token_boolean", '\b(?:true|false)\b');
\define($n . "\\token_number", '-?(?:(?:\d+)?\.)?\d+');
@HoldOffHunger
HoldOffHunger / bradvin.social.share.urls.txt
Last active February 1, 2024 19:10
Social Share URL's (Summary)
https://www.facebook.com/sharer.php?u={url}
https://www.facebook.com/dialog/share?app_id={app_id}&display={page_type}&href={url}&redirect_uri={redirect_url}
https://reddit.com/submit?url={url}&title={title}
https://twitter.com/intent/tweet?url={url}&text={title}&via={user_id}&hashtags={hash_tags}
https://www.linkedin.com/sharing/share-offsite/?url={url}
https://api.whatsapp.com/send?phone={phone_number}&text={title}%20{url}
https://www.tumblr.com/widgets/share/tool?canonicalUrl={url}&title={title}&caption={text}&tags={hash_tags}
http://pinterest.com/pin/create/button/?url={url}
https://www.blogger.com/blog-this.g?u={url}&n={title}&t={text}
https://www.evernote.com/clip.action?url={url}&title={title}