Skip to content

Instantly share code, notes, and snippets.

@mahemoff
mahemoff / TestCase
Last active August 29, 2015 14:15
Rails TestCase - Log current test case info plus couple of other tricks (handy if watching test and useful to see where console messages are being output from)
class ActiveSupport::TestCase
ActiveRecord::Migration.check_pending!
fixtures :all
def setup
puts "------ #{self.class}:#{method_name} ------"
Rails.cache.clear
self.do_setup
...
@mahemoff
mahemoff / gist:8d1109d9761c35ee4925
Created March 16, 2015 08:08
Three UK - getting support
03333003333
menu sequence: 4 2 2 4 1
@mahemoff
mahemoff / gist:c4ba901515fd93f39242
Created April 26, 2015 00:34
AWS policy to assign a user to a single bucket
# Create this from IAM - Users - the user - Inline policies - create one - Custom Policy - paste this
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "s3:*",
"Effect": "Allow",
"Resource": [
"arn:aws:s3:::my-bucket",
@mahemoff
mahemoff / access-s3.rb
Created April 27, 2015 17:32
aws-s3 v2 gem example
# Elaborating on https://docs.aws.amazon.com/AWSRubySDK/latest/index.html
Aws.config.update(
region: 'us-east-1', # https://docs.aws.amazon.com/general/latest/gr/rande.html
credentials: Aws::Credentials.new(
Figaro.env.s3_access_key_id,
Figaro.env.s3_secret_access_key
)
)
s3 = Aws::S3::Client.new
@mahemoff
mahemoff / gist:28e531550d6c4c8ab8eb
Last active August 29, 2015 14:21
Subtle radial gradient - good as an overlay for text in front of a photo
background: radial-gradient(ellipse farthest-corner at 50% 50% , rgba(0,0,0,0.4) 20%, rgba(0,0,0,0) 200%)
@mahemoff
mahemoff / episode.haml
Created June 24, 2015 08:23
Twitter card meta tags
%meta(name="twitter:card" content="player")
%meta(name="twitter:title" content="#{@episode.safe_title} by #{@series.safe_title}")
%meta(name="twitter:app:name:googleplay" content="Player FM")
%meta(name="twitter:app:id:googleplay" content="fm.player")
%meta(name="twitter:description" content="#{@episode.safe_description}")
%meta(name="twitter:site" content="PlayerFM")
%meta(name="twitter:image" content="#{safe_series_image_url @episode.series}")
-# dev tunnel -> %meta(name="twitter:player" content="https://something-something.ngrok.com#{widget_episode_path series_id: @series.slug, id: @episode.slug}"
)
%meta(name="twitter:player" content="#{Player.routes.base_url}#{widget_episode_path series_id: @series.slug, id: @episode.slug}")
@mahemoff
mahemoff / confirm.coffee
Created August 6, 2015 09:14
Confirm window close while playing
window.onbeforeunload = ->
if player.isPlaying()
"This will stop playback."
netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserRead');
$.get("http://twitter.com",
function(response) {
var token= response.match(/authenticity_token.*?value="(.*?)"/)[1]
netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserRead');
$.post("http://twitter.com/sessions", {
"session[authenticity_token]": token,
"session[username_or_email]": $("#username").val(),
"session[password]": $("#password").val()
}, function(html) {
@mahemoff
mahemoff / finding jQuery andSelf useful
Created August 21, 2009 14:19
finding jQuery andSelf useful
$(".delete").live("click", function() {
$(this).parents("tr").prev().andSelf().remove();
});