Skip to content

Instantly share code, notes, and snippets.

View excid3's full-sized avatar
:shipit:
Shipping

Chris Oliver excid3

:shipit:
Shipping
View GitHub Profile
@excid3
excid3 / letsencrypt_2016.md
Created February 28, 2017 23:56 — forked from cecilemuller/letsencrypt_2020.md
How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

There are two modes when you don't want Certbot to edit your configuration:

  • Standalone: replaces the webserver to respond to ACME challenges
  • Webroot: needs your webserver to serve challenges from a known folder.

Webroot is better because it doesn't need to replace Nginx (to bind to port 80) to renew certificates.

In the following, we're setting up mydomain.com to be served from /var/www/mydomain, and challenges will be served from /var/www/letsencrypt.

What's up guys? In this episode we're going to talk about devise masquerading and how to add this gem so that you can login as other users to make doing suppport and finding and reproducing books a little bit easier.

This is really useful in development but it can also be really useful in production if you have the need to do some support and maybe login into someone's account and try to do something and reproduce the bug or maybe just you know help them with their account so we're going to talk about the devise masquerade gem and then I'd like to do a follow-up where we talked about how this is actually implemented behind the scenes because it's actually rather interesting and not as complicated as you might think.

So this gem is a extension for devise so you're gonna have to have devise installed in order to use it. It basically just hooked in and you have a few message that you can use so you have devised master able and in your application controller you put in before filter mastery user and uh then y

@excid3
excid3 / 024-liking-posts.md
Created October 29, 2016 00:27
GoRails Transcript 024 - Liking Posts

Liking Posts

A common feature of applications these days is the ability to like or favorite a post on websites.

Today we're going to talk about implementing that and submitting it via an AJAX request.

We're starting with a simple application that has posts and users. Anyone is able to create a blog post and click on them and view. But we want to add the ability for a user to click a link and Like the post.

The first step we need to take is to create a model to represent the association between the user and the post they liked.

Realtime Notifications with ActionCable

In this episode we're going to be adding realtime notifications into your app using ActionCable. We've talked about notifications a few times in the past and we used AJAX polling for that. 95% of the time, polling is the solution that would be recommended for it.

But if you're looking for a good introduction into ActionCable then this is a decent one because we're only really using it for one way from the server side to the client side.

Getting started

So to get started we're starting with an app that has Bootstrap installed and then we created a Main controller with an index view which is where we will list our Notifications as for this example.

Before we generate our channels let's install a few things

require 'open-uri'
require 'nokogiri'
page = open('http://www.ncbi.nlm.nih.gov/pubmed/?term=asdf')
doc = Nokogiri::HTML(page)
# Get all the links on the page inside the results
links = doc.css(".rprt .title a")
#=> [
#<Nokogiri::XML::Element:0x3fc61e11898c name="a" attributes=[#<Nokogiri::XML::Attr:0x3fc61e118900 name="href" value="/pubmed/26754126">,
class PostsController < ApplicationController
before_action :set_posts, only: [:index]
before_action :set_new_post, only: [:new, :create]
before_action :set_post, only: [:show, :edit, :update, :destroy]
def new; end
def show; end
def edit; end
def index; end
handleSuccess: (data) =>
if data.length > 0
items = $.map data, (notification) ->
"<a class='dropdown-item' href='#{notification.url}'>#{notification.actor} #{notification.action} #{notification.notifiable.type}</a>"
$("[data-behavior='unread-count']").text(items.length)
$("[data-behavior='notification-items']").html(items)
else
$("[data-behavior='unread-count']").text(items.length)
<div class="hero-section parallax-bg dark-layer" data-background="<%= image_url("background2.jpg") %>">
# winners.each { |stop, list|
# CSV.open("#{Rails.root}/lib/assets/group_#{stop}.csv", "wb") do |csv|
# list.each { |user|
# csv << [user.email, user.referrals.count]
# }
# end
# }
# change the above to something like this
workers Integer(ENV['PUMA_WORKERS'] || 3)
threads Integer(ENV['MIN_THREADS'] || 1), Integer(ENV['MAX_THREADS'] || 16)
preload_app!
rackup DefaultRackup
port ENV['PORT'] || 3000
environment ENV['RACK_ENV'] || 'development'
on_worker_boot do