This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function makeRequest(url) { | |
httpRequest = new XMLHttpRequest(); | |
if (!httpRequest) { | |
displayErrorMsg('Sorry, there was a problem making the request!'); | |
return false; | |
} | |
httpRequest.onreadystatechange = receiveRequest; | |
httpRequest.open('GET', url); | |
httpRequest.send(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
participants = ["Lena", "Seth", "Paul", "Suz", "Nina", "Burke", "Todd"] | |
print(f"{random.choice(participants)} is taking notes.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# This will force ActiveRecord to create proper `interval` column types in PostgreSQL | |
# | |
# def change | |
# add_column :leases, :period, :interval | |
# end | |
# | |
# This applies to a generated `schema.rb` file too. | |
# | |
# No special OID type is applied to an `interval` type. Rails will treat it as a string, although |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Integer | |
def factorial | |
result = 0 | |
self.downto(1) { |number| result == 0 ? result = number : result *= number } | |
return result | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# implementation from https://github.com/rails/rails/pull/16919 | |
# activerecord/lib/active_record/connection_adapters/postgresql/oid/interval.rb | |
require "active_support/duration" | |
module ActiveRecord | |
module ConnectionAdapters | |
module PostgreSQL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf $TMPDIR/npm-* && rm -rf $TMPDIR/haste-* && rm -rf $TMPDIR/metro-* && rm -rf node_modules && npm install && rm -rf ios/Pods && cd ios && pod cache clean --all && pod repo update && pod install && ./android/gradlew clean -p ./android/ && rm -rf ios/build && rm -rf ~/Library/Developer/Xcode/DerivedData && npm start -- --reset-cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'bcrypt' | |
require 'haml' | |
require 'sinatra' | |
enable :sessions | |
userTable = {} | |
helpers do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/opt/apps/ruby/ruby/bin/ruby | |
require 'date' | |
# The initial date format as a String | |
my_date = "2013-10-03 21:03:46Z" | |
# Convert the Date to a DateTime Object | |
date_obj = DateTime.strptime(my_date,'%Y-%m-%d %H:%M:%S%Z') | |
# Re-Format the date - returns a String |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# a simple/configurable rake task that generates some random fake data for the app (using faker) at various sizes | |
# NOTE: requires the faker or ffaker gem | |
# sudo gem install faker - http://faker.rubyforge.org | |
# OR | |
# sudo gem install ffaker - http://github.com/EmmanuelOga/ffaker | |
require 'faker' | |
class Fakeout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Cleans up branches like: | |
# if Shopify.rails_next? | |
# # Rails 5 login | |
# else | |
# # Rails 4 login | |
# end | |
module RuboCop | |
module Cop | |
module ShopifyRails | |
class RailsNextUnless < Cop |
OlderNewer