Skip to content

Instantly share code, notes, and snippets.

View napcs's full-sized avatar

Brian P. Hogan napcs

View GitHub Profile
@napcs
napcs / talent_lms_md_generator.js
Last active June 6, 2022 16:26
Quick Node script to generate Hugo static pages from TalentLMS API data
'use strict';
// The URL to your public catalog. Ensure you've enabled this public catalog so links work.
const URL = 'https://yourdomain.talentlms.com/catalog';
const fs = require('fs');
// Getting data from a local copy to ensure builds are stable.
let rawdata = fs.readFileSync('data/courses.json');
let courses = JSON.parse(rawdata);
notifyMe() {
if [ $? -eq 0 ]; then
osascript -e 'display notification "The command worked" with title "Success"'
else
osascript -e 'display notification "The command failed" with title "Failed"'
fi
}
@napcs
napcs / playbook.yml
Created June 22, 2018 19:17
playbook for dev server
---
- hosts: all
remote_user: root
tasks:
- name: Add "sammy" non-root sudo user
user:
name: sammy
# THIS IS BAD - DON'T PUT PASSWORDS IN PRODUCTION FILES -
sudo apt-get install build-essential libevent-dev libncurses-dev
tar -zxvf tmux-2.4.tar.gz
cd tmux-2.3
./configure
make
sudo make install
@napcs
napcs / flags.elm
Created April 8, 2017 15:16
Elm with Flags
module Main exposing (..)
import Html exposing (Html, div, p, text)
-- Data type for the flags
type alias Flags =
{ user : String
, token : String
}
@napcs
napcs / flags.elm
Created April 8, 2017 15:16
Elm with Flags
module Main exposing (..)
import Html exposing (Html, div, p, text)
-- Data type for the flags
type alias Flags =
{ user : String
, token : String
}
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<title>Game</title>
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/phaser/2.6.2/phaser.js"></script>
<script type="text/javascript" src="game.js" charset="utf-8"></script>
@napcs
napcs / README.md
Last active April 15, 2017 18:00
EFP #47

EFP 47

This is the solution to the "Who's In Space" problem in Exercises For Programmers, implemented in Elm v0.18

This exercise uses the OpenNotify API and that API doesn't support CORS, so you'll need to use a local proxy if you want to make this work in a browser.

But you can use my app QEDProxy as a simple local proxy.

Install it with npm:

@napcs
napcs / TerminalVim.applescript
Last active April 14, 2024 11:08
Open file in Terminal Vim on OSX
on run {input, parameters}
set filename to quoted form of POSIX path of input
set cmd to "clear;cd `dirname " & filename & "`;vim " & filename
tell application "iTerm"
tell the current window
@napcs
napcs / ce.rb
Last active July 20, 2016 16:01
copyedit script - shuffles file contents to help look for errors without being clouded by context.
# Shuffles file contents to help you find errors without being blinded by context.
# Displays original line number and the line text to help you fix errors.
# usage: ce.rb path/to/file
file = ARGV[0]
File.readlines(file)
.collect.with_index {|line, i| {line: i + 1, text: line} }
.shuffle.each {|line| puts "#{line[:line]}\t#{line[:text]}" }