Skip to content

Instantly share code, notes, and snippets.

@jkotchoff
jkotchoff / google_play_verification.rb
Last active July 6, 2023 17:57
Verifying an Android subscription in a Ruby on Rails app using the Google Play API
class GooglePlayVerification
require 'google/api_client'
# Refer:
# https://code.google.com/p/google-api-ruby-client/issues/detail?id=72
# and
# http://jonathanotto.com/blog/google_oauth2_api_quick_tutorial.html
# and
# http://milancermak.wordpress.com/2012/08/24/server-side-verification-of-google-play-subsc/
GOOGLE_KEY = 'xxx-xxx.apps.googleusercontent.com'
@toshimaru
toshimaru / jquery-scroll-bottom.js
Last active July 21, 2024 00:02
Detect the scrolling to bottom of the page using jQuery.
$(window).on("scroll", function() {
var scrollHeight = $(document).height();
var scrollPosition = $(window).height() + $(window).scrollTop();
if ((scrollHeight - scrollPosition) / scrollHeight === 0) {
// when scroll to bottom of the page
}
});
@runlevel5
runlevel5 / 00_pending_migrations.rb
Last active November 8, 2016 09:03
An initialiser to prevent app to bootstrap app on dev env if pending migrations - cover Rails 3 or newer
## Place in config/initializers/00_pending_migrations.rb
# Raise an error and abort the run there are any pending migrations:
if Rails.env.development?
# Rails 4 way ;)
if Rails.version >= '4'
ActiveRecord::Migration.check_pending!
else
# Rails 3 way - TODO: remove when we up to Rails 4
migrator = ActiveRecord::Migrator.new(