Skip to content

Instantly share code, notes, and snippets.

package main
import (
"fmt"
"net/http"
"sync"
"github.com/gorilla/websocket"
)
@Boztown
Boztown / vscode_vim_keybindings.json
Created August 26, 2021 07:07
VSCode Vim Keybindings
// Place your key bindings in this file to override the defaults
[
{
"key": "cmd+enter",
"command": "renameFile",
"when": "explorerViewletVisible && filesExplorerFocus"
},
{
"key": "enter",
"command": "-renameFile",
@Boztown
Boztown / tagged_logger.rb
Created September 4, 2018 23:32
Good old TaggedLogger!
module TaggedLogger
extend ActiveSupport::Concern
def log(message, additional_tags = [], log_level = :info)
begin
caller_name = caller[0][/`.*'/][1..-2].to_s
rescue StandardError
caller_name = "error_getting_method_name"
@Boztown
Boztown / trace_redirect.rb
Created January 12, 2017 17:38
Rails snippet to trace redirects
# add to application_controller.rb
# from: http://stackoverflow.com/questions/15274038/how-to-trace-redirect-to-in-a-rails-app-while-hunting-bugs
def redirect_to(options = {}, response_status = {})
::Rails.logger.error("Redirected by #{caller(1).first rescue "unknown"}")
super(options, response_status)
end
@Boztown
Boztown / 0_reuse_code.js
Created September 6, 2016 16:50
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@Boztown
Boztown / post-checkout-hook.rb
Last active September 15, 2016 18:08
Post-Checkout GIT hook to change database_yml to the name of my current branch.
#!/usr/bin/env ruby
gem 'psych'
require 'psych'
branch = `git branch | grep '*' | cut -c 3-`.chomp
branch.gsub! '/', '_'
branch.gsub! '-', '_'
f = Psych.load_file("config/database.yml")
@Boztown
Boztown / .vimrc
Last active November 3, 2015 21:24
My Vim Config
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
@Boztown
Boztown / vest.rb
Last active August 29, 2015 14:27
#!/usr/bin/env ruby
# So, first thing: normally I'd use (or even create) some kind of framework. If we were using
# Rails for example we'd have functions and libraries like ActiveRecord that would make this look
# like nothing at all. I know whoever is reading this knows that; but I thought I'd state it.
require 'csv'
# So this is going to be main class.
class GrantGainsCalculator
#!/usr/bin/env ruby
require 'csv'
class GrantGainsCalculator
@employees
@market_price_date
@market_price
@Boztown
Boztown / acf-repeater.php
Created August 16, 2015 20:35
ACF Repeater Example
<?php if( have_rows('locations') ): ?>
<?php while ( have_rows('locations') ) : the_row(); ?>
<h3><?php the_sub_field('location_name'); ?></h3>
<?php endwhile; ?>
<?php endif; ?>