Skip to content

Instantly share code, notes, and snippets.

View masom's full-sized avatar
💭
I may be slow to respond.

Martin Samson masom

💭
I may be slow to respond.
  • Shopify
  • Ottawa, Canada
View GitHub Profile
@derrek
derrek / google_play_receipt_verification.md
Last active August 17, 2022 19:34
Google Play/Android Receipt Validation/Verification/Lookup with Ruby

This document outlines setting up google's ruby gem, google-api-client, to verify payloads(receipts) sent to a server from google play in app purchases made via an android app.
This document was written using version 0.9.13.

First you'll need 'owner' access to the google play developer's console that contains the mobile app you wish to verify receipts from.

  • Go to https://play.google.com/apps/publish
  • Click on the mobile app you'd like to set up
  • Click "Settings" on the left click "API access"
  • Below "LINKED PROJECT" link the google play account

Next setup an api account

@pamelafox
pamelafox / sortable.py
Last active May 6, 2018 05:15
Hotlist algorithm
"""Scores for any type of entity.
This is used to rank entities, for example the list of top forks of a
scratchpad and the current "hottest" scratchpads.
"""
import math
import datetime
import functools
@thebucknerlife
thebucknerlife / authentication_with_bcrypt_in_rails_4.md
Last active July 10, 2024 00:17
Simple Authentication in Rail 4 Using Bcrypt

#Simple Authentication with Bcrypt

This tutorial is for adding authentication to a vanilla Ruby on Rails app using Bcrypt and has_secure_password.

The steps below are based on Ryan Bates's approach from Railscast #250 Authentication from Scratch (revised).

You can see the final source code here: repo. I began with a stock rails app using rails new gif_vault

##Steps

@jhilden
jhilden / discourse_sso.rb
Last active June 16, 2018 04:11
# Discourse SSO Rails::Engine gem to perform cookie-based SSO login in [Discourse](http://www.discourse.org/). It expects your main app to set a cookie readable by Discourse with a Discourse `user_id` as the value (encrypting the value is a very good idea). See: http://meta.discourse.org/t/give-me-those-authentication-hooks-d/3943
module DiscourseSso
module ControllerExtensions
def self.included(klass)
klass.append_before_filter :ensure_sso_login
end
private
@pamelafox
pamelafox / util.js
Created April 13, 2012 17:44
JavaScript Utility Libraries (Scroll down!)
var ED = ED || {};
// Utility functions
ED.util = (function() {
// Data structure functions
function each(object, callback) {
if (object === null) return;

Proposal for Improving Mass Assignment

For a while, I have felt that the following is the correct way to improve the mass assignment problem without increasing the burden on new users. Now that the problem with the Rails default has been brought up again, it's a good time to revisit it.

Sign Allowed Fields

When creating a form with form_for, include a signed token including all of the fields that were created at form creation time. Only these fields are allowed.

To allow new known fields to be added via JS, we could add:

@burke
burke / 0-readme.md
Created January 27, 2012 13:44 — forked from funny-falcon/cumulative_performance.patch
ruby-1.9.3-p327 cumulative performance patch for rbenv

ruby-1.9.3-p327 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

@pamelafox
pamelafox / _ie_warning.html
Created January 25, 2012 00:06
IE ChromeFrame conditional prompt and alert
<!--[if lt IE 7]>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/chrome-frame/1/CFInstall.min.js"></script>
<script>
// The conditional ensures that this code will only execute in IE,
// Therefore we can use the IE-specific attachEvent without worry
window.attachEvent("onload", function() {
CFInstall.check({
mode: "overlay"
});
@aarongrando
aarongrando / gist:1635158
Created January 18, 2012 19:53
jQuery UI Autocomplete Facebook Friends
$(function() {
// Depends on: jQuery, jQuery UI core & widgets (for the autocomplete method)
// Assumes you're already including the FB JS SDK asynchronously...
window.fbAsyncInit = function() {
FB.init({
appId : 'xxxxxxxxxxxxxxxxxx', // App ID
status : true, // check login status