Skip to content

Instantly share code, notes, and snippets.

@davidimoore
davidimoore / gamedata.json
Created December 3, 2018 21:06
gamedata.json
This file has been truncated, but you can view the full file.
{
"id": "5748e073-d838-4100-bce5-8d41df5a38a2",
"status": "closed",
"reference": "57752",
"number": 186,
"scheduled": "2018-12-03T01:20:00+00:00",
"attendance": 61069,
"utc_offset": -5,
"entry_mode": "INGEST",
"weather": "Clear Temp: 57 F, Humidity: 55%, Wind: From S 8 mph",
@davidimoore
davidimoore / package.json
Last active May 11, 2018 00:11
jest-webpacker-setup
{
"scripts": {
"test": "NODE_PATH='./app/javascript/node_modules:./app/javascript' jest",
"test:watch": "yarn test --watch",
"test:coverage": "test --coverage"
},
"jest": {
"roots": [
"./app/javascript"
],
@davidimoore
davidimoore / index.html
Created December 1, 2017 18:39
video promises
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<video controls class="handsome"></video>
<body>
<script>
const video = document.querySelector('.handsome');
class Benchwarmer
attr_reader :results
class << self
def run(options = {gc: :enable})
if options[:gc] == :disable
GC.disable
elsif options[:gc] == :enable
# collect memory allocated during library loading
# and our own code before the measurement
require 'lhm'
class AddDateTimeColumnsToNpsSurveys < ActiveRecord::Migration
def up
Lhm.change_table :nps_surveys do |m|
m.add_column :survey_created_at, 'DATETIME AFTER `survey_created_at_epoch`'
m.add_column :survey_updated_at, 'DATETIME AFTER `survey_created_at_epoch`'
end
end
def down
require 'rails_helper'
describe 'ruby 2.2.0' do
context "Enumerable methods" do
# slice_before, slice_after and slice_when return Enumerable
describe "#slice_before" do
it "slices before a matched singular value" do
a = ["a", "b", "c"]
require 'rails_helper'
describe 'ruby 2.3.0' do
context "Integer methods" do
describe "positive?" do
it "checks if an array value is greater than zero" do
some_array = [2,3,4]
expect(some_array.first.positive?).to eq true
describe "counter caches" do
it "increments associations when created" do
user = User.create(first_name: "David", last_name: "Moore", email:"[email protected]")
#creating a thread with the user
user.forum_threads.create(name:"First thread")
expect(user.forum_threads_count).to eq 1
#create a thread with its own class and associating it to the user
#!/usr/bin/env python
# Eulerian Tour Ver 1
#
# Write a function, `create_tour` that takes as
# input a list of nodes
# and outputs a list of tuples representing
# edges between nodes that have an Eulerian tour.
#
# == Schema Information
#
# Table name: users
#
# id :integer not null, primary key
# email :string(255) default(""), not null
# encrypted_password :string(255) default(""), not null
# reset_password_token :string(255)
# reset_password_sent_at :datetime
# remember_created_at :datetime