Skip to content

Instantly share code, notes, and snippets.

Avatar

Kevin R. Barnes vinbarnes

View GitHub Profile
@vinbarnes
vinbarnes / setup.sh
Created March 30, 2022 14:15 — forked from bradp/setup.sh
New Mac Setup Script
View setup.sh
echo "Creating an SSH key for you..."
ssh-keygen -t rsa
echo "Please add this public key to Github \n"
echo "https://github.com/account/ssh \n"
read -p "Press [Enter] key after this..."
echo "Installing xcode-stuff"
xcode-select --install
View my_project.el
;; helper functions
(defun kb/project-dir ()
"returns the current project's root path"
(let* ((pr (project-current t))
(pr-dir (project-root pr)))
pr-dir))
(defun kb/project-concat (path)
"appends provided path onto the current project's root path"
View destroy.rb
# https://guides.rubyonrails.org/active_record_callbacks.html#halting-execution
class Org < ApplicationRecord
before_destroy do
throw :abort unless no_user?
end
end
@vinbarnes
vinbarnes / solar_system_objects.sql
Created May 30, 2021 01:31 — forked from pamelafox/solar_system_objects.sql
solar_system_objects.sql
View solar_system_objects.sql
/*
Solar system objects
Adapted from: http://en.wikipedia.org/wiki/List_of_Solar_System_objects_by_size
Collected by: https://www.khanacademy.org/profile/patrick809/programs
*/
CREATE TABLE solar_system_objects(
body TEXT
, mean_radius NUMERIC /* km */
, mean_radius_rel NUMERIC /* relative to earth */
, volume NUMERIC /* 10^9 km^3 */
View furniture_store_sales.sql
/*
Sales from an online furniture store
Collected by: https://www.khanacademy.org/profile/charlesb2000/
*/
CREATE TABLE sales(
ID INTEGER NOT NULL PRIMARY KEY
, transaction_date TEXT
, product TEXT
, price INTEGER
, payment_type TEXT
View counts.rb
def counts(str)
str.chars.inject([]) do |memo, e|
if memo.last && memo.last[0].eql?(e)
memo.last[1] += 1
else
memo << [e, 1]
end
memo
end
View inherit_test_setup.rb
class Test
def run
puts ">>> starting test run: #{self.class.name}"
setup
the_test_methods.each do |test_method|
puts "running #{self.class.name}##{test_method}"
send(test_method)
end
end
View Instatest.md

Test Title

heading

PARAGRAPH starts here.

Then continues on for a bit.

@vinbarnes
vinbarnes / repl.js
Created April 4, 2019 01:47 — forked from blackwright/repl.js
Sequelize REPL
View repl.js
// Require the REPL module
// and models
let repl = require('repl').start({});
const models = require('./models');
// Make the `models` object
// a global variable in the
// REPL
repl.context.models = models;
@vinbarnes
vinbarnes / optparse-template.rb
Created February 13, 2019 12:22 — forked from rtomayko/optparse-template.rb
Ruby optparse template
View optparse-template.rb
#!/usr/bin/env ruby
#/ Usage: <progname> [options]...
#/ How does this script make my life easier?
# ** Tip: use #/ lines to define the --help usage message.
$stderr.sync = true
require 'optparse'
# default options
flag = false
option = "default value"