Skip to content

Instantly share code, notes, and snippets.

@tmbritton
tmbritton / searchReplace
Created November 19, 2021 17:49
search and replace grep/sed
grep -rl 'search' ./* | xargs sed -i '' -e 's/search/replace/g'
@tmbritton
tmbritton / machine.js
Last active May 2, 2021 03:07
Generated by XState Viz: https://xstate.js.org/viz
const turnMachine = Machine({
id: 'turn',
initial: 'beginning',
states: {
beginning: {
initial: 'untap',
states: {
untap: {
entry: sendParent({type: 'UNTAP_STEP_START'}),
exit: sendParent({type: 'UNTAP_STEP_END'}),
@tmbritton
tmbritton / machine.js
Last active May 2, 2021 01:01
Generated by XState Viz: https://xstate.js.org/viz
const pubsubMachine = Machine({
id: 'pubsub',
initial: 'listening',
type: 'parallel',
context: {
queue: [],
subscriptions: {},
},
states: {
listening: {
@tmbritton
tmbritton / token.txt
Created February 23, 2018 19:32
Custom token in Drupal 7
/**
* Implements hook_token_info().
*/
function modulename_token_info() {
// Add tokens.
$info['types']['token-type'] = array(
'name' => t('ModuleName Tokens'),
'description' => t('ModuleName custom tokens'),
);
@tmbritton
tmbritton / output
Created July 10, 2017 19:13
vagrant console output
$ vagrant provision
==> wfmcom: [vagrant-hostsupdater] Checking for host entries
==> wfmcom: [vagrant-hostsupdater] found entry for: 192.168.88.88 local.wholefoodsmarket.com
==> wfmcom: [vagrant-hostsupdater] found entry for: 192.168.88.88 adminer.local.wholefoodsmarket.com
==> wfmcom: [vagrant-hostsupdater] found entry for: 192.168.88.88 xhprof.local.wholefoodsmarket.com
==> wfmcom: [vagrant-hostsupdater] found entry for: 192.168.88.88 pimpmylog.local.wholefoodsmarket.com
==> wfmcom: [vagrant-hostsupdater] found entry for: 192.168.88.88 dashboard.local.wholefoodsmarket.com
==> wfmcom: Running provisioner: ansible...
wfmcom: Running ansible-playbook...
@tmbritton
tmbritton / geo-distance-select
Created January 26, 2017 17:57
MySQL lat/long select by distance
SELECT field_geo_data_lat, field_geo_data_lon, SQRT(
POW(69.1 * (field_geo_data_lat - [30.2707]), 2) +
POW(69.1 * ([-97.7533] - field_geo_data_lon) * COS(latitude / 57.3), 2)) AS distance
FROM field_data_field_geo_data HAVING distance < 25 ORDER BY distance;
@tmbritton
tmbritton / check-dat-star-wars.js
Last active October 19, 2015 17:36 — forked from chrislambe/check-dat-star-wars.js
Are tickets on sale yet for The Force Awakens?
var https = require('https'),
exec = require('child_process').exec;
// Check every 5 minutes
var checkDelay = 60000 * 5;
// Store the previous response body for comparison
var lastBody = null;
var checkTickets = function()
@tmbritton
tmbritton / store folders
Created June 4, 2015 23:12
Select store titles and paths
SELECT f.field_store_name_value as "Store Path",
n.title as "Store Name",
n.nid as "Drupal Node ID"
FROM field_data_field_store_name f
LEFT JOIN node n
ON f.entity_id = n.nid
;
@tmbritton
tmbritton / morse
Created February 5, 2014 21:27
Arduino morse code blink
//This isn't quite working yet.
int led = 13; //led is on pin 13
String text = "Hello World!";
int basetime = 100;
int pause = basetime;
int shortgap = basetime * 3;
int mediumgap = basetime * 7 - pause;
String translatetext(char character) {
@tmbritton
tmbritton / casper.js test test
Created January 30, 2014 04:57
casper.js testing test
/**
* Casper.js testing test
*/
var testSuite = {
config: {
baseUrl: 'http://www.wholefoodsmarket.com',
},
googleTest: function(){