Skip to content

Instantly share code, notes, and snippets.

View JaisonBrooks's full-sized avatar

Jaison Brooks JaisonBrooks

  • Enphase Energy
  • Boise, ID
View GitHub Profile
@JaisonBrooks
JaisonBrooks / 0000_packages.config
Created December 2, 2016 17:10 — forked from gcarrion-gfrmedia/0000_packages.config
AWS Elastic Beanstalk Ruby 2.0/Puma Environment - .ebextensions tweaks and Sidekiq configuration. This is known to work fine with AWS Elastic Beanstalk 's 64bit Amazon Linux 2014.03 v1.0.1 running Ruby 2.0 (Puma) stack. Later stack versions might not work, but for that specific version works fine.
# Install Git needed for Git based gems
packages:
yum:
git: []
@JaisonBrooks
JaisonBrooks / remove_input_number_scroll.js
Last active July 11, 2022 15:09
Disable Input[type=number] scroll action
// Disable Mouse scrolling
$('input[type=number]').on('mousewheel',function(e){ $(this).blur(); });
// Disable keyboard scrolling
$('input[type=number]').on('keydown',function(e) {
var key = e.charCode || e.keyCode;
// Disable Up and Down Arrows on Keyboard
if(key == 38 || key == 40 ) {
e.preventDefault();
} else {
return;
@JaisonBrooks
JaisonBrooks / application.html.erb
Created January 26, 2016 23:24 — forked from suryart/application.html.erb
Rails 4 flash messages using Twitter Bootstrap(bootstrap-sass: https://github.com/thomas-mcdonald/bootstrap-sass). An improved version of https://gist.github.com/roberto/3344628
// layout file
<body>
<div class="container">
<%= flash_messages %>
<%= yield %>
</div><!-- /container -->
</body>
@JaisonBrooks
JaisonBrooks / random_hex_colors.rb
Last active December 16, 2015 21:51
Generate random hex colors in ruby
```
255.times { puts '#%06x'%(rand*0xffffff) }
```
#3df5bd
#55e6a6
#52c4e4
#c5fc45
#07debb
#3a29eb
#e7a501
@JaisonBrooks
JaisonBrooks / getting_started.md
Created December 10, 2015 15:07 — forked from boddhisattva/getting_started.md
Writing a spec from scratch for a plain ruby script(no rails) using TDD

Steps -

  • Create the filename.rb file for which you’d like to create a filename_spec.rb
  • Run the command rspec --init from the same working directory as to where you have filename.rb
  • the above command will create a .rspec file for you
  • It will create a new spec directory within which you need to place your specs
  • It will create spec_helper.rb where you need continually require the ruby files that you would want to write specs for
  • Create the filename_spec.rb within the spec directory
  • [optional] Edit the .rspec file to add the option: --format documentation
  • The above addition gives your running tests more readability as to what they do or what they stand for when they are run.
@JaisonBrooks
JaisonBrooks / install_spigot.sh
Last active September 18, 2015 03:51
Install the Spigot Minecraft server via command line | Checkout => www.spigotmc.org and http://getspigot.org/ for more details.
# Make sure you have java 7+, git and a beer cause its going to be awhile :) #
wget http://getspigot.org/build.sh && sudo bash build.sh
@JaisonBrooks
JaisonBrooks / Capistrano 3.md
Last active September 16, 2015 19:32 — forked from stevenyap/Capistrano 3.md
Capistrano 3 Setup

This guide explains the way to setup a production server using Capistrano.

Setup Capistrano on LOCAL

  • Capistrano is a development gem which assist the developer to run commands on the production server (something like a Heroku toolbelt)
  • Hence, it is installed and configured on developer's computer
# Gemfile

# Use Capistrano for deployment
@JaisonBrooks
JaisonBrooks / split_and_replace_to_array.rb
Created September 10, 2015 22:24
Split and extract pieces of a string into an array, only leaving what you need
# I have the following string and needed to extract just the values from it.
# Thus removing the key and =/& symbols and return the values in an array
#
# I did it like so.
str = "str1=lolf839Di8FjliWBfcceBab8PvD9AuqY1b7ISjVL43XeOh7yaUA&str2=OAW8mb1x7lEl0s5OUCz7vdZtMVzYXI9j8IYkxhKfCbQ"
str.split('&').each{|b| b.gsub!(/.*?=(?=)/im, "")}
# > ["lolf839Di8FjliWBfcceBab8PvD9AuqY1b7ISjVL43XeOh7yaUA", "OAW8mb1x7lEl0s5OUCz7vdZtMVzYXI9j8IYkxhKfCbQ"]
@JaisonBrooks
JaisonBrooks / example.rb
Last active September 10, 2015 21:49 — forked from erikeldridge/example.rb
A utility for signing an url using OAuth in a way that's convenient for debugging
require 'oauth_util.rb'
require 'net/http'
o = OauthUtil.new
o.consumer_key = 'examplek9SGJUTUpocjZ5QjBJmQ9WVdrOVVFNHdSR2x1TkhFbWNHbzlNQS0tJnM9Y29uc3VtkZXJzZWNyZXQmeD0yYg--';
o.consumer_secret = 'exampled88d4109c63e778dsadcdd5c1875814977';
url = 'http://query.yahooapis.com/v1/yql?q=select%20*%20from%20social.updates.search%20where%20query%3D%22search%20terms%22&diagnostics=true';