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 / 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 / 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 / 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 / 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 / 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 / predawn-DEV.sublime-theme
Last active April 24, 2019 10:39
Sublime Text 3 Predawn Theme Changes
// This needs to go in the "~/.config.sublime-text-3/Packages" folder on Linux.
[
{
// Vertical scroll puck
"class": "puck_control",
"layer0.texture": "",
"layer0.opacity": 1.0,
"layer0.inner_margin": [0, 5],
"content_margin": [5, 20],
"blur": false,
# Call non-public methods directly to test
describe '#my_private_method' do
before do
Yardi::Yardi4LeaseTransfer.send(:public, *Yardi::Yardi4LeaseTransfer.private_instance_methods)
end
...
it 'should be able to call method directly' do
expect(object.my_private_method).to ...
end
#!/bin/bash
# This script converts .heic files to .jpg files. The actual file encoding
# is checked, so that if the file is renamed correctly, it will be named
# and converted properly.
#
# Instructions:
#
# From the folder that contains the image files you want to convert...
#
@gangelo
gangelo / tmdel
Created March 2, 2020 15:28
Bash script to delete local Time Machine snapshots
for d in $( tmutil listlocalsnapshots / )
do
if [[ $d =~ ^.+([0-9]{4}-[0-9]{2}-[0-9]{2}-[0-9]{6})$ ]]; then
date=${BASH_REMATCH[1]}
echo "Running tmutil deletelocalsnapshots $date..."
( tmutil deletelocalsnapshots $date )
fi
done
@gangelo
gangelo / network.rb
Last active January 7, 2022 00:17
Hacking
# Examples:
#
# Hacking::Networking.network_info_for(ip: '192.168.114.32/27')
# Hacking::Networking.network_info_for(ip: '192.168.33.12', mask: '255.255.224.0')
# => {:ip=>[192, 168, 33, 12], :mask=>[255, 255, 224, 0], :cidr_info=>{:cidr=>19, :network=>"192.168.32.0", :cidr_notation=>"192.168.32.0/19"}, :network=>"192.168.32.0", :host=>"0.0.1.12", :total_hosts=>8192}
# Hacking::Networking.network_for(ip: '192.168.33.12', mask: '255.255.224.0') # => "192.168.32.0"
# Hacking::Networking.host_for(ip: '192.168.33.12', mask: '255.255.224.0') # => "0.0.1.12"
# Hacking::Networking.total_hosts_for(mask: '255.255.224.0') # => 8192
# Hacking::Networking.to_binary('192.168.33.12') # => "11000000.10101000.00100001.00001100"
# Hacking::Networking.to_binary('255.255.224.0') # => "11111111.11111111.11100000.00000000"