Skip to content

Instantly share code, notes, and snippets.

View badcrocodile's full-sized avatar

Jason badcrocodile

  • The Motley Fool
  • Austin, Texas
View GitHub Profile
@badcrocodile
badcrocodile / vifmrc
Created October 1, 2023 16:46
Vifm config vifmrc
" vim: filetype=vifm :
" Sample configuration file for vifm on OSX (last updated: 2 April, 2023)
" You can edit this file by hand.
" The " character at the beginning of a line comments out the line.
" Blank lines are ignored.
" The basic format for each item is shown with an example.
" ------------------------------------------------------------------------------
" Main settings
" ------------------------------------------------------------------------------
@badcrocodile
badcrocodile / monitor_and_sync.sh
Last active October 2, 2023 17:27
Monitor multiple source directories for changes and sync to given destination
#!/bin/bash
# Ensure fswatch is installed
if ! command -v fswatch &>/dev/null; then
echo "Error: fswatch is not installed. Please install it before running this script."
exit 1
fi
if [ $# -ne 1 ]; then
echo "Usage: $0 <2 letter country code>"
<?php
add_action('wp_ajax_addTagToStory', 'add_tag_to_story');
add_action('wp_ajax_nopriv_addTagToStory', 'add_tag_to_story');
function add_tag_to_story() {
// Here you have everything passed from your JS function available as $_POST
// With $_POST['postID'], you can do almost any post manipulation you need
var_dump($_POST);
@badcrocodile
badcrocodile / post.js
Created September 21, 2020 13:53
Displaying a basic post with Author and Categories in Frontity
import React from "react";
import { connect, styled } from "frontity";
import Link from "./link";
const Post = ({ state }) => {
const data = state.source.get(state.router.link); // state.source.get('url-string')
const post = state.source[data.type][data.id]; // state.source[url-string -> type][url-string -> id] date.type is Post; data.id is Post ID
const author = state.source.author[post.author]; // state.source.author[post -> author]
@badcrocodile
badcrocodile / post.js
Last active September 20, 2020 03:29
post.js
import React from "react";
import { connect, styled } from "frontity";
console.log("Hello there");
const Post = ({ state }) => {
const data = state.source.get(state.router.link); // state.source.get('url-string')
const post = state.source[data.type][data.id]; // state.source[url-string -> type][url-string -> id] date.type is Post; data.id is Post ID
const author = state.source.author[post.author]; // state.source.author[post -> author]
@badcrocodile
badcrocodile / common.css
Last active May 2, 2018 16:06 — forked from TwisterMc/common.css
Vivaldi Tab Loading Indicator
/* append this to the bottom of the common.css file */
/* via https://forum.vivaldi.net/topic/6289/tab-loading-indicator/24?page=2 */
/* Applications/Vivaldi/Contents/Versions/1.1323.4343/vivaldi/style/common.css
@keyframes fade{
from {opacity:1}
to {opacity:0.4}
}
/* Either pulse the "X"... */
.button-toolbar.reload.loading svg{
animation-name: fade;
@badcrocodile
badcrocodile / fusionchart.js
Created January 18, 2018 02:47
Use JS and PHP to render graph
<script type="text/javascript">
FusionCharts.ready(function(){
var fusioncharts = new FusionCharts({
type: 'column2d',
renderAt: 'global-food-safety-audit-rating',
width: '500',
height: '300',
dataFormat: 'json',
dataSource: <?= $chart_data ?>
}
@badcrocodile
badcrocodile / guzzle.php
Created January 18, 2018 00:25
Using guzzle with api
// Using Guzzle
$client = new Client();
$response = $client->get($this->api_url_path);
$this->api_data = $response->getBody()->getContents();
var_dump($this->api_data);
@badcrocodile
badcrocodile / directory_up.php
Created March 18, 2017 02:09
Traverse up in directory <= 5.3
<?php
require(dirname(__FILE__).'/../Extensions/PDF_FancyRow.php');
?>
@badcrocodile
badcrocodile / EnqueueScripts.php
Created February 4, 2017 19:38
One way to add_action ooo style
<?php
namespace IngredientManager;
/**
* Usage: In calling script:
* $enqueue_scripts = new EnqueueScript
*/
class EnqueueScript
{