Skip to content

Instantly share code, notes, and snippets.

View carlweis's full-sized avatar

Carl Weis carlweis

View GitHub Profile
@carlweis
carlweis / .pryrc
Created March 14, 2017 19:07
Custom Environment Consoles
# .pryrc
color_escape_codes = {
black: "\033[0;30m",
red: "\033[0;31m",
green: "\033[0;32m",
yellow: "\033[0;33m",
blue: "\033[0;34m",
purple: "\033[0;35m",
cyan: "\033[0;36m",
reset: "\033[0;0m"
@carlweis
carlweis / modal.html.slim
Created March 9, 2017 19:27
Bootstrap slim modal
/! Modal
#myModal.modal.fade aria-labelledby="myModalLabel" role="dialog" tabindex="-1"
.modal-dialog role="document"
.modal-content
.modal-header
button.close aria-label="Close" data-dismiss="modal" type="button"
span aria-hidden="true" ×
h4#myModalLabel.modal-title Modal title
.modal-body
| \...
@carlweis
carlweis / modal.html.slim
Created March 9, 2017 19:27
Bootstrap slim modal
/! Modal
#myModal.modal.fade aria-labelledby="myModalLabel" role="dialog" tabindex="-1"
.modal-dialog role="document"
.modal-content
.modal-header
button.close aria-label="Close" data-dismiss="modal" type="button"
span aria-hidden="true" ×
h4#myModalLabel.modal-title Modal title
.modal-body
| \...
@carlweis
carlweis / laptop
Created February 11, 2017 21:43
Shell script to setup a rails development machine
#!/bin/sh
# exit on any error
set -e
echo | echo "$(tput setaf 3)Setting up machine for Ruby on Rails development\n\n"
echo "$(tput setaf 3)Installing laptop setup..."
echo "$(tput setaf 7)"
curl --remote-name https://raw.githubusercontent.com/thoughtbot/laptop/master/mac
sh mac 2>&1
@carlweis
carlweis / tmux.hybrid
Created January 18, 2017 05:57
tmux hybrid color scheme
## color sheme: hybrid
# default statusbar colors
set-option -g status-bg colour0 #base02
set-option -g status-fg colour6 # colour100 #yellow
set-option -g status-attr default
# default window title colors
set-window-option -g window-status-fg colour13 #base0
set-window-option -g window-status-bg default
@carlweis
carlweis / ruby_methods
Created January 17, 2017 19:52
Ruby methods for interview process.
# method 1
# returns members of the Fibonacci series up to a certain value
def method_one(max)
i1, i2 = 1, 1
while i1 <= max
yield i1
i1, i2 = i2, i1+i2
end
end
# demo.gemspec
Gem::Specification.new do |spec|
spec.name = "Demogem"
spec.version = "1.0.2"
spec.authors = ["Carl Weis"]
spec.email = ["[email protected]"]
spec.description = %q{A Ruby library for a demo app.}
spec.summary = %q{Demo Gem Library}
spec.homepage = "http://carlweis.com/gems/demo"
spec.license = "MIT"
set nocompatible " be iMproved, required
so ~/.vim/plugins.vim " load vundle plugins
syntax enable
"-------------General Settings--------------"
set backspace=indent,eol,start "Make backspace behave like every other editor.
let mapleader = ',' "The default leader is \, but a comma is much better.
@carlweis
carlweis / form_helper.rb
Created January 23, 2016 20:19
Rails Twitter Boostrap form helper.
module FormHelper
def errors_for(form, field)
content_tag(:p, form.object.errors[field].try(:first), class: 'help-block')
end
def form_group_for(form, field, &block)
has_errors = form.object.errors[field].present?
content_tag :div, class: "form-group #{'has-error' if has_errors}" do
concat form.label(field, class: 'control-label')
@carlweis
carlweis / laravel_travisci_codecep
Created January 11, 2016 23:45
laravel setup travis ci with codeception tests
I spent some time on this recently - and my conclusion is that you cannot use memory sqlite for acceptance tests - due to the way acceptance tests work. i.e. because you are making an 'external' request to the server from your client (i.e. you make a curl request to the server) - then you cant have a memory database.
I tried a few things - and it just kept causing weird errors and failing tests when it should otherwise work.
What I do instead, for all my tests, is create a 'stubdb.sqlite' file - and then literally make a copy of that file inbetween each test. It is ridicously fast - especially if you have an SSD drive.
So my config\database.php file looks like this:
'mysqldev' => [
'driver' => 'mysql',