Skip to content

Instantly share code, notes, and snippets.

View simonds's full-sized avatar

Mark Simonds simonds

View GitHub Profile
@simonds
simonds / snippets.js
Created July 10, 2021 22:19
JavaScript snippets
// Source: https://medium.com/dailyjs/13-javascript-one-liners-thatll-make-you-look-like-a-pro-29a27b6f51cb
const randomBoolean = () => Math.random() >= 0.5;
// randomBoolean() == true || false (a 50/50 change on returning true of false)
const isWeekday = (date) => date.getDay() % 6 !== 0;
// isWeekday(new Date(2021, 0, 11)) == true
const reverse = str => str.split('').reverse().join('');
// reverse('hello world') == 'dlrow olleh'
@simonds
simonds / Blockstack Proof #3
Last active July 16, 2019 21:54
Blockstack Verification
Verifying my Blockstack ID is secured with the address 1FLudoN99abz3cdd6MJuAkcgX9NkkSySg8 https://explorer.blockstack.org/address/1FLudoN99abz3cdd6MJuAkcgX9NkkSySg8
@simonds
simonds / zipcode.html
Created January 21, 2019 22:07
Automatic City Lookup with Google's Location API (from https://nobleintentstudio.com/blog/zip-code-to-city-state-lookup/)
<!DOCTYPE html>
<html>
<head>
<title>Zipcode Lookup Demo</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.0/jquery.js"></script>
<style>
input, label, select {
display: block;
width: 100%;
margin: 0;
Verifying that "marksimonds.id" is my Blockstack ID. https://onename.com/marksimonds
@simonds
simonds / compress-tables.sh
Created May 9, 2017 15:38 — forked from deviantintegral/compress-tables.sh
Compress MySQL Tables
#!/usr/bin/env bash
# Compress MySQL tables on disk.
# Author: Andrew Berry, andrew.berry@lullabot.com
#
# Compress all tables in a MySQL InnoDB database using compression from the
# Barracuda table format. Tables have to already be in the Barracuda file
# format to actually compress tables, otherwise the table setting is ignored.
#
# innodb_file_per_table = 1 MUST be set in my.cnf for compression to work.
@simonds
simonds / picar.py
Last active March 14, 2017 05:12
Python script for controlling a Raspberry Pi car.
import time
time.sleep(10)
from rrb3 import *
from bluetooth import *
speedFactor = 0.1
class Robot(object):

Keybase proof

I hereby claim:

  • I am simonds on github.
  • I am marksimonds (https://keybase.io/marksimonds) on keybase.
  • I have a public key ASBqQJ9UmPluawCSeemeOPcfBxaC0Tbhpfygn7eB1GNnkwo

To claim this, I am signing this object:

@simonds
simonds / character_fix.sql
Created October 7, 2016 21:19
Finds records in a MySQL database that have non-ascii values and fixes double-encoding errors. Accepts table and field name.
DELIMITER ;;
DROP PROCEDURE IF EXISTS character_fix;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `character_fix`(_table_name VARCHAR(50), _field_name VARCHAR(50))
BEGIN
DROP TEMPORARY TABLE IF EXISTS temp_cursor_table;
SET @temp_table_query='CREATE TEMPORARY TABLE temp_cursor_table AS ';
SET @temp_table_query=concat( @temp_table_query, 'SELECT id, ', _field_name, ' FROM ', _table_name, ' WHERE ', _field_name, ' <> convert(', _field_name, ' using ascii) ORDER BY id');
PREPARE temp_statement from @temp_table_query;
EXECUTE temp_statement;
@simonds
simonds / uc_words.sql
Created August 24, 2016 18:17
Found this MySQL function in several places online, so I don't know who to credit. This works a treat outputting Uppercase first letters on multiple words within a string.
/*
Usage:
UPDATE Table_name SET column_name = UC_Words(column_name)
*/
DELIMITER ||
CREATE FUNCTION `UC_Words`( str VARCHAR(255) ) RETURNS VARCHAR(255) CHARSET utf8_general_ci
BEGIN
DECLARE c CHAR(1);
@simonds
simonds / pokestops.json
Last active July 18, 2016 21:51
Pokestops within 5km of Riverside and Howard in downtown Spokane, WA
{
"pokestops" : [
{
"distance": 18,
"name": "Salvation Army Dedication Plaque",
"bearing": 207,
"latitude": 47.657763,
"image": "http://lh3.ggpht.com/Cf46atmJRu3lhO0JVbGFA4AxKWq8uHFEBxcU-GgzB8U390uqAEE-G1X4pNqT8ccHeFMSe7t1WoVDAuSnyB9v",
"guid": "4aed3289f2ae4450964e0ab3cb5eb3d6.16",
"compass": "SW",