Skip to content

Instantly share code, notes, and snippets.

Avatar

Jake Bathman jakebathman

View GitHub Profile
@jakebathman
jakebathman / geoDistance.php
Last active Jul 15, 2020
Lat/Lon Distance Calculator
View geoDistance.php
<?php
/**
* Calculate the distance between two points on a sphere
*
* Implements the Haversine formula: http://en.wikipedia.org/wiki/Haversine_formula
*
* More advanced calculation (good for antipodal points) can be used by using
* FALSE for $boolUseHaversine. This will use another solution to the Great-circle
* ditance problem (http://en.wikipedia.org/wiki/Great-circle_distance), implementing
* the Vincenty formula (http://en.wikipedia.org/wiki/Vincenty%27s_formulae#Nearly_antipodal_points).
@jakebathman
jakebathman / botPost.php
Last active Jul 12, 2020
GroupMe bot post function including @mentions
View botPost.php
<?php
/**
* Post a message from a bot to a group
*
* $groupId (string) GroupId of the group to post the message
* $strMessage (string) Text of the message to post (limit of 1000 characters)
* $strBotId (string) ID of the bot which will post the message
* $mentionUsers (array) [optional] array of userIds to mention (uses attachment)
* Example array of userIds:
@jakebathman
jakebathman / centos_setup.sh
Created Mar 14, 2017
CentOS box initial setup script
View centos_setup.sh
#!/bin/bash
# Base box setup steps
# Do the steps below as root user
sudo su
# The steps below are based on a clean install on
# CentOS 7 (build 1608)
# http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud-1608.raw.tar.gz
@jakebathman
jakebathman / StateBoundaries.sql
Last active Jun 10, 2020
The approximate max/min latitude and longitude for all states and major territories
View StateBoundaries.sql
-- Create the table
CREATE TABLE IF NOT EXISTS `StateBoundaries` (
`State` varchar(10) DEFAULT NULL,
`Name` varchar(255) DEFAULT NULL,
`MinLat` varchar(50) DEFAULT NULL,
`MaxLat` varchar(50) DEFAULT NULL,
`MinLon` varchar(50) DEFAULT NULL,
`MaxLon` varchar(50) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@jakebathman
jakebathman / init.lua
Last active May 18, 2020
Hammerspoon config
View init.lua
-- Clear the console
hs.console.clearConsole()
-- Set the default grid
hs.grid.MARGINX = 0
hs.grid.MARGINY = 0
hs.grid.GRIDWIDTH = 20
hs.grid.GRIDHEIGHT = 100
-- Also can be set using hs.grid.setGrid'20x100'
@jakebathman
jakebathman / jsonToCsv.php
Last active May 8, 2020 — forked from Kostanos/json-to-csv.php
A function to convert a JSON string (or a PHP array) to a CSV file or CSV string echoed to the browser
View jsonToCsv.php
<?php
/*
*
* Based on (forked from) the work by https://gist.github.com/Kostanos
*
* This revision allows the PHP file to be included/required in another PHP file and called as a function, rather than focusing on command line usage.
*
* Convert JSON file to CSV and output it.
*
* JSON should be an array of objects, dictionaries with simple data structure
@jakebathman
jakebathman / remove_laravel_comments.php
Last active Apr 29, 2020
Remove comments from fresh Laravel files
View remove_laravel_comments.php
<?php
/*
|--------------------------------------------------------------------------
| Remove Laravel Comments
|--------------------------------------------------------------------------
|
| Just made a new Laravel project, but don't want all those big
| comment blocks? Put this in the root of your project and run
| "php remove_laravel_comments.php"
|
@jakebathman
jakebathman / regex.md
Last active Jan 22, 2020
Laravel 5.8 deprecated helpers regex search
View regex.md
(array_add|array_collapse|array_divide|array_dot|array_except|array_first|array_flatten|array_forget|array_get|array_has|array_last|array_only|array_pluck|array_prepend|array_pull|array_random|array_set|array_sort_recursive|array_sort|array_where|array_wrap|camel_case|ends_with|kebab_case|snake_case|starts_with|str_after|str_before|str_contains|str_finish|str_is|str_limit|str_plural|str_random|str_replace_array|str_replace_first|str_replace_last|str_singular|str_slug|str_start|studly_case|title_case)
@jakebathman
jakebathman / thats-no-moon.js
Created Jan 21, 2020
Get the current phase of the moon, and adjust a sprite for it
View thats-no-moon.js
const phases=[
{"sprite-x":123, "sprite-y":987, phase:"new"},
{"sprite-x":123, "sprite-y":987, phase:"wax-crescent-1"},
{"sprite-x":123, "sprite-y":987, phase:"wax-crescent-2"},
{"sprite-x":123, "sprite-y":987, phase:"wax-crescent-3"},
{"sprite-x":123, "sprite-y":987, phase:"wax-crescent-4"},
{"sprite-x":123, "sprite-y":987, phase:"wax-crescent-5"},
{"sprite-x":123, "sprite-y":987, phase:"wax-crescent-6"},
{"sprite-x":123, "sprite-y":987, phase:"quarter-1"},
{"sprite-x":123, "sprite-y":987, phase:"wax-gibbous-1"},
View long-url-test.md

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vitae enim sollicitudin, placerat arcu vitae, https://www.amazon.com/Razor-15120040-Pocket-Rocket-Blue/dp/B001PH9J1I/ref=sr_1_1?keywords=razor+pocket+rocket&qid=1565972694&s=gateway&sr=8-1 tristique urna. Duis vitae commodo felis. Morbi tincidunt magna at turpis porttitor maximus.

Vivamus fermentum rutrum enim vitae ultrices. Pellentesque ac https://www.amazon.com/Razor-15120040-Pocket-Rocket-Blue/dp/B001PH9J1I/ref=sr_1_1?keywords=razor+pocket+rocket&qid=1565972694&s=gateway&sr=8-1 enim at sem aliquet convallis sit amet quis diam. Etiam sodales urna eget varius pretium. Vivamus id eros vehicula mauris auctor dictum sed rhoncus arcu. Pellentesque tincidunt magna lorem, et pretium mi rhoncus in. Mauris erat erat, elementum a congue ut, imperdiet quis turpis.

You can’t perform that action at this time.