Skip to content

Instantly share code, notes, and snippets.

@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
# ```
@thom-nic
thom-nic / Dockerfile
Created June 18, 2014 15:15
Node.js Dockerfile based on ubuntu 14.04. This is a little smaller than dockerfile/nodejs which depends on python
# Node.js app Docker file
FROM ubuntu:14.04
MAINTAINER Thom Nichols "thom@thomnichols.org"
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update
RUN apt-get -qq update
RUN apt-get install -y nodejs npm
@thom-nic
thom-nic / build.gradle
Last active November 16, 2023 07:35
find the largest classnames in Spring libraries. Also find FactoryFactories
/**
* Find the longest class names in Spring.
* Also find FactoryFactory classes.
* a goof-off project by @thom_nic
*/
import java.util.jar.*
defaultTasks 'longest', 'factoryfactory'
@thom-nic
thom-nic / scroll.js
Created June 9, 2014 14:05
smooth scroll to element in HTML
/**
* Scroll to the given element on the page
*/
function scrollTo(elem) {
$('html').animate({
scrollTop: $(elem).offset().top
}, 600);
}
@thom-nic
thom-nic / .gvimrc
Created June 5, 2014 13:53
Vim files
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
source ~/.vimrc
behave mswin
set diffexpr=MyDiff()
function MyDiff()
let opt = ''
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
@thom-nic
thom-nic / keybase.md
Created June 4, 2014 16:13
keybase.io proof of github identity

Keybase proof

I hereby claim:

  • I am thom-nic on github.
  • I am thom_nic (https://keybase.io/thom_nic) on keybase.
  • I have a public key whose fingerprint is 66D4 6F49 8A5A CF50 61DD 028A F60F F0BE 93E2 E646

To claim this, I am signing this object:

@thom-nic
thom-nic / pom.xml
Created May 28, 2014 02:47
Facebook Android SDK POM for Maven
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.facebook</groupId>
<artifactId>facebook-android-sdk</artifactId>
<packaging>apklib</packaging>
<name>Facebook Android SDK</name>
<version>3.0.1</version>
@thom-nic
thom-nic / record.py
Created January 3, 2014 15:55
inspired by collections.namedtuple, I wanted an easy struct-type for data objects without the boilerplate __init__() method for setting all instance attributes from the argument list. I also added some features to namedtuple, most notably mutable properties & default values. It can be extended to act as a base for any class definition.
import sys
def Record(name, required, **defaults):
required = tuple(required.split())
class RecordBase(object):
__slots__ = required + tuple(defaults.keys())
def __init__(self, *args, **kwargs):
all_args = set()
@thom-nic
thom-nic / berks_install.txt
Created November 27, 2013 18:51
Output from BERKSHELF_DEBUG=1 berks install related to https://github.com/berkshelf/berkshelf/issues/927
$ BERKSHELF_DEBUG=1 berks install
Using git (2.3.0)
Using zsh (1.0.0)
Using node (1.0.1)
Using nginx (2.0.4)
Using redisio (1.4.1)
Using mongodb (0.13.7)
The file at '/var/folders/57/7kc43km1357fb9lrdgc15jn00000gn/T/community-rest-stream20131127-47587-nwjl66' is not a known compression type
/Users/tnichols/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/berkshelf-2.0.10/lib/berkshelf/community_rest.rb:22:in `unpack'
/Users/tnichols/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/berkshelf-2.0.10/lib/berkshelf/community_rest.rb:100:in `download'
@thom-nic
thom-nic / Berksfile
Created November 27, 2013 15:44
Odd failures from Berkshelf on OSX
site :opscode
cookbook 'git', '~> 2.3.0'
cookbook 'zsh', '~> 1.0.0'
cookbook 'node', '~> 1.0.1'
cookbook 'nginx', '~> 2.0.4'
cookbook 'redisio', '~> 1.4.1'
cookbook 'mongodb', '~> 0.13.7'
cookbook 'cloudwatch-monitoring', '~> 1.1.0'