Skip to content

Instantly share code, notes, and snippets.

<style>
:root {
--barHeight: 20%;
}
#hamburger {
width: 30px;
height: 30px;
overflow: hidden;
position: relative;
border: 10px solid transparent;
[
{ "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 February 2, 2018 03:28
Send a string to remote server to be read by a custom widget for StatusBoard via terminal
#!/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 February 3, 2018 02:48
Turn slack messages into a activity feed widget with 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
<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 February 1, 2018 19:17
restrict a user to just a page
<?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 () {
<?php
header('Location: http://localhost/phpmyadmin/'.(strnatcmp(phpversion(),'5.5.0') >= 0 ? "new" : "old")."/");
?>
<?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 February 3, 2018 03:00
Gutenberg hello world
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
<?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;
});