Skip to content

Instantly share code, notes, and snippets.

forEachIterativeStack(callback) {
const stack = [];
let i = 0;
let node = this._root;
while (node || stack.length > 0) {
// slide to the left (all the way)
while (node) {
stack.push(node);
node = node.left;
}
@droberts-sea
droberts-sea / Twitter-gem.md
Last active July 13, 2019 03:52 — forked from mbd-s/Twitter-gem.md
Building a simple Twitter bot with the Twitter Ruby gem

Twitter gem overview

Adapted (formatting changes) from https://gist.github.com/mbd-s/2352b1454790852a6946dcb3842ec3d5

The Twitter Ruby gem is a Ruby interface to the Twitter API. It allows you to make all available Twitter API requests (e.g., tweet, follow a user, search, etc.) within a Rails app.

This guide was adapted from multiple sources, including the Twitter Ruby gem configuration page and How to Make a Twitter Bot in Ruby on Rails. Twitter's own API docs are a good resource too, of course.


Get set up with Twitter

#orange {
background-color: orange;
}
.one .two .three .four .five .six .seven .eight .nine .ten .eleven h1 {
background-color: teal;
}
# An Instructor represents a single instructor
class Instructor
attr_reader :donut_count
def initialize
@donut_count = 0
end
def eat_donut
@donut_count += 1
end
# Behavior:
# Can send a message
# Can open the first message
#
# module Messageable
# def setup
# @messages = []
# end
#
# def send(msg)
class Song
attr_reader :title, :artist, :filename, :play_count
# Initialize our total play count
# This will be set to 0 when the program is loaded
@@total_plays = 0
def initialize(title, artist, filename)
@title = title
@artist = artist
require 'httparty'
TOKEN = "xoxp-105525597987-111410440576-176854780516-7dcef01f9a30d7b808a9ebce3248439d"
BASE_URL = "https://slack.com/api/"
class SlackException < StandardError
end
class SlackChannel
attr_reader :name, :raw_data
@droberts-sea
droberts-sea / .rails-template.rb
Last active December 18, 2023 22:33
Save this file as "~/.rails-template.rb", then add the line "-m ~/.rails-template.rb" to your .railsrc
# Make $(document).ready work as expected, despite turbolinks weirdness
gem 'jquery-turbolinks'
gem_group :development, :test do
# Use pry for rails console, enable binding.pry
gem 'pry-rails'
end
gem_group :development do
# Improve the error message you get in the browser
@droberts-sea
droberts-sea / app.js
Last active November 29, 2016 22:56
Adding a Collection to TaskListView
import $ from 'jquery';
import TaskList from 'app/collections/task_list';
import TaskListView from 'app/views/task_list_view';
var taskData = [
{
title: 'Mow the lawn',
description: 'Must be finished before BBQ on Sat afternoon'
}, {
@droberts-sea
droberts-sea / index.html
Last active November 29, 2016 04:29
Ada C6 Backbone Models Check-in 2
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/foundation/6.2.4/foundation.min.css">
<link rel="stylesheet" href="styles/index.css">
</head>
<body>
<main id="application" class="row">
<section class="small-12 columns">