Skip to content

Instantly share code, notes, and snippets.

View slackday's full-sized avatar

Stefan Lindberg slackday

View GitHub Profile
@slackday
slackday / vagrant-update-host-date-time.sh
Created November 7, 2022 10:05
vagrant update host date time
sudo date -s "$(curl -I google.com 2>&1 | grep Date: | cut -d' ' -f3-6)Z"
@slackday
slackday / app.ninja-forms.php
Last active April 11, 2022 14:32
Fix for loading Ninja forms preview in Sage theme version 10
<?php
namespace App;
/**
* Set preview page for ninja forms
*/
add_filter('template_include', function ($template) {
if (substr($template, -9) === 'index.php') {
$ninja_forms_id = isset($_GET['nf_preview_form']) ? $_GET['nf_preview_form'] : null;
@slackday
slackday / hide-sticky-post-option.php
Last active August 30, 2021 20:38
Hide sticky post option on WordPress 5.8
// Target the first panel__row in the scheduel part of sidebar on post type = post
add_action('admin_head', function () {
echo '
<style>
body.wp-admin.post-type-post .interface-interface-skeleton__sidebar .components-panel__body.edit-post-post-status .edit-post-post-schedule + .components-panel__row {
display: none;
}
</style>
';
@slackday
slackday / example.ts
Last active May 15, 2020 10:57
Typescript/styled-components/no-explicit-any question
// Project 1:
// Styled componet wrapper might look like this
const styledFactory = (
target: any,
displayName: string,
...systemFunctions: styleFn[]
): any => {
const Component = styled(target)`
min-width: 0;
@slackday
slackday / acf-convert-field-to-repeater.sql
Last active September 29, 2020 15:02
WordPress ACF rename field after converting to repeater
-- This transaction converts previous acf file field named
-- 'course_field_schedule_file' into acf repeater field
-- containing single file field
START TRANSACTION;
SET @repeater_name = 'course_field_schedule_file';
SET @field_name = 'file';
INSERT INTO
wp_postmeta (post_id, meta_key, meta_value)
SELECT post_id, CONCAT(@repeater_name, '_0_', @field_name), meta_value FROM wp_postmeta WHERE meta_key = @repeater_name AND meta_value != '';
@slackday
slackday / appdomain.conf
Last active June 27, 2019 00:47
Serve static app like Create React App from Nginx subdirectory
# Example config for serving a static page under nginx subdirectory
# Include this config in your server block and change the paths
#
# This is useful because we can server the same app from /subdirectory/subsubdirectory
# Where the subsubdirectory could represent :slug or :id in the client side routing.
location ^~ /subdirectory/ {
alias /path/to/static/webroot/;
if (!-e $request_filename) {
@slackday
slackday / wkhtmltopdf.md
Last active April 12, 2019 12:44
Install wkhtmltopdf 0.12.5-1 on bento/ubuntu-18.04
sudo apt-get install -y software-properties-common && \
sudo apt-add-repository -y "deb http://security.ubuntu.com/ubuntu bionic-security main" && \
sudo add-apt-repository ppa:malteworld/ppa && \
sudo apt-get -yq update && \
sudo apt-get install -y pdftk libxrender1 libfontconfig1 libx11-dev libjpeg62 libxtst6 \
                           fontconfig xfonts-75dpi xfonts-base libpng16-16 xvfb && \
wget "https://downloads.wkhtmltopdf.org/0.12/0.12.5/wkhtmltox_0.12.5-1.bionic_amd64.deb" && \
sudo dpkg -i wkhtmltox_0.12.5-1.bionic_amd64.deb && \
sudo apt-get -f install
@slackday
slackday / keybase.md
Created September 22, 2016 20:32
Keybase

Keybase proof

I hereby claim:

  • I am slackday on github.
  • I am slackday (https://keybase.io/slackday) on keybase.
  • I have a public key whose fingerprint is 85DC BF91 73A0 F254 845B 406E DDEA 8910 6CD0 63A7

To claim this, I am signing this object: