Skip to content

Instantly share code, notes, and snippets.

Jacob Bearce JacobDB

Block or report user

Report or block JacobDB

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View inline-svg-function.scss
// Replace letters
@function str-replace($string, $search, $replace: '') {
$index: str-index($string, $search);
@if $index {
@return str-slice($string, 1, $index - 1) + $replace + str-replace(str-slice($string, $index + str-length($search)), $search, $replace);
}
@return $string;
}
@JacobDB
JacobDB / wkqx.php
Created Mar 15, 2016
Web scraper to convert TuneGenie in to RSS
View wkqx.php
<?php
$url = "http://wkqx.tunegenie.com/";
$title = "WKQX RSS Feed";
$description = "A constantly updated feed for WKQX's playlist";
$userAgent = "Googlebot/2.1 (http://www.googlebot.com/bot.html)";
header("Content-type: text/xml; charset=utf-8", true);
echo "<?xml version='1.0' encoding='UTF-8' ?>" . PHP_EOL;
echo "<rss version='2.0'>" . PHP_EOL;
@JacobDB
JacobDB / init.php
Created Jul 19, 2019
Initialization script for git-deploy
View init.php
<?php
define("TOKEN", "g430vdsj07jDSFj93g21");
define("REMOTE_REPOSITORY", "https://gitlab+deploy-token-123:g430vdsj07jDSFj93g21@gitlab.com/JacobTheDev/new-site.git");
define("DIR", "{$_SERVER["DOCUMENT_ROOT"]}/.gitlab/repository/");
define("BRANCH", "refs/heads/master");
define("LOGFILE", "deploy.log");
define("GIT", "/usr/bin/git");
define("MAX_EXECUTION_TIME", 180);
define("BEFORE_PULL", "");
define("AFTER_PULL", "");
View acf-register-json-fields.php
<?php
/**
* Read ACF fields from JSON
*/
function PREFIX_acf_register_json_fields() {
if (function_exists("acf_add_local_field_group")) {
$acf_json_data = locate_template("path/to/advanced-custom-fields.json");
$custom_fields = $acf_json_data ? json_decode(file_get_contents($acf_json_data), true) : array();
foreach ($custom_fields as $custom_field) {
@JacobDB
JacobDB / install-acf.sh
Last active May 21, 2019
Download and install ACF Pro via a bash script – to be used with WP CLI. Set an environemnt variable ACF_KEY first!
View install-acf.sh
#!/bin/sh
# Adapted from https://support.advancedcustomfields.com/forums/topic/download-acf-with-wp-cli-on-clean-install/#post-26191
# get plugin path
acf_zip_file="$(wp plugin path)/advanced-custom-fields-pro.zip"
# get acf zip file
wget -O ${acf_zip_file} "http://connect.advancedcustomfields.com/index.php?p=pro&a=download&k=$ACF_KEY"
@JacobDB
JacobDB / .scripts.log
Created Apr 10, 2019
Log of output of `.scripts` for VS Code Chrome Debugger debugging https://github.com/Microsoft/vscode-chrome-debug/issues/802
View .scripts.log
.scripts
› VM83
› VM84
› http://framework.localhost
› http://framework.localhost/wp-content/themes/framework/assets/scripts/fontawesome.cc84fb87.js (c:\Users\Jacob\Repositories\new-site\dev\assets\scripts\fontawesome.cc84fb87.js)
› http://framework.localhost/wp-content/themes/framework/assets/scripts/modern.08943789.js (c:\Users\Jacob\Repositories\new-site\dev\assets\scripts\modern.08943789.js)
› webpack:///(webpack)/buildin/module.js
› webpack:///./node_modules/@dotsunited/load-css-polyfill/dist/load-css-polyfill.mjs
› webpack:///./node_modules/@fortawesome/fontawesome-svg-core/index.es.js
View modern.08943789.js
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
@JacobDB
JacobDB / atom.sh
Last active Feb 13, 2019
Alias used to open Atom from within Bash on WSL.
View atom.sh
atom() {
target_path=$(wslpath -a -w $(readlink -f $1)) # resolve the path
(/mnt/c/Windows/System32/cmd.exe /C "atom.cmd $target_path" &> /dev/null) # open the path
}
@JacobDB
JacobDB / code.sh
Last active Feb 13, 2019
Alias used to open Visual Studio Code from within Bash on WSL.
View code.sh
code() {
target_path=$(wslpath -a -w $(readlink -f $1)) # resolve the path
(/mnt/c/Windows/System32/cmd.exe /C "Code $target_path" &> /dev/null) # open the path
}
@JacobDB
JacobDB / renew-letsencrypt.sh
Created Nov 16, 2018
Simple bash script to disable UFW, renew Lets Encrypt certificates, restart GitLab nginx, and re-enable UFW
View renew-letsencrypt.sh
ufw disable
certbot renew --renew-hook "/usr/bin/gitlab-ctl restart nginx"
ufw --force enable
You can’t perform that action at this time.