Skip to content

Instantly share code, notes, and snippets.

View Jellyfishboy's full-sized avatar
🏠
Working from home

Tom Dallimore Jellyfishboy

🏠
Working from home
View GitHub Profile
@Jellyfishboy
Jellyfishboy / nil_vs_empty_vs_blank_ror.md
Last active December 6, 2017 05:26
nil vs empty vs blank in Ruby on Rails

.nil? can be used on any object and is true if the object is nil.

.empty? can be used on strings, arrays and hashes and returns true if:

  • String length == 0
  • Array length == 0
  • Hash length == 0

Running .empty? on something that is nil will throw a NoMethodError.

@Jellyfishboy
Jellyfishboy / linx-rails-server-setup.md
Last active November 1, 2016 14:59
Nginx + Postgresql + rbenv + Rails + Redis + Memcached + Monit || Linux server setup

Update server

sudo yum update

Install system monitoring

sudo yum install htop
@Jellyfishboy
Jellyfishboy / exampleJSONforshiptationorder
Created September 15, 2016 10:39
Example JSON for Shipstation Create Order
{
"orderNumber" => 1,
"customerEmail" => "me@tomdallimore.com",
"customerUsername" => "me@tomdallimore.com",
"orderDate" => "2016-09-14 12:33:55",
"paymentDate" => "2016-09-14 12:33:55",
"orderStatus" => "awaiting_shipment",
"billTo" => {
"name" => "Wanda Predovic",
"company" => "",
@Jellyfishboy
Jellyfishboy / rubytimezonedosdonts.md
Last active August 28, 2016 17:03
Ruby Timezone Dos & Donts

Dos

2.hours.ago # => Thu, 27 Aug 2015 14:39:36 AFT +04:30
1.day.from_now # => Fri, 28 Aug 2015 16:39:36 AFT +04:30
Time.zone.parse("2015-08-27T12:09:36Z") # => Thu, 27 Aug 2015 16:39:36 AFT +04:30
Time.current # => Thu, 27 Aug 2015 16:39:36 AFT +04:30
Time.current.utc.iso8601 # When supliyng an API ("2015-08-27T12:09:36Z")
Time.strptime("2015-08-27T12:09:36Z", "%Y-%m-%dT%H:%M:%S%z").in_time_zone # If you can’t use Time.zone.parse (Thu, 27 Aug 2015 16:39:36 AFT +04:30)
Date.current # If you really can’t have a Time or DateTime for some reason (Thu, 27 Aug 2015)
@Jellyfishboy
Jellyfishboy / railserversetup.md
Last active November 21, 2017 06:49
Nginx + Postgresql + rbenv + Rails + Redis + Memcached + Monit || Ubuntu 14+ server setup

Update server

sudo apt-get update

sudo apt-get dist-upgrade

Install system monitoring