Skip to content

Instantly share code, notes, and snippets.

View stevensona's full-sized avatar

Adam Stevenson stevensona

View GitHub Profile
@stevensona
stevensona / TicTacToe.jsx
Last active July 19, 2019 20:09
React TicTacToe Functional Component
// Working demo: https://jsfiddle.net/1r5f2cey/1/
/* CSS
#board {
display: grid;
grid: repeat(3, 1fr) / repeat(3, 1fr);
grid-gap: 5px;
}
.space {
@stevensona
stevensona / [email protected]
Last active June 17, 2021 12:26
systemd unit file for running ruby/rails delayed_job as service
# Keep delayed job workers running using systemd on ubuntu
# Usage
# Start "sudo systemctl start delayed_job@{0..3}" to start 4 worker instances
# Enable "sudo systemctl enable delayed_job@{0..3}" to enable 4 worker instances
# Restart "sudo systemctl restart delayed_job@{0..3}" to restart 4 worker instances
# Disable "sudo systemctl disable delayed_job@{0..3}" to disable 4 worker instances
# Stop "sudo systemctl stop delayed_job@{0..3}" to stop 4 worker instances
[Unit]
Description=Delayed Job Worker %i
@stevensona
stevensona / Gemfile
Last active May 6, 2017 22:07
Gemfile for new Rails app
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
gem 'rails', '~> 5.1.0'
gem 'pg', '~> 0.18'
gem 'puma', '~> 3.7'
{
"editor.tabSize": 2,
"editor.insertSpaces": true,
"editor.fontFamily": "Hack, Consolas",
"editor.fontSize": 11,
"editor.renderIndentGuides": true,
"editor.renderWhitespace": "all",
"editor.minimap.enabled": true,
"editor.minimap.renderCharacters": false,
"editor.dragAndDrop": true,
@stevensona
stevensona / tasks.json
Created January 6, 2017 23:26
Run RSpec tests in Vagrant from Visual Studio Code Host
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "cmd",
"isShellCommand": true,
"tasks": [
{
"isBuildCommand": true,
"taskName": "run tests",
@stevensona
stevensona / cron
Created September 17, 2016 16:20
execute ruby script with cron job (rbenv)
SHELL=/bin/bash
0 * * * * /bin/bash -c 'export PATH="$HOME/.rbenv/bin:$PATH" ; eval "$(rbenv init -)"; cd $HOME; ./script.sh >> $HOME/jobs.log 2>&1'
@stevensona
stevensona / install_ruby.sh
Last active September 23, 2018 01:08
Bash script to install Install ruby 2.3.1 on ubuntu 16
#!/bin/bash
sudo apt-get update
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev
cd
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
@stevensona
stevensona / duplicates.cpp
Created May 10, 2016 22:11
remove duplicates from sorted linked list
Node* removeDuplicates(Node *head) {
if(head == nullptr) return head;
while(head->next != nullptr && head->data == head->next->data) {
auto dup = head->next;
head->next = dup->next;
delete dup;
}
removeDuplicates(head->next);
return head;
}
@stevensona
stevensona / benchmark.cpp
Last active May 10, 2016 19:21
c++ timing helper
#include <chrono>
#include <functional>
template<class T>
long long benchmark(std::function<void()> op) {
auto start = std::chrono::steady_clock::now();
op();
return std::chrono::duration_cast<T>(std::chrono::steady_clock::now() - start).count();
}
<!DOCTYPE html><html><head></head><body></body></html>