Skip to content

Instantly share code, notes, and snippets.

View carlweis's full-sized avatar

Carl Weis carlweis

View GitHub Profile
@carlweis
carlweis / .phpstorm.meta.php
Created December 11, 2015 19:00 — forked from barryvdh/.phpstorm.meta.php
Laravel PhpStorm Meta file
<?php
namespace PHPSTORM_META {
/**
* PhpStorm Meta file, to provide autocomplete information for PhpStorm
* Generated on 2015-06-22.
*
* @author Barry vd. Heuvel <[email protected]>
* @see https://github.com/barryvdh/laravel-ide-helper
*/
@carlweis
carlweis / usa-vector-map-svg
Created January 6, 2016 06:51
SVG Map of the United States
<svg height="668.4389989572471" version="1.1" width="1081" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="overflow: hidden; position: relative; top: -0.661621px;" viewBox="0 0 959 593" preserveAspectRatio="xMinYMin"><desc style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);">Created with Raphaël 2.1.2 and Mapael (http://neveldo.fr/mapael)</desc><defs style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></defs><path fill="#343434" stroke="#5d5d5d" d="M233.08751,519.30948L235.02744,515.75293L237.29070000000002,515.42961L237.61402,516.23791L235.51242000000002,519.30948L233.08751,519.30948ZM243.27217000000002,515.59127L249.41530000000003,518.1778400000001L251.51689000000002,517.8545200000001L253.13350000000003,513.9746500000001L252.48686000000004,510.5797700000001L248.28366000000003,510.0947900000001L244.24213000000003,511.8730600000001L243.27217000000005,515.5912700000001ZM273.9878,525.61427L277.706,531.1107400000001L280.13092,530.7874200000001L281.26255,530.3024400000002
@carlweis
carlweis / countries_migration.rb
Created January 11, 2016 10:29
Import countries into rails app
require 'csv'
class CreateCountries < ActiveRecord::Migration[5.0]
def change
create_table :countries do |t|
t.string :code, null: false
t.decimal :latitude, {:precision => 10, :scale=>6}
t.decimal :longitude, {:precision => 10, :scale=>6}
t.string :name, null: false
t.boolean :active, null: false, default: false
@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',
@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')
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.
# 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"
@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
@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 / 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