Skip to content

Instantly share code, notes, and snippets.

View nootrope's full-sized avatar
💭
Pushing bits

Alberto Gaitán nootrope

💭
Pushing bits
  • planet earth
View GitHub Profile
<div class="relative" style="padding-top: 56.25%">
<iframe class="absolute inset-0 w-full h-full" src="https://www.youtube-nocookie.com/embed/FMrtSHAAPhM" frameborder="0" …></iframe>
</div>
exports.handler = async (event) => {
const response = {
statusCode: 301,
headers: {
Location: 'https://destination-domain.tld'
}
};
return response;
};
@nootrope
nootrope / child_theme_template_enqueue_styles.php
Created May 19, 2018 23:29
WordPress enqueue styles by template
<?php
/***
From: https://developer.wordpress.org/reference/functions/wp_enqueue_style/
This is a conditional loading of css file by page template (css will be loaded on on the pages with template-name.php).
You can change the condition to others. The code should be used in your theme’s function.php.
Notice: The code works for child themes. If you want to use it in a parent theme replace get_stylesheet_directory_uri() with get_stylesheet_uri().
**/
$handle = 'wpdocs';
wp_register_style( $handle, get_stylesheet_directory_uri().'/relative/path/to/stylesheet.css', array(), '', true );
if ( is_page_template( 'template-name.php' ) ) {
@nootrope
nootrope / screen_cheatsheet.md
Last active August 31, 2017 12:51
screen command cheatsheet

Case: Session lists as attached but cannot be resumed.

Solution: Resume it on the current terminal after detaching it from the original, unavailable terminal.

screen -d -r [pid]


Case: Kill one screen session

screen -X -S [pid] quit

@nootrope
nootrope / functions.php
Created August 3, 2017 20:30
Wordpress: enqueue parent theme styles
<?php
add_action( 'wp_enqueue_scripts', 'usr_enqueue_parent_styles' );
function usr_enqueue_parent_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}
?>
@nootrope
nootrope / tmux.md
Created May 28, 2016 20:17 — forked from andreyvit/tmux.md
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@nootrope
nootrope / brew_install_python_upgrade_pip.md
Last active April 10, 2016 14:49
About Installing Pythons with Homebrew

If you use Homebrew to install Python and Python3, make sure to install python3 first. Otherwise, when trying to upgrade pip3 withpip3 install --upgrade pip it will clobber default command pip and link it to the python3 packages, i.e., pip3.

To avoid a lot of wasted time and relinking I do this:

# First install Python3
$ brew install python3
$ brew linkapps python3
$ pip3 install --upgrade pip setuptools
# Then install Python 2
#! /bin/sh -
#
# Install OpenVPN connections for all available
# regions to NetworkManager
#
# Requirements:
# should be run as root
# python and openvpn (will be installed if not present)
#
# Usage:
@nootrope
nootrope / shrink-iframe.css
Last active September 21, 2015 00:44 — forked from DavidWells/shrink-iframe.css
Shrink Contents of Iframe with CSS
/ This shrinks content in iframes /
iframe {
-webkit-transform-origin: 0px 0px;
transform-origin: 0px 0px 0px;
-webkit-transform: scale(0.8446726572528884);
transform: scale(0.8446726572528884);
margin-left: 110.67073170731703px;
margin-top: 10px;
}
@nootrope
nootrope / gist:81fb593a1cf1131dd227
Last active September 21, 2015 00:44 — forked from DavidWells/gist:ed7324739059cea4ee8d
git ignore for wordpress project
# WPEngine Deploy - wp-content folder #
###########################################
# Ignore all files except for the wp-content directory
*
# Don't ignore directories themselves, else we can't add anything to the repository
!*/
# Don't ignore the the following directory
!**/wp-content/*
# or its subdirectories