Skip to content

Instantly share code, notes, and snippets.

View davidpaulhunt's full-sized avatar
🏖️
#RemoteLife

David Hunt davidpaulhunt

🏖️
#RemoteLife
View GitHub Profile

Declaration

// old
const helloWorld = React.createClass({
  render() {},
});

// new
class HelloWorld extends React.Component {
  render() {}
@davidpaulhunt
davidpaulhunt / queues.md
Last active January 8, 2016 16:11
A quick intro on queues.

What is a queue?

Anytime you go out for a meal and the hostess informs you that there is a wait and you agree to be added to a waitlist, you are being put into a queue. A queue is at it's core nothing more than a line. In fact, in the UK they call waiting in line queueing.

Our queue when you arrive -

[
  {"name": "Bob"},
  {"name": "Karen"}
]
'use strict';
module.exports = function isUndefined(obj) {
return typeof obj === 'undefined';
}

Setting up the base application

1. Install rails

$ gem install rails -v 5.0.0.beta1 --no-ri --no-rdoc

2. Create a new application

$ rails _5.0.0.beta1_ new blog --skip-spring

Rails 5 and ActionCable

Assumptions: The application already exists. You have two models article.rb and comment.rb. Articles have two attributes, title and text. Comments have two attributes, text and article_id. See these instructions if you need help getting started.

Routes

Assuming that you are nesting your :comments resources inside of :articles, mount ActionCable and make sure you have a root.

config/routes.rb

Rails.application.routes.draw do
// Testing API routes
module.exports = vows.describe('Feature > SubFeature').addBatch(setupBatch).addBatch({
'GET /some/specific/url?q=something by User One > Testing SubFeature.0': {
topic: function(){
request.get({
headers: {
authorization: someHelperMethod('userone')
}
# wines_controller.rb
def import
file = params[:file]
user = current_user.id
UploadCsvJob.new.async.perform(file, user)
redirect_to root_path, notice: "Your wines are being imported! Check your wine list for updates."
end
# wine.rb
class VideosController < ApplicationController
include Rails.application.routes.url_helpers
def show
@video = Video.find(params[:id])
@original_video = @video.panda_video
@h264e = @original_video.encodings['h264']
end
require 'rails_helper'
RSpec.describe Recipe, :type => :model do
context 'validations' do
it 'should validate name' do
recipe = FactoryGirl.build_stubbed(:recipe)
expect(recipe).to be_valid
class AuthController < ApplicationController
def facebook
@user = User.find_or_create_from_auth_hash(auth_hash)
self.current_user = @user
end
def facebook_callback
current_user.set_facebook_token(auth_hash.credentials.token)
redirect_to wishlists_path, notice: "Facebook hooked up!"