Skip to content

Instantly share code, notes, and snippets.

View nikmartin's full-sized avatar

Nik Martin nikmartin

View GitHub Profile
@nikmartin
nikmartin / gist:a70f500a41b051a1bdd137d415d5d900
Last active December 30, 2019 16:05
Cleanup your mp3 directory
1. install mp3val
2. find . -name "*.mp3" -print0 | xargs -0 mp3val -si -f -t -nb
rename double extensions
shopt -s globstar
for i in **/*.mp3.mp3; do
echo mv -nv -- "$i" "${s/\.mp3\.mp3/\.mp3/g}"
done
@nikmartin
nikmartin / README.md
Last active November 9, 2018 17:27
High Performance Batched updates in Firestore

Batched updates in Firestore

This short script shows how to do a batched update of a very large data set in firestore.

The scenario is I have a large set of products, and a 'pool' of product codes that need to be assigned to them. This script loads the list of UPC codes from a firebase database, then updates a firestore collection, updating every doc with a UPC code. For each product, the next code docID is assigned (so it's reall a pointer to the code, not the code itself), then the code is updated to signify that is has been assigned.

@nikmartin
nikmartin / namecheap-ddns.sh
Last active April 5, 2018 13:52 — forked from dalhundal/namecheap-ddns.sh
Shell script to update namecheap.com dynamic dns for a domain with your external IP address
#!/bin/sh
# Shell script to update namecheap.com dynamic dns
# for a domain to your external IP address
HOSTNAME=yoursubdomain
DOMAIN=yourdomainname.com
PASSWORD=y0urp455w0rd
curl "https://dynamicdns.park-your-domain.com/update?host=$HOSTNAME&domain=$DOMAIN&password=$PASSWORD"
@nikmartin
nikmartin / twiml.gs
Created November 9, 2015 21:38
Google Apps Script to produce Twilio TWIML
function doGet(e) {
var toNum = e.parameter.PhoneNumber;
var fromNum = e.parameter.CallerId;
var action = e.parameter.Direction;
var record = e.parameter.Record;
Logger.log(e);
var output = ContentService.createTextOutput();
var xml = createDialTWIML(fromNum, toNum, action);
@nikmartin
nikmartin / GetNextUpcomingDate.js
Last active October 28, 2015 21:51
This javascript snippet gets the date of the next day requested
function getNextDate(whichDay) {
console.log(whichDay);
var today = new Date(); //Wed Oct 28 2015
var currentDayOfWeek = today.getDay(); //0-6
var thisWeeksSunday = today.getDate() - currentDayOfWeek; //1-31
var theDate = today;
//if whichDay has not happened this week yet:
if (whichDay > currentDayOfWeek) { //then get this weeks whichday
@nikmartin
nikmartin / updateContacts.js
Last active August 29, 2015 14:26
A short example of how to bulk update a list of Hubspot contacts using node.js and the Hubspot API
/**
hubspot API - how to update a list of contatcs using hubspot API and node.js
The MIT License (MIT)
Copyright (c) 2015 Nik Martin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
@nikmartin
nikmartin / hubspot_csv.js
Last active November 23, 2022 02:10
A short example of how to use the hubspot api in node.js to get a full CSV export of your contacts
/**
hubspot API FULL CSV Export
A short example of how to use the hubspot api in node.js to get a full CSV export of your Hubspot contacts
The MIT License (MIT)
Copyright (c) 2015 Nik Martin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
@nikmartin
nikmartin / index.tpl
Created May 8, 2015 15:21
Underscore/Lodash template test
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Underscore/lodash template test </title>
<script data-require="jquery@*" data-semver="2.1.4" src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
<!--whichever one of these is LAST will get assigned to '_'-->
<script data-require="lodash.js@*" data-semver="3.8.0" src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.8.0/lodash.js"></script>
// ==UserScript==
// @name Clean Up Signals notifier.
// @version 0.2
// @include https://api.getsignals.com/*
// @include https://app.getsignals.com/*
// @include chrome-extension://*
// @require //ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js
// ==/UserScript==
var cleanDiv = $(".over-limit-state");
##
## Put me in ~/.irssi/scripts, and then execute the following in irssi:
##
## /load perl
## /script load notify
##
use strict;
use Irssi;
use vars qw($VERSION %IRSSI);