Skip to content

Instantly share code, notes, and snippets.

View gangelo's full-sized avatar
:octocat:
Got codez?

Gene M. Angelo, Jr. gangelo

:octocat:
Got codez?
View GitHub Profile
@gangelo
gangelo / accessing-virtualbox.md
Last active May 27, 2018 01:53
Accessing your Virtualbox Guest from your Host OS

Accessing your Virtualbox Guest from your Host OS

As a developer you want to ping and access the webserver on your virtual machine. This is a very simple solution to enable the bridge to the guest VM.

Requirements

  • VirtualBox (latest version)
  • A guest operation system (e.g. Ubuntu)
@gangelo
gangelo / nokogiri_namespace_usage.rb
Last active February 15, 2019 14:45 — forked from mudge/gist:428455
Namespaces with Nokogiri::Builder
# Dealing with namespaces in Nokogiri.
#
# First thing you must do is abandon what you're used to with Builder,
# namespaces aren't just attributes on an element, they uniquely identify
# what sort of element you are building and, as such, you are better off
# specifying them manually.
#
# The key here is accessing the Nokogiri::XML::Element being built with
# b.parent, then you can set the namespace (distinguished by an element
# with a prefix such as "soap12:Envelope") or add a default namespace
@gangelo
gangelo / Benchmark Helper
Created January 25, 2018 01:19
Benchmark Helper
require 'benchmark'
=begin
# Example use
do_benchmark("Each loop test") do
(1..100).each do |n|
puts (n * n).to_s
end
end
@gangelo
gangelo / template.html
Last active January 25, 2018 11:52
HTML5/CSS3 Template
<!doctype html>
<html lang='en'>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<meta name="description" content="My Description">
<meta name="keywords" content="keyword1, keyword2">
<meta name="author" content="Gene M. Angelo, Jr.">
@gangelo
gangelo / Miscellaneous file changes
Last active February 1, 2018 14:36
Bootstrap Modal Dialog Example
# *** ATTENTION ***
# Be sure to run the below generator after updating the below files:
# $ rails generate bootstrap:install less --no-coffeescript -p
# $ rails generate rspec:install -p
# *** ATTENTION ***
#
# /Gemfile
# Gems to add bootstrap, jquery using less, and font-awesome-rails.
@gangelo
gangelo / fizz_buzz.rb
Last active December 14, 2022 09:29
fizz buzz
# Fizz buzz
# Range 1 -> 100 (inclusive)
# If divisible by 3, output fizz
# If divisible by 5, output buzz
# If divisible by 3 and 5, output fizzbuzz
FIZZ = 'fizz'.freeze
BUZZ = 'buzz'.freeze
FIZZBUZZ = (FIZZ + BUZZ).freeze
@gangelo
gangelo / UIDesignableXibExample.swift
Created December 8, 2016 14:12
A designable .xib .swift class example [Swift 3, Xcode 8.1]
//
// UIDesignableXibExample.swift
//
// Created by Gene M. Angelo Jr. on 12/8/16.
// Copyright © 2016 Mohojo Werks LLC. All rights reserved.
//
import UIKit
@IBDesignable class UIDesignableXibExample: UIView {
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
Flash[:notice] vs. Flash.now[:notice]
============================================
Flash[:notice] - message will persist to the next action and should be used when redirecting to another action via the 'redirect_to' method.
Flash.now[:notice] - message will be displayed in the view your are rendering via the 'render' method.
Log and watch messages logged realtime
============================================
# In my code...
@gangelo
gangelo / database_cleaner.rb
Created September 20, 2014 18:41
database_cleaner, rspec-rails and capybara configuration strategy
#
# What's this do?
#
# Keep your test database clean whilst testing, using database_cleaner, rspec-rails and capybara.
#
# Instructions:
#
# Place this file in spec/support
#
# Assumptions: