Skip to content

Instantly share code, notes, and snippets.

View kenmazaika's full-sized avatar

ken mazaika kenmazaika

View GitHub Profile
class Instructor::LessonsController < ApplicationController
before_action :authenticate_user!
before_action :require_authorized_for_current_section, only: [:new, :create]
before_action :require_authorized_for_current_lesson, only: [:update]
def new
@lesson = Lesson.new
end
def create
<!-- Load Bootstrap from a CDN -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<!-- Put inside a bootstrap div -->
<div class="col-xs-10 col-xs-offset-1">
<h1>Hello</h1>
<img src="http://imgur.com/Q5GpJMB.png" class="face big img-center center-block img-responsive"/>
</div>
@kenmazaika
kenmazaika / README.md
Last active September 14, 2017 04:13

Setting up the ES6 Sandbox

The configuration of tools like babel are one of the things that throws off beginners when learning to use the technology. We've setup our vagrant environment to give the folder /vagrant/src/es6-sandbox everything it needs to start working with the ES6 programming language (without worrying about getting the perfect babel configuration).

There are a few things we needed to do to supercharge babel to work in this environment. Here are a few concepts that exist in babel and how we configured our ES6 Sandbox to work.

Setting Up Babel

We used NPM to install babel in the environment by executing the command:

Running Two Vagrant Environments in Parallel.

Two different vagrant environments can be run on the same machine. Here's how.

First, make sure you're initial vagrant environment is powered down. Move to the directory the environment is listed by running this command:

cd Desktop/vagrant

To run:

babel-node --presets es2015 runner.js

Output:

12 is 10 away from 22

a = []
a.push(1) # enqueue the number 1 in the queue
a.push(2) # enqueue the number 2 in the queue
a.push(3) # enqueue the number 3 in the queue
# dequeue the first element, 1 has been in the queue longest
puts a.shift # => displays 1
a.push(4) # enqueue the number 4 in the queue
def binary_search(target, list)
position = (list.count / 2).floor
mid = list[position]
return mid if mid == target
if(mid < target)
return binary_search(target, list.slice(position + 1, list.count/2))
else
return binary_search(target, list.slice(0, list.count/2))
def binary_search(target, list)
# find the middle position number
position = (list.count / 2).floor
# look up the item in the middle position
mid = list[position]
# if we've found it, we're done
return mid if mid == target
class LinkedListNode
attr_accessor :value, :next_node
def initialize(value, next_node=nil)
@value = value
@next_node = next_node
end
# node3.print_value
def print_values
# generate all of the touples such that
# the first value and the second value summed
# is less than or equal to the value presented
def touples(n)
touple_values = []
n.times do |x|
n.times do |y|
touple_values.push([x, y])
end