Skip to content

Instantly share code, notes, and snippets.

@rkjha
rkjha / nginx-passenger-ssl.conf
Last active March 25, 2021 15:47
Nginx/Passenger config when using SSL with a Ruby/Rails Application.
# for redirecting hhtp traffic to https version of the site
server {
listen 80;
server_name example.com;
return 301 https://$server_name$request_uri;
}
# for redirecting to non-www version of the site
server {
listen 80;
@rkjha
rkjha / amazon_uam_sample_config.js
Last active July 26, 2019 11:16
amazon_uam_sample_config for header.
// Load APS library
!function(a9,a,p,s,t,A,g){if(a[a9])return;function q(c,r){a[a9]._Q.push([c,r])}a[a9]={init:function(){q("i",arguments)},fetchBids:function(){q("f",arguments)},setDisplayBids:function(){},targetingKeys:function(){return[]},_Q:[]};A=p.createElement(s);A.async=!0;A.src=t;g=p.getElementsByTagName(s)[0];g.parentNode.insertBefore(A,g)}("apstag",window,document,"script","//c.amazon-adsystem.com/aax2/apstag.js");
apstag.init({
pubID: 'pub_id_amazon_uam',
adServer: 'googletag',
simplerGPT: true
});
var googletag = googletag || {};
@rkjha
rkjha / ad_unit_code.html
Created July 26, 2019 11:22
that dfpad unit for Amazon UAM. Nothing special for UAM - just your plain old dfp unit.
<!-- /dfp_account_id/ad_unit_1 -->
<div id='div-gpt-ad-xxxxxxxxxx-0'>
<script>
googletag.cmd.push(function() { googletag.display('div-gpt-ad-xxxxxxxxxx-0'); });
</script>
</div>
@rkjha
rkjha / my_blog.rb
Last active June 8, 2020 10:31
Simple use of Dalli gem to implement caching using memcached in a Sinatra Application.
require 'rubygems'
require 'sinatra/base'
require 'sinatra/content_for'
require 'dalli'
class MyBlog < Sinatra::Base
helpers Sinatra::ContentFor
set :dc, Dalli::Client.new('localhost:11211')
get '/articles/:id' do