Skip to content

Instantly share code, notes, and snippets.

@jakebathman
jakebathman / StringConcat.vbs
Created August 18, 2015 17:20
Concatenate a range of strings in Excel, using VBA From http://www.cpearson.com/excel/stringconcatenation.aspx
Function StringConcat(Sep As String, ParamArray Args()) As Variant
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' StringConcat
' By Chip Pearson, chip@cpearson.com, www.cpearson.com
' www.cpearson.com/Excel/stringconcatenation.aspx
' This function concatenates all the elements in the Args array,
' delimited by the Sep character, into a single string. This function
' can be used in an array formula. There is a VBA imposed limit that
' a string in a passed in array (e.g., calling this function from
' an array formula in a worksheet cell) must be less than 256 characters.
@jakebathman
jakebathman / te-snippets-to-alfred.php
Created January 29, 2021 19:31
Convert TextExpander exported CSV file to an Alfred 4 snippets import file
<?php
$input = $argv[1] ?? 'snippets.csv';
$file = fopen($input, 'r');
$outputDir = pathinfo($input, PATHINFO_FILENAME);
$snippetFiles = [];
// Make the temp output directory
if (! file_exists($outputDir)) {
@jakebathman
jakebathman / arrayToTable.php
Created August 14, 2017 20:56
Make a quick HTML table from a PHP array
function arrayToTable(array $values, array $headers = [])
{
$options = [
'tableStyle' => 'border: 1px solid black;border-collapse: collapse;',
'thStyle' => 'border: 1px solid black;padding: 5px 7px;text-align: center;',
'tdStyle' => 'border: 1px solid black;padding: 5px 7px;text-align: center;',
];
$th = "<th style='" . $options['thStyle'] . "'>";
$td = "<td style='" . $options['tdStyle'] . "'>";
<?php
$host = 'palindromer-bd7e0fc867d57915.elb.us-east-1.amazonaws.com';
$port = 7777;
$socket = fsockopen($host, $port);
if (! $socket) {
die('Error: connection not successful');
}
@jakebathman
jakebathman / user-agents.txt
Last active January 8, 2021 22:20
A list of major user agent strings for different browsers and devices
Chrome/Windows: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36
Chrome/Windows: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36
Chrome/Windows: Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36
Chrome/macOS: Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36
Chrome/Linux: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36
Chrome/iPhone: Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/87.0.4280.77 Mobile/15E148 Safari/604.1
Chrome/iPhone (request desktop): Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/87 Version/11.1.1 Safari/605.1.15
Chrome/iPad: Mozilla/5.0 (iPad; CPU OS 14_3 like Mac OS X) AppleWebKit/605.1.1
@jakebathman
jakebathman / centos_setup.sh
Created March 14, 2017 14:58
CentOS box initial setup script
#!/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 / geoDistance.php
Last active July 15, 2020 15:10
Lat/Lon Distance Calculator
<?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 July 12, 2020 00:10
GroupMe bot post function including @mentions
<?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 / init.lua
Last active May 18, 2020 19:22
Hammerspoon config
-- 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 / regex.md
Last active January 22, 2020 21:16
Laravel 5.8 deprecated helpers regex search
(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)