Skip to content

Instantly share code, notes, and snippets.

Avatar

David Sword davidsword

View GitHub Profile
View CSS MenuNav Hamburger Animation.html
<style>
:root {
--barHeight: 20%;
}
#hamburger {
width: 30px;
height: 30px;
overflow: hidden;
position: relative;
border: 10px solid transparent;
View Default (OSX).sublime-keymap
[
{ "keys": ["super+alt+f"], "command": "show_panel", "args": {"panel": "find", "reverse": false} },
{ "keys": ["super+f"], "command": "show_panel", "args": {"panel": "replace", "reverse": false} },
]
@davidsword
davidsword / statusboardmsg.sh
Last active Feb 2, 2018
Send a string to remote server to be read by a custom widget for StatusBoard via terminal
View statusboardmsg.sh
#!/bin/bash
echo -e "Message: \c "
read message
echo $message | ssh -i ~/.ssh/rsa.pem user@host "cat > /var/www/message.txt"
echo -e "Done.\n\n"
@davidsword
davidsword / slack-call.php
Created Feb 3, 2018
Turn slack messages into a activity feed widget with php
View slack-call.php
<?php
date_default_timezone_set('America/Vancouver');
if ( date('G') > 7 && date('G') < 19 ) { // only update between 7am and 7pm
require('slack-api.php'); // via Yong Zhen <yz@stargate.io>: https://github.com/10w042/slack-api/blob/master/Slack.php
// authentication
$token = 'xxxx-xxxxxxxxxxxx-xxxxxxxxxxxx-xxxxxxxxxxxxx-xxxxxx';
// options
View read-gmail-inbox-with.php
<h2>Recent Emails</h2>
<?php
$service = new Google_Service_Gmail($client);
$results = $service->users_messages->listUsersMessages('me',array('maxResults' => 5));
$messageList = $results->getMessages();
$inboxMessage = array();
@davidsword
davidsword / restrict-multiple-users.php
Created Feb 1, 2018
restrict a user to just a page
View restrict-multiple-users.php
<?php
$restricted = array(
56834 => 67, // user id => page id
56832 => 764, // user id => page id
56901 => 'ai1ec_event', // user id => post_type
);
// SOME CSS ------------------------------------------------------------
add_action('admin_head',function () {
View phpmyadmin-router.php
<?php
header('Location: http://localhost/phpmyadmin/'.(strnatcmp(phpversion(),'5.5.0') >= 0 ? "new" : "old")."/");
?>
View extending-wc-square.php
<?php
add_action('wc_square_loaded',function(){
if (class_exists('Woocommerce_Square')) {
add_action( 'plugins_loaded', function(){
// get WooCommerce_Square
$wcsm = Woocommerce_Square::instance();
// startup, (aka `Woocommerce_Square::init()` rebuilt)
@davidsword
davidsword / myblock.js
Last active Feb 3, 2018
Gutenberg hello world
View myblock.js
var el = wp.element.createElement,
registerBlockType = wp.blocks.registerBlockType,
withAPIData = wp.components.withAPIData;
registerBlockType( 'sandbox/myblock', {
title: 'My Block',
icon: 'archive',
category: 'widgets',
// representation of the block in the editor's context
View check-if-using-gutenberg.php
<?php
add_action('body_class', function($classes){
if (function_exists('the_gutenberg_project') && gutenberg_post_has_blocks( get_the_ID() ) )
$classes[] = 'using-gutenberg';
return $classes;
});