Skip to content

Instantly share code, notes, and snippets.

View coolsoftwaretyler's full-sized avatar

Tyler Scott Williams coolsoftwaretyler

View GitHub Profile
@coolsoftwaretyler
coolsoftwaretyler / READ.ME
Created April 13, 2018 20:21
Tyler Williams NationBuilder API Certification
Tyler Williams NationBuilder Developer Certification
Submitted 4/13/18
This python program completes the following developer exercises:
Create an event
Edit an event
Create a person
Edit a person
Delete a person
@coolsoftwaretyler
coolsoftwaretyler / functions.php
Created July 11, 2018 19:26
Income Log Reporting
<?php
// NationBuilder functions
// It may eventually make sense to make these methods in OOP model
// Could turn into a NationBuilder PHP library or package
// Make a GET request using curl
// Takes one argument, $endpoint, which is the URL to hit with GET
// Expects a response in JSON format, decodes to array, returns the decoded JSON array
function nationbuilderGet($endpoint) {
// Make the curl request
@coolsoftwaretyler
coolsoftwaretyler / 01_ror_tutorial_exercise_answers.md
Created August 10, 2018 22:54
Ruby on Rails Tutorial Exercise Answers

Ruby on Rails Tutorial Exercise Answers

Chapter 1

Section 1.1.1

  1. https://rubygems.org hosts the Ruby gem for Ruby on Rails.
  2. The current stable version number of Rails is 5.1.4, with 5.2.0.beta2 being the overall latest version.
  3. As of this writing, Ruby on Rails has been downloaded 118,011,892 across all versions.
@coolsoftwaretyler
coolsoftwaretyler / flatten.rb
Last active May 28, 2019 17:25
An array flatten method written in Ruby for Theorem LLC interview. Uses RSpec for unit tests. Created by Tyler Williams. tyler@ogdenstudios.xyz
# Use RSpec for testing https://rspec.info/
require 'rspec'
# Define the flatten function, we'll use it recursively
# On the initial run, set `results` to an empty array
def flatten(array, results = [])
# Check that array is not nil
if array
# For each item in the array, check if it's a nested array
array.each do |item|
doSomeLongRunningTask(function(response, error) {
// This function is running as a CALLBACK inside the long task
// So it logs on completion
console.log(response)
// Return the response
return response;
}
var res = doSomeLongRunningTask(function(response, error) {
@coolsoftwaretyler
coolsoftwaretyler / sample_object.rb
Last active February 7, 2020 03:50
Rails Fragment Caching and Low Level Caching
class SampleObject < ApplicationRecord
def external_components
Rails.cache.fetch("#{cache_key_with_version}/components", expires_in: 12.hours) do
# Some long running task that fetches "components"
end
end
end
@coolsoftwaretyler
coolsoftwaretyler / prereqs.md
Last active April 15, 2020 19:59
Make a Website Super Fast Crash Course
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<link rel="stylesheet" type="text/css" href="css/app.css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width">
<title></title>
@coolsoftwaretyler
coolsoftwaretyler / bench-mobx.ts
Created September 26, 2023 17:22 — forked from thegedge/bench-mobx.ts
MobX benchmark
import { makeAutoObservable, makeObservable, observable } from "mobx";
import { DataModel, Model, model, prop } from "mobx-keystone";
import { types } from "mobx-state-tree";
function bench(f: () => { value: number }) {
// Warmup
let sum = 0;
for (let index = 0; index < 100_000; ++index) {
sum += f().value;
}
@coolsoftwaretyler
coolsoftwaretyler / ask
Last active October 22, 2023 01:32
I use this code to interface with my OpenAI account and "ask" from my command line. It will take input directly, or you can point it to a markdown file and get a response. Usage instructions in the code comments, or feel free to leave a comment on the gist if you need any help.
#!/usr/bin/env node
/**
* If you put this program in your PATH, you can use it like this:
*
* ask "What is the meaning of life?"
*
* or
*
* ask my_file.md