Skip to content

Instantly share code, notes, and snippets.

View tygerbytes's full-sized avatar
🦖

Ty Walls tygerbytes

🦖
View GitHub Profile
Rails.application.routes.draw do
namespace :static_pages, path: '/' do
get 'about'
get 'health_check'
end
get 'target_pace/calc'
root 'target_pace#index'
import Vue from 'vue';
import Router from 'vue-router';
import RunbyPace from '@/components/RunbyPace.vue';
import TargetPace from '@/components/TargetPace.vue';
import About from '@/components/About.vue';
Vue.use(Router);
export default new Router({
// src/main.js
import router from './router';
...
new Vue({
render: h => h(App),
router,
store,
}).$mount('#app');
<template>
<div id="app" class="container">
...
<router-view>
...
</div>
</template>
...
import Vuex from 'vuex';
...
// The library I want to share amongst the components
import RunbyLib from './runbylib';
...
Vue.use(Vuex);
const store = new Vuex.Store({
state: {
RunbyLib,
new Vue({
render: h => h(App),
router,
// Provide the store using the "store" option.
// this will inject the store instance to all child components.
store,
}).$mount('#app');
export default {
name: 'RunbyPace',
beforeCreate() {
this.lib = this.$store.state.RunbyLib;
},
...
computed: {
// Do this
missingRaceTime() {
return this.submitted && this.fiveKmRaceTime === '';
},
...
@tygerbytes
tygerbytes / body.html
Last active July 14, 2019 16:55
Netlify admin entrypoint
<!-- Add this before </body> -->
<script>
if (window.netlifyIdentity) {
window.netlifyIdentity.on("init", user => {
if (!user) {
window.netlifyIdentity.on("login", () => {
document.location.href = "/admin/";
});
}
});
@tygerbytes
tygerbytes / SendSms.cs
Created September 11, 2019 16:32
Azure Function snippet for sending text messages with Twilio
[FunctionName("SendSms")]
public static async Task<IActionResult> Run(
// This is an HTTP trigger accepting POST requests. That's why we are able to invoke it using Postman.
[HttpTrigger(AuthorizationLevel.Function, "post", Route = "tygerbytes/sygnal")] HttpRequest req,
ILogger log,
ExecutionContext context)
{
// The FuncConfig class encapsulates environment-specific settings like those
// TWILIO... environment variables.
var funcConfig = new FuncConfig(context);