Skip to content

Instantly share code, notes, and snippets.

View natebeaty's full-sized avatar
🦉

Nate Beaty natebeaty

🦉
View GitHub Profile
@natebeaty
natebeaty / maybe-useful-php-hooha-for-alec.php
Last active April 25, 2016 21:59
untested comic image PHP hooha for alec
<?php
// Pull all files in a directory into an array
$comic_dir = $_GET['comic']; // something like '001'
$files_in_dir = dirList("/archive/$comic_dir/",'\d+\.\w{3}'); // assumes files are named 5.jpg, can adjust regex if you have other files in dir you don't want to output (like a cover image)
function pageJumpLinks($num_pages) {
$output = '';
for ($i=0; $i < $num_pages; $i++) {
$output .= '<a href="#' . $i . '">' . $i . '</a> | ';
}
@natebeaty
natebeaty / mapscorps-json-convert.rb
Created November 8, 2016 19:50
ruby script to convert json output from mashape/boundaries-io to google maps friendly json
#!/usr/bin/ruby
require 'json'
output = ''
file = File.read('niagarazips.json')
city = 'NiagaraFalls'
# file = File.read('nczips.json')
# city = 'NashEdgecombe'
# file = File.read('nyzips.json')
# city = 'NewYork'
@natebeaty
natebeaty / csv-convert.rb
Last active November 8, 2016 22:18
quick ruby script to convert 2 CSV files of community areas + community lat/lng boundary paths
#!/usr/bin/ruby
require 'CSV'
output = ''
# get areas
areas = {}
CSV.foreach("community-areas.csv", headers:true) do |row|
areas[row['shapeid']] = row['community']
end
@natebeaty
natebeaty / cmb2-tabs.md
Last active September 28, 2017 17:46
CMB2 tabs for repeatable groups

in fb_init.php (or any other file called from functions.php)

// Custom Admin styles + JS
add_action('admin_enqueue_scripts', function($hook){
  wp_enqueue_style('fb_wp_admin_css', Assets\asset_path('styles/admin.css'));
  wp_enqueue_script('fb_wp_admin_js', Assets\asset_path('scripts/admin.js'), ['jquery'], null, true);
}, 100);

add to manifest.json

@natebeaty
natebeaty / server.js
Last active February 2, 2018 20:01
socket.io + redis notifications server
var app = require('express')();
var server = require('http').Server(app);
var io = require('socket.io')(server);
var redis = require('redis').createClient({host: 'localhost'});
var port = process.env.PORT || 8890;
server.listen(port);
io.on('connection', function (socket) {
socket.on('subscribe', function(data) {
@natebeaty
natebeaty / fb.rb
Last active March 13, 2018 22:06
parse my facebook deactivation time since 2012
#!/usr/bin/ruby
require 'date'
logtext = "Account Deactivated : Wednesday, August 8, 2012 at 8:52pm CDT
Account Reactivated : Sunday, November 4, 2012 at 3:14pm CST
Account Deactivated : Sunday, November 4, 2012 at 3:25pm CST
Account Reactivated : Monday, December 24, 2012 at 9:42pm CST
Account Deactivated : Monday, December 24, 2012 at 10:02pm CST
Account Reactivated : Thursday, January 10, 2013 at 9:07am CST
Account Deactivated : Thursday, January 10, 2013 at 9:14am CST
@natebeaty
natebeaty / deploy.sh
Created April 20, 2018 15:10
deploy script for a grav site
#!/bin/bash
USER=username
PROJECT=projectname
SERVER=siteurl.com
rsync --delete -rvzce ssh . ${USER}@${SERVER}:webapps/${PROJECT}/ \
--exclude /.git \
--exclude /assets \
--exclude /tmp \
--exclude /cache \
@natebeaty
natebeaty / _navigation.twig
Last active June 20, 2018 18:42
nested navigation partial for Navigation structure in Craft 3
{% set headerImage = pageHeader.image.one() %}
{% set grayImage = craft.imager.transformImage(headerImage, {
width: 1000,
height: 1000,
mode: 'crop',
position: '20% 65%',
effects: { grayscale: true, gamma: 1.5 }
}) %}
<div class="page-header">
<div class="image-wrap">
@natebeaty
natebeaty / sphp.sh
Last active March 19, 2019 19:10 — forked from marlocorridor/sphp.sh
sphp.sh w/ php 7.3 support
#!/bin/bash
# Creator: Phil Cook
# Email: phil@phil-cook.com
# Twitter: @p_cook
brew_prefix=$(brew --prefix | sed 's#/#\\\/#g')
brew_array=("5.6","7.0","7.1","7.2","7.3")
php_array=("php@5.6" "php@7.0" "php@7.1" "php@7.2" "php@7.3")
valet_support_php_version_array=("php@5.6" "php@7.0" "php@7.1" "php@7.2" "php@7.3")
php_installed_array=()
@natebeaty
natebeaty / stickyHeaders.js
Created October 21, 2019 17:28
es6 module for push-as-you-scroll sticky headers (currently set for vertical, rotated 90º headers)
// Vertical sticky headers with push effect
//
// Use:
// import stickyHeaders from './stickyHeaders';
// stickyHeaders.init($('.sticky-header'), $(window), 20);
//
// Markup:
// <div class="sticky-header">
// <div class="sticky-title">Test Header</div>
// </div>