Skip to content

Instantly share code, notes, and snippets.

View evantahler's full-sized avatar
💭
Programmin'

Evan Tahler evantahler

💭
Programmin'
View GitHub Profile
@evantahler
evantahler / setup.sh
Last active September 3, 2019 22:08
Setting up a new computer via sshcode
#!/bin/bash
# First, configure the host to run VSCode with SSHCODE - https://github.com/cdr/sshcode
# Then, run this command via the command line exposed from the new VSCode window (assuming as Root)
# Inspired by https://github.com/evantahler/workstation
###
# Run Command:
# wget https://gist.githubusercontent.com/evantahler/ddfbe3101c3c9fe8451c6412e288c9fa/raw/85e544e513591f316ec23a482419e6e060431fac/setup.sh && chmod 0766 setup.sh && ./setup.sh
###
@evantahler
evantahler / vpn-reconnect.scpt
Created August 9, 2019 21:12
Keep that VPN Connected (OSX)
on idle
tell application "System Events"
tell current location of network preferences
set VPNService to the service "vpn-evan" -- replace this with the name of your VPN connection
if VPNService is not null then
if current configuration of VPNService is not connected then
beep
beep
beep
connect VPNService
@evantahler
evantahler / require-shim.js
Created August 13, 2018 22:52
require-shim.js
// in your action
{formatter} = requrie('../helper.js')
// in helper.js
const path = require('path')
exports.formatter = require(path.join(__dirname, 'path', 'that', 'is', 'really', 'long', 'formatter.js'))
@evantahler
evantahler / test.js
Created March 28, 2018 03:58
Testing Node.JS browser apps with Selenium, Async/Await, and Jest
/**
* @jest-environment jest-environment-webdriver
*/
const url = 'https://www.actionherojs.com'
describe('www.actionherojs.com#index', () => {
test('it renders', async () => {
await browser.get(url)
const title = await browser.findElement(by.tagName('h2')).getText()
@evantahler
evantahler / build.js
Created November 20, 2017 22:23
Using NEXE to compile and ActionHero project
const nexe = require('nexe')
nexe.compile({
output: 'build',
input: `${__dirname}/index.js`,
build: true,
silent: false
})
@evantahler
evantahler / client.js
Last active November 14, 2017 23:43
actionhero and next
require('isomorphic-fetch') // ensure fech is in-scope, even on the server
let hosts = {
dev: 'http://localhost:8080',
production: 'https://api.scoreboard.guru'
}
export default class Client {
apiEndpoint () {
if (process && process.title === 'node') {
@evantahler
evantahler / v17.js
Last active October 7, 2017 21:19
V17 to V18 cache ActionHero action
exports.cacheTest = {
name: 'cacheTest',
description: 'I will test the internal cache functions of the API',
inputs: {
key: {
required: true,
formatter: function (s) { return String(s) }
},
value: {
required: true,
@evantahler
evantahler / code.js
Created September 28, 2017 16:25
util.promisify
const {promisify} = require('util')
async sleep (time) {
return promisify(setTimeout)(time)
}
@evantahler
evantahler / index.js
Last active September 25, 2017 22:37
modifying requires
exports.api = {}
exports.initializer = require('./initializer.js')
exports.main = require('./main.js') // comment me out and everything is fine
@evantahler
evantahler / buildSitemap.js
Last active December 17, 2020 16:35
35 lines to build a sitemap for next.js projects
#! /usr/bin/env node
// I am ./bin/buildSitemap.js
const path = require('path')
const glob = require('glob')
const fs = require('fs')
const SITE_ROOT = process.env.SITE_ROOT || 'https://www.actionherojs.com'
const SOURCE = process.env.SOURCE || path.join(__dirname, '..', 'pages', '/**/*.js')
const DESTINATION = process.env.DESTINATION || path.join(__dirname, '..', 'static', 'sitemap.xml')