Skip to content

Instantly share code, notes, and snippets.

@crslade
crslade / test_helper.rb
Created August 9, 2022 02:43
Sample Test Helper File for using Capybara in Integration Tests
ENV["RAILS_ENV"] ||= "test"
require_relative "../config/environment"
require "rails/test_help"
#Use Spec DSL
require 'minitest/spec'
#Helpers
require 'capybara/rails'
require 'mocha/minitest'
@crslade
crslade / Guardfile
Created August 9, 2022 02:40
Sample Guardfile for Integration and Model tests
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
## Uncomment and set this to only include directories you want to watch
# directories %w(app lib config test spec features) \
# .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}
## Note: if you are using the `directories` clause above and you are not
## watching the project directory ('.'), then you will want to move
## the Guardfile to a watched dir and symlink it back, e.g.
// This file is automatically compiled by Webpack, along with any other files
// present in this directory. You're encouraged to place your actual application logic in
// a relevant structure within app/javascript and only use these pack files to reference
// that code so it'll be compiled.
require("@rails/ujs").start()
require("turbolinks").start()
require("@rails/activestorage").start()
require("channels")
require("bootstrap/dist/js/bootstrap")
{
"devices": [
{
"deviceName": "HVAC Controller",
"deviceType": "HVAC Controller",
"devicePath": "",
"parameters": [
{ "paramName": "heat", "paramType": "bool", "paramActions": "both"},
{ "paramName": "ac", "paramType": "bool","paramActions": "both"},
{ "paramName": "fan", "paramType": "bool", "paramActions": "both"},
@crslade
crslade / havc.json
Last active November 13, 2017 20:04
{
"deviceName": "HVAC",
"deviceType": "HVAC",
"parameters": [
{"paramName": "Current Temperature", "paramType": "number", "paramActions": "read"},
{"paramName": "Set Temperature", "paramType": "number", "paramActions": "both"}
]
}
Verifying that "crslade.id" is my Blockstack ID. https://onename.com/crslade
@crslade
crslade / AxesDrawers
Created October 4, 2016 22:36
AxesDrawers for Stanford's CS193p, updated to Swift 3.0
//
// AxesDrawer.swift
// Calculator
//
// Created by CS193p Instructor.
// Copyright (c) 2015-16 Stanford University. All rights reserved.
//
import UIKit
@crslade
crslade / config.ru
Created October 25, 2011 08:33
config.ru to redirect Wordpress links to Blogger.
require 'rack/rewrite'
use Rack::Static, :urls => ['/index.html', '/favicon.ico'], :root => 'public'
if ENV['RACK_ENV'] == 'development'
use Rack::ShowExceptions
end
#change to your domain
root = 'http://www.christopherslade.com'
@crslade
crslade / .htaccess
Created October 25, 2011 08:11
.htaccess file to redirect Wordpress links to Blogger
Options +FollowSymLinks
RewriteEngine On
#index page
RewriteRule ^index.php http://www.christopherslade.com [R=301,L]
#About
RewriteRule ^author/crslade http://www.christopherslade.com/p/about_21.html [R=301,L]
RewriteRule ^about http://www.christopherslade.com/p/about_21.html [R=301,L]
# Feed
RewriteRule ^feed http://www.christopherslade.com/feeds/posts/default [R=301,L]
# Post URL
<%= drop_receiving_element :droppable, :accept => "draggable", :hoverclass => "hover", :url => draggable_elements_path, :method => :post, :with => "'element_id='+encodeURIComponent(element.id.split('_').last()) +
'&x='+ encodeURIComponent(Element.getStyle(element,'left')) + '&y='+ encodeURIComponent(Element.getStyle(element,'top')) ">