Skip to content

Instantly share code, notes, and snippets.

// Place your key bindings in this file to override the defaults
[
{
"key": "shift+h",
"command": "workbench.action.focusLeftGroup",
"when": "editorTextFocus && vim.active && vim.mode != 'Insert'"
},
{
"key": "shift+l",
"command": "workbench.action.focusRightGroup",
@mattroyer
mattroyer / App.vue
Last active February 9, 2023 16:45
Getting started with Vue
<template>
<div>
<p>This is the start of the App component.</p>
<Images />
</div>
</template>
<script>
import Images from './components/Images.vue'
{
"basics": {
"name": "Matt Royer",
"label": "Software Engineer",
"email": "matthew.royer@gmail.com",
"summary": "My favorite projects to work on are where I can automate a manual process. I have been lucky enough to work on a number of these over the years, including a system that automatically captioned video evidence of Selenium test scenarios, and scrapers that pull and transform data from various websites and APIs. Code is all about the adventure to me.",
"location": {
"city": "Lehi",
"countryCode": "US",
"region": "Utah"
PS1="\n\[\033[35m\]\$(/bin/date)\n\[\033[32m\]\w\n\[\033[1;31m\]\u@\h: \[\033[1;36m\]\$(/bin/ls -1 | /usr/bin/wc -l | /bin/sed 's: ::g') files \[\033[1;33m\]\$(/bin/ls -lah | /bin/grep -m 1 total | /bin/sed 's/total //')b\[\033[0m\]: \[\033[0m\]"
@mattroyer
mattroyer / dropp.rb
Last active July 30, 2018 20:12
Drop(p) named URLs or paths into a JSON file so you can easily retrieve them later
require 'json'
action, name, path = ARGV
filename = ".dropp"
$config = File.exist?("#{ENV['USERPROFILE']}/#{filename}") ? JSON.parse(File.read("#{ENV['USERPROFILE']}/#{filename}")) : {}
def truncate(string, max=65)
string.length > max ? "#{string[0...max]}..." : string
@mattroyer
mattroyer / gist:b7b87f20b14712e08d9a0498694be1b3
Created February 6, 2018 20:16 — forked from dvliman/gist:10402435
ruby $ global variable
$: (Dollar Colon) is basically a shorthand version of $LOAD_PATH. $: contains an array of paths that your script will search through when using require.
$0 (Dollar Zero) contains the name of the ruby program being run. This is typically the script name.
$* (Dollar Splat) is basically shorthand for ARGV. $* contains the command line arguments that were passed to the script.
$? (Dollar Question Mark) returns the exit status of the last child process to finish.
$$ (Dollar Dollar) returns the process number of the program currently being ran.
$~ (Dollar Tilde) contains the MatchData from the previous successful pattern match.
$1, $2, $3, $4 etc represent the content of the previous successful pattern match.
$& (Dollar Ampersand) contains the matched string from the previous successful pattern match.
$+ (Dollar Plus) contains the last match from the previous successful pattern match.
$` (Dollar Backtick) contains the string before the actual matched string of the previous successful pattern match.
def start_of_next_week(date)
date + (7 - date.wday)
end
def date_of_next(day)
date = Date.parse(day)
delta = date > Date.today ? 0 : 7
date + delta
end
var times = $(".lecture__item").not('.completed').find('.lecture__item__link__time').map(function() { return $(this).text() });
var reduced_time = times.map(function() { return this.split(":").map(function(str) { return parseInt(str) }).reduce(function(a, b) { return a * 60 + b}) });
var seconds = Array.from(reduced_time).reduce(function(a, b) { return a + b }, 0);
Number.prototype.toHHMMSS = function () {
var sec_num = parseInt(this, 10); // don't forget the second param
var hours = Math.floor(sec_num / 3600);
var minutes = Math.floor((sec_num - (hours * 3600)) / 60);
var seconds = sec_num - (hours * 3600) - (minutes * 60);
@mattroyer
mattroyer / zip_lists.py
Last active May 10, 2016 21:43
Zip Lists Together
families = [["Jenny", "Dana", "Tana", "Shawn", "Mark"], ["Kevin", "Jamison", "Brian", "Alice"], ["Chris", "John", "April"], ["Kevin", "Jim", "Bobby", "Ryan"]]
surnames = ['Richards', 'Millhouse', 'Carmichael', 'Williams']
for index, name in enumerate(surnames):
families[index] = list(map(lambda x: "%s %s" % (x, name), families[index]))
for family in families:
print(family)
#=> ['Jenny Richards', 'Dana Richards', 'Tana Richards', 'Shawn Richards', 'Mark Richards']
@mattroyer
mattroyer / github_api.py
Created May 10, 2016 21:36
Get JSON API in usable form
import urllib
import json
github = urllib.urlopen('https://api.github.com/repos/google/acai')
body = github.read()
github.close()
json_data = json.loads(body)
print json_data