Skip to content

Instantly share code, notes, and snippets.

Avatar
🇺🇦
Slava Ukrayini!

Ben Phelps benphelps

🇺🇦
Slava Ukrayini!
View GitHub Profile
View gist:101fa08a064fed2dd5b979119a89117d
phelps:7qVlf2c69e7daca8b0b5cb0d3bc869faff3719a359777d8f5741f9739f212b34637a:175dac88690
View test_spec.cr
require "./spec_helper"
def test_statement(statement : AST::LetStatement, name : String)
it "expectes token_literal to be let" do
statement.token_literal.should eq("let")
end
it "should be an AST::LetStatement" do
statement.should be_a(AST::LetStatement)
end
@benphelps
benphelps / pitmaster.lua
Last active Sep 30, 2019
A computer craft turtle program.
View pitmaster.lua
--[[
How about no.
]]
local CHEST_SLOT = 16
local PIT_WIDTH = 3
local PIT_LENGTH = 3
local PIT_DEPTH = 45
local function log(str, ...)
View Abstraction.php
<?php
namespace PDG\Database;
use PDO;
/**
* An actually simple PDO wrapper. Woah, dude.
*/
class Abstraction
View Guardfile
require 'active_support/inflector'
guard :rspec, cmd: 'WAT=wat spring rspec' + (ENV['DOC_FORMAT'] ? ' --format documentation' : ''), notification: false do
watch(%r{^spec/features/.+_spec\.rb$})
watch(%r{^spec/models/.+_spec\.rb$})
watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1].singularize}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| "spec/features/#{m[1].singularize}_spec.rb" }
watch(%r{^app/models/(.+)\.rb$}) { |m| "spec/models/#{m[1]}_spec.rb" }
watch(%r{^spec/factories/(.+)_spec\.rb$}) do |m|
["app/models/#{m[1].singularize}.rb", "spec/models/#{m[1].singularize}_spec.rb"]
@benphelps
benphelps / __readme.md
Last active Sep 9, 2020
Action Specific Javascript for Rails 5
View __readme.md

Action Specific Javascript for Rails 5

This is a simple example of action specific javascript. It also allows you to pass data to JS from inside rails controllers. Works with Turbolinks 5 (not required).

Installation

Add the files below to your project, then insert <%= insert_javascript_hook %> somewhere in the footer of your layout.

You'll need these gems:

gem 'jquery-rails'
View heh.rb
def sub_heading(content = nil)
@sub_headings ||= []
if content
@sub_headings.push content
elsif block_given?
@sub_headings.each do |sub_heading|
yield sub_heading
end
else
Enumerator.new do |y|
@benphelps
benphelps / .gitlab-ci.yml
Created Jan 11, 2017
A test / deploy setup I use
View .gitlab-ci.yml
image: benphelps/docker-ruby-phantomjs:latest
Testing:
services:
- postgres:latest
variables:
POSTGRES_DB: test
POSTGRES_HOST: postgres
POSTGRES_USER: testuser
POSTGRES_PASS: testuser
environment: test
@benphelps
benphelps / .env
Last active Jan 17, 2017
Cloud66 Basic Postgres
View .env
POSTGRES_USER=phelps
POSTGRES_PASS=phelps
POSTGRES_HOST=localhost
View location_helper.rb
module LocationHelper
def render_location_html(location)
content_tag :address do
content = ''
content += location.address_1 + tag(:br) if location.address_1.present?
content += location.address_2 + tag(:br) if location.address_2.present?
content += location.address_3 + tag(:br) if location.address_3.present?
content += location.short if location.short.present?
content
end