Skip to content

Instantly share code, notes, and snippets.

View napcs's full-sized avatar

Brian P. Hogan napcs

View GitHub Profile
@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

Vim Cheatsheet

Generally helpful stuff

Open a file for editing             :e path/to/file.txt
Return to Normal mode               ESC   or <CTRL>+C

Navigating around text

@napcs
napcs / .vimrc
Last active December 14, 2022 17:40
Set up Vim on Mac, Linux, or Windows. For Mac and Linux: sh <(curl -s https://gist.githubusercontent.com/napcs/532968/raw/vim.sh)
if has('win32') || has ('win64')
let $VIMHOME = $HOME."/Dropbox/dotfiles/.vim"
if !empty($CONEMUBUILD)
set term=xterm
set t_Co=256
let &t_AB="\e[48;5;%dm"
let &t_AF="\e[38;5;%dm"
endif
@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);
@napcs
napcs / .tmux.clipboard
Created August 15, 2011 19:28
My tmux config
# configuration for osx clipboard support
set-option -g default-command "reattach-to-user-namespace -l sh"
@napcs
napcs / server.js
Created February 20, 2013 19:22
Simple web server with MIME type support and directory listing support for use in HTML5 and CSS3 Second Edition.
// Simple static server with MIME based on https://gist.github.com/906395
// Definitely not for production use.
var path = require('path');
var http = require("http");
var fs = require('fs');
var url = require("url");
try{
var mime = require('mime');
} catch(error) {
@napcs
napcs / README.md
Created May 6, 2011 04:10
Deploying Rails to Linode

Deploying Rails to Linode

Installing Ruby Enterprise Edition, Apache, MySQL, and Passenger for deploying Rails 3.0 applications.

Get a Linode, and set it up with Ubuntu 10.04 LTS so that you have till April 2013 to get updates. Once the Linode is formatted, boot it and continue on.

Set up an 'A' record in your DNS, pointing to the IP of your Linode. I'm using demo.napcs.com here.

Initial setup

@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 / JS Loading in web frameworks like Elixir
Last active January 20, 2020 04:05
Per-view JavaScript functions for Phoenix. Keeps things out of global space, allows a page to specifically invoke the JS it needs.
How to load page-specific JS functions and pass values to those functions when JS is loaded below your views.
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
}