Skip to content

Instantly share code, notes, and snippets.

@jakebathman
jakebathman / regex.php
Created August 31, 2015 17:53
TryBot regex
<?php
$arrRegexPatterns = array(
'subreddit' => "/(reddit\.com|reddittryhard\.com)?(?:\/r\/){1}([\w]+)/i",
);
if (preg_match($arrRegexPatterns['subreddit'], $text, $arrMatches) !== false)
{
echo json_encode($arrMatches);
}
@jakebathman
jakebathman / groupMeApi.php
Last active August 28, 2015 17:50
GroupMe API post
public function apiPost($url, $data = array() , $boolHeaders = false)
{
$ch = curl_init($url);
if (empty($data['file']))
{
$data = json_encode($data);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data)
));
@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 / 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, [email protected], 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.
Public Function BASE64SHA1(ByVal sTextToHash As String)
Dim asc As Object
Dim enc As Object
Dim TextToHash() As Byte
Dim SharedSecretKey() As Byte
Dim bytes() As Byte
Const cutoff As Integer = 5
Set asc = CreateObject("System.Text.UTF8Encoding")
@jakebathman
jakebathman / markov.php
Last active August 29, 2015 14:26 — forked from bmcculley/markov.php
PHP Markov Chain class
<?php
/*
Levi Thornton from boogybonbon and wordze generously posted his php Markov
Chain class.. unfortunately there is a missing $nn++ thus the class can hang,
the working version is below all credit to Levi for the code, i just fixed a
bug.
Example Usage:
------------------
@jakebathman
jakebathman / map.php
Last active August 29, 2015 14:20
Google Maps v3 basic example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<style>
html, body, #map-canvas {
height: 100%;
margin: 0px;
padding: 0px
@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 / Auto-clicker for TheButton.md
Last active August 29, 2015 14:19
Auto-clicker for /r/TheButton

###AUTO BUTTON CLICKER

This little script will automatically click The Button (http://www.reddit.com/r/thebutton) when the timer goes below a certain time (set by the user as intClickUnderTime).

This will only run until you refresh the page or navigate away.

⚠️ ⚠️ ⚠️

REVIEW THIS CODE CAREFULLY.

@jakebathman
jakebathman / jsonToCsv.php
Last active June 5, 2022 21:02 — 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
<?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