Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew Golightly magician11

View GitHub Profile
@tomhicks
tomhicks / plink-plonk.js
Last active Aug 5, 2020
Listen to your web pages
View plink-plonk.js
@magician11
magician11 / freshbooks-classic.js
Last active Jul 12, 2019
How to call Freshbooks Classic directly in Node.js using axios
View freshbooks-classic.js
const axios = require("axios");
const config = require("../security/auth.js");
const callFreshbooks = async (
xml,
apiUrl = config.freshbooks.url,
authToken = config.freshbooks.token
) => {
try {
const response = await axios({
@magician11
magician11 / supportedLanguages.js
Created Dec 28, 2018
Google Cloud Speech-to-Text API Language Support as a JavaScript array
View supportedLanguages.js
export default [
['Afrikaans (Suid-Afrika)', 'af-ZA'],
['አማርኛ (ኢትዮጵያ)', 'am-ET'],
['Հայ (Հայաստան)', 'hy-AM'],
['Azərbaycan (Azərbaycan)', 'az-AZ'],
['Bahasa Indonesia (Indonesia)', 'id-ID'],
['Bahasa Melayu (Malaysia)', 'ms-MY'],
['বাংলা (বাংলাদেশ)', 'bn-BD'],
['বাংলা (ভারত)', 'bn-IN'],
['Català (Espanya)', 'ca-ES'],
@magician11
magician11 / remove-duplicates.js
Last active Dec 28, 2018
How to remove duplicates in a csv field
View remove-duplicates.js
const removeDuplicates = csvStr => [...new Set(csvStr.split(',').map(tag => tag.trim()))].join(', ');
@magician11
magician11 / nodejs-cron.js
Last active May 1, 2018
How to get a Node.js function to run once on the last day of each month
View nodejs-cron.js
const moment = require('moment');
const someAction = () => console.log('Actioning...');
const wait = ms => new Promise((resolve, reject) => setTimeout(resolve, ms));
const startCron = async () => {
while (true) {
if (
moment().date() ===
@magician11
magician11 / tweetnacl-test.js
Last active Jan 8, 2020
How to encrypt and decrypt a message with TweetNaCl.js
View tweetnacl-test.js
const tweetnacl = require('tweetnacl'); // https://github.com/dchest/tweetnacl-js
tweetnacl.util = require('tweetnacl-util'); // https://github.com/dchest/tweetnacl-util-js
// utility function to display the Uint8Array
const asciiArmored = arr => tweetnacl.util.encodeBase64(arr);
// generate the key to encrypt a message
const secretKey = tweetnacl.randomBytes(32);
console.log(`secret key: ${asciiArmored(secretKey)}`);
@magician11
magician11 / my-domain.com.conf
Last active Jan 19, 2018
How to add pre and post hooks for Certbot automatic renewals running Nginx
View my-domain.com.conf
# renew_before_expiry = 30 days
version = 0.19.0
archive_dir = /etc/letsencrypt/archive/my-domain.com
cert = /etc/letsencrypt/live/my-domain.com/cert.pem
privkey = /etc/letsencrypt/live/my-domain.com/privkey.pem
chain = /etc/letsencrypt/live/my-domain.com/chain.pem
fullchain = /etc/letsencrypt/live/my-domain.com/fullchain.pem
# Options used in the renewal process
[renewalparams]
@magician11
magician11 / config.js
Last active Dec 2, 2017
How to send an email from Node.js using Gmail
View config.js
module.exports = {
email: {
address: 'youraddress@gmail.com',
password: 'clever-password'
}
};
@ipepe
ipepe / install-chrome-headless.sh
Last active Aug 10, 2020
Installing headless chrome on Ubuntu.
View install-chrome-headless.sh
#!/bin/bash
# from https://chromium.woolyss.com/
# and https://gist.github.com/addyosmani/5336747
# and https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md
sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:canonical-chromium-builds/stage
sudo apt-get update
sudo apt-get install chromium-browser
chromium-browser --headless --no-sandbox http://example.org/
@umidjons
umidjons / youtube-dl-download-audio-only-on-best-quality.md
Last active Aug 14, 2020
Download Audio from YouTube with youtube-dl
View youtube-dl-download-audio-only-on-best-quality.md

Download Audio from YouTube

-i - ignore errors

-c - continue

-t - use video title as file name

--extract-audio - extract audio track

You can’t perform that action at this time.