Skip to content

Instantly share code, notes, and snippets.

@bloc40
bloc40 / Clear-log-files.md
Last active October 1, 2015 14:47
Clear your development logs automatically when they are too large
# config/initializers/clear_logs.rb

if Rails.env.development?
  MAX_LOG_SIZE = 2.megabytes
  
  logs = File.join(Rails.root, 'log', '*.log')
  if Dir[logs].any? {|log| File.size?(log).to_i > MAX_LOG_SIZE }
    $stdout.puts "Runing rake log:clear"
 `rake log:clear`
// Module requirements
var express = require('express');
// The variables
var user = 'myUsername';
var pass = 'myPassword';
var basicAuthMessage = 'Restrict area, please identify';
// The function
var basicAuth = express.basicAuth(function(username, password) {
@bloc40
bloc40 / tmux-commands.md
Last active August 29, 2015 14:26
Tmux Commands
prefix = Ctrl-a

Sessions:

tmux -V                        # show version
tmux                           # start a session
tmux new -s <name>             # start a session named <name>
tmux ls                        # list tmux sessions
tmux a                         # attach to a session (if there is only one running)
@bloc40
bloc40 / bash-commands.md
Last active September 9, 2016 17:22
Bash Commands

Command Editing Shortcuts

Ctrl + a     # go to the start of the command line
Ctrl + e     # go to the end of the command line
Ctrl + k     # delete from cursor to the end of the command line
Ctrl + u     # delete from cursor to the start of the command line
Ctrl + w     # delete from cursor to start of word (i.e. delete backwards one word)
Ctrl + y     # paste word or text that was cut using one of the deletion shortcuts (such as the one above) after the cursor
Ctrl + xx    # move between start of command line and current cursor position (and back again)
Ctrl + f     # move forward one character

Create a directory to hold Git hooks

mkdir -p ~/.git_template/hooks/

Add This file to ~/.git_template/hooks/prepare-commit-msg

#!/bin/sh

if [ -z "$BRANCHES_TO_SKIP" ]; then
 BRANCHES_TO_SKIP=(master develop)
@bloc40
bloc40 / vim-heroku.sh
Created April 23, 2018 16:14 — forked from dvdbng/vim-heroku.sh
Run vim in heroku updated 2017
mkdir ~/vim
cd ~/vim
# Staically linked vim version compiled from https://github.com/ericpruitt/static-vim
# Compiled on Jul 20 2017
curl 'https://s3.amazonaws.com/bengoa/vim-static.tar.gz' | tar -xz
export VIMRUNTIME="$HOME/vim/runtime"
export PATH="$HOME/vim:$PATH"
cd -
def word_hash
hash = {}
Hash.new(0)
('a'..'z').to_a.each_with_index do |e, i|
hash[e] = i + 1
end
hash
end
def word_points(word)