Skip to content

Instantly share code, notes, and snippets.

@thaicloud
thaicloud / Sass mixin for full-width element
Last active June 29, 2016 17:16
Sass mixin for full-width element (for use when inside a non-full-width container)
@mixin full-width($bgcolor: #fff) {
position: relative;
&:before, &:after {
content: "";
position: absolute;
background: $bgcolor;
top: 0;
bottom: 0;
width: 9999px;
}
@thaicloud
thaicloud / Create a dummy WP-CLI command
Last active June 29, 2016 19:09
Create a dummy WP-CLI command, passing 1 parameter
<?php
/**
*
* Plugin Name: Demo - MJ WP-CLI Command
* Description: Create WP CLI Command
* Author: MJ
* Version: 1.0
*/
@thaicloud
thaicloud / git-workflow
Last active August 29, 2015 14:26
Example Git Feature Workflow
// Create feature branch
git checkout -b feature/tiny-change
echo 'Hello world' > foo.txt // make whatever changes
git add .
git commit -m "Add great text file"
git push origin feature/tiny-change
// Happy with changes, merge to develop
@thaicloud
thaicloud / Using WP HTTP API
Last active July 14, 2022 15:35
Sending Authenticated Requests Using WP HTTP API
$wp_request_headers = array(
'Authorization' => 'Basic ' . base64_encode( 'username:password' )
);
$wp_request_url = 'http://localserver/wordpress-api/wp-json/wp/v2/posts/52';
$wp_delete_post_response = wp_remote_request(
$wp_request_url,
array(
'method' => 'DELETE',
@thaicloud
thaicloud / Bash archive-branch
Last active June 29, 2016 17:10
Bash archive-branch
# Check out a Git branch, tag it with archive/, remove
# the remote branch, and get ready to do it all over again.
#
# USAGE:
# archive-branch feature/my-branch
function archive-branch() {
if [[ "$1" == "master" ]]; then
echo "I'm sorry, $USER. I'm afraid I can't do that. (Cannot archive master branch)"
return
fi
@thaicloud
thaicloud / Clear Node's NPM cache
Last active June 29, 2016 17:10
Clear Node's NPM cache
# rm -rf ~/.npm
# npm cache clear
var React = require('react'); // include library