Skip to content

Instantly share code, notes, and snippets.

View trkoch's full-sized avatar

Tristan Koch trkoch

View GitHub Profile
@zealot128
zealot128 / ActiveStorageDocxPreviewer.md
Last active September 18, 2023 11:18
Activestorage Docx Previewer

Docx (and other Office doc) previewer support for ActiveStorage

Converts all document formats using LibreOffice first to PDF and then to an image, using build-in pdf previwer of ActiveStorage

  • needs: unoconv, a command line tool which uses libreoffice, e.g. apt install unoconv
  • needs a PDF converter, because libreoffice will make a pdf from the office document, Mupdf oder Poppler are already integrated into ActiveStorage, and poppler is free to use, e.g. apt install poppler-utils
@mulhoon
mulhoon / s3proxy.js
Last active March 20, 2023 22:42
Serve S3 files through express proxy
// Example of using express to proxy files from s3.
// Works with streaming media like mp4
const AWS = require('aws-sdk')
const mime = require('mime-types')
const express = require('express')
AWS.config.update({
secretAccessKey: '...',
accessKeyId: '...',
@trkoch
trkoch / Gruntfile.js
Created July 28, 2014 11:14
Simple Gruntfile using grunt-contrib-connect (run 'grunt serve')
/* global module */
module.exports = function(grunt) {
'use strict';
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
connect: {
options: {
port: 8000,
@thom-nic
thom-nic / Dockerfile
Last active August 13, 2020 14:35
Dockerfile that attempts to run the app as non-root user. This creates a `node` user & sets permissions on app files. Note you cannot `chown` files in a docker 'volume' during the build process, but you can at runtime (as part of your `CMD`) but in that case you can't use the `USER` command to change the UID before `CMD` runs.
###
# Node.js app Docker file
#
# Some basic build instructions:
# ```
# # you should delete node_modules b/c you don't want that copied during 'ADD'
# docker build -t thom-nic/node-bootstrap .
# # run a shell in the container to inspect the environment (as root):
# docker run --rm -itu root thom-nic/node-bootstrap /bin/bash
# ```
@trkoch
trkoch / template.rb
Last active August 29, 2015 14:02
Rails Application Template (rSpec, Capybara, Poltergeist, FactoryGirl)
remove_file("test")
gem_group :development, :test do
gem "rspec-rails", "~> 3.0.0"
gem "spring-commands-rspec"
gem "factory_girl_rails", "~> 4.0"
gem "pry-rails"
gem "pry-byebug"
gem "pry-stack_explorer"
gem "pry-rescue"
@trkoch
trkoch / Vagrantfile
Last active August 29, 2015 14:02
Vagrantfile for ubuntu/trusty with Ansible provisioning
# -*- mode: ruby -*-
# vi: set ft=ruby :
require "rbconfig"
require "fileutils"
VAGRANTFILE_API_VERSION = "2"
# Customize
PROJECT = "app"
@trkoch
trkoch / .tmux.conf
Created May 21, 2014 16:41
Basic tmux config
# Inherit current path in new window
bind-key c new-window -c "#{pane_current_path}"
# Enable mouse scrolling
set-window-option -g mode-mouse on
# Remap window navigation to vim
unbind-key j
bind-key j select-pane -D
unbind-key k
@jasonlewis
jasonlewis / create-project.sh
Last active February 10, 2023 12:04
Bash script that creates a new project and virtual host for that project. Can also be used to quickly create a new Laravel project.
#!/bin/bash
# This script creates a new project (or site) under /var/sites and creates
# new virtual host for that site. With the options a site can also
# install the latest version of Laravel directly.
# This script was originally based on the following script by @Nek from
# Coderwall: https://coderwall.com/p/cqoplg
# Display the usage information of the command.
create-project-usage() {
@trkoch
trkoch / .vimrc
Last active December 15, 2015 15:28
Basic vim config: curl -L http://git.io/kochvim > .vimrc
" Basic
syntax on
set nocompatible
set encoding=utf-8
set vb
" Buffers and windows
set hidden
set autoread
set shortmess+=IA