Skip to content

Instantly share code, notes, and snippets.

View codeprimate's full-sized avatar

Patrick Morgan codeprimate

  • Bellingham, WA
  • 19:40 (UTC -07:00)
View GitHub Profile
@codeprimate
codeprimate / ssl-commands.sh
Last active July 22, 2016 20:04
SSL Key Generation
#!/bin/bash
[ -z "$DOMAIN" ] && DOMAIN=test.example.com
[ -z "$DOMAIN_FILE" ] && DOMAIN_FILE=$DOMAIN
# Generate Key
openssl genrsa -out $DOMAIN_FILE.key 2048
# Generate Certificate Signing Request
openssl req -new -sha256 -key $DOMAIN_FILE.key -out $DOMAIN_FILE.csr
@codeprimate
codeprimate / install_newrelic_ubuntu.sh
Created September 30, 2015 14:53
NewRelic Server Monitor Installation
#!/bin/bash
echo 'deb http://apt.newrelic.com/debian/ newrelic non-free' | sudo tee /etc/apt/sources.list.d/newrelic.list
wget -O- https://download.newrelic.com/548C16BF.gpg | sudo apt-key add -
apt-get update
apt-get install newrelic-sysmond
nrsysmond-config --set license_key=KEY
@codeprimate
codeprimate / dump.sh
Last active August 29, 2015 14:24
Export MySQL Data retaining character set
# Export
mysqldump --result-file=/data/output.sql --default-character-set=latin1 -ec -uUSERNAME -pPASSWORD -h localhost DATABASENAME
# Load
mysql
# > use databasename;
## Optional vvv
# > set names latin1;
# > source /path/to/dump.sql;
@codeprimate
codeprimate / apache2.conf
Created June 2, 2015 02:58
Apache HTTPS Redirect
<VirtualHost *:80>
# ...
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</VirtualHost>
@codeprimate
codeprimate / nginx.conf
Created June 2, 2015 02:50
NginX HTTPS Redirect
server {
# ...
# force https-redirects
if ($scheme = http) {
return 301 https://$server_name$request_uri;
}
}
@codeprimate
codeprimate / _readme.md
Last active August 29, 2015 14:06 — forked from shime/_readme.md

Having trouble installing the latest stable version of tmux?

Save yourself some time and run this little fellow!

Prerequisities

  • gcc
  • wget
#
# Wide-open CORS config for nginx
#
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
#
@codeprimate
codeprimate / .vimrc
Created April 11, 2014 18:01
Vim: Highlight trailing white space
" Highlight trailing whitespace
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
function! TrimWhiteSpace()
%s/\s\+$//e
endfunction
# ~/.gitconfig Alias for changelog
[alias]
cl = !git log --format='format: * %s (%an: %ad) [%h]' --no-merges
class FooStruct
def initialize(attrs)
# Create a Singleton Class (Anonymous Class) inheriting from FooStruct
klass = ( class << self; self; end )
# Loop through the attributes
attrs.each do |attr|
# Within the context of the anonymous class...
klass.class_eval do
# Define accessors for each of the attributes
attr_accessor attr.to_sym