Skip to content

Instantly share code, notes, and snippets.

View natebeaty's full-sized avatar
🦉

Nate Beaty natebeaty

🦉
View GitHub Profile
@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 / 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 / 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 / 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> | ';
}