Skip to content

Instantly share code, notes, and snippets.

Avatar

Nik Martin nikmartin

View GitHub Profile
View gist:a70f500a41b051a1bdd137d415d5d900
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 / Ionic 4 Livereload
Last active Dec 14, 2019
Running an ionic 4 Capacitor project in livereload mode
View Ionic 4 Livereload
<!-- android/app/src/main/AndroidManifest.xml -->
<application
android:networkSecurityConfig="@xml/network_security_config"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
@nikmartin
nikmartin / README.md
Last active Nov 9, 2018
High Performance Batched updates in Firestore
View README.md

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 Apr 5, 2018 — forked from dalhundal/namecheap-ddns.sh
Shell script to update namecheap.com dynamic dns for a domain with your external IP address
View namecheap-ddns.sh
#!/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 / build.sh
Created Mar 2, 2016
atom builder script
View build.sh
#!/bin/bash
git fetch -p && \
git checkout $(git describe --tags `git rev-list --tags --max-count=1`) && \
sed -i -e "/exception-reporting/d" -e "/metrics/d" package.json \
script/build && \
gksudo script/grunt install
@nikmartin
nikmartin / twiml.gs
Created Nov 9, 2015
Google Apps Script to produce Twilio TWIML
View twiml.gs
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 Oct 28, 2015
This javascript snippet gets the date of the next day requested
View GetNextUpcomingDate.js
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 Aug 29, 2015
A short example of how to bulk update a list of Hubspot contacts using node.js and the Hubspot API
View updateContacts.js
/**
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 Feb 8, 2019
A short example of how to use the hubspot api in node.js to get a full CSV export of your contacts
View hubspot_csv.js
/**
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 / inline.tpl
Created May 8, 2015
inline lodash/underscore template
View inline.tpl
<h3>Library Version (this html should be escaped): <%- '<h1>' + _.VERSION + '</h1>' %> </h3> <h2> <%- rc.listTitle %> </h2> <ul> <% _.each( rc.listItems, function( listItem ){ %> <li> <%- listItem.name %> <% if ( listItem.hasOlympicGold ){ %> <em>*</em> <% } %> </li> <% }); %> </ul> <% var showFootnote = _.any(
_.pluck( rc.listItems, "hasOlympicGold" )
); %> <% if ( showFootnote ){ %> <p style="font-size: 12px ;"> <em>* Olympic gold medalist</em> </p> <% } %>
You can’t perform that action at this time.