Skip to content

Instantly share code, notes, and snippets.

View bryansray's full-sized avatar

Bryan Ray bryansray

View GitHub Profile
{ "event": "unread_email", "type": "gauge", "value": "6", "ts": "2019-11-21T04:56:41Z" }{ "event": "chrome_tabs", "type": "gauge", "value": "22", "ts": "2019-11-21T04:56:41Z" }{ "event": "cpu_temp", "type": "gauge", "value": "137.3°F", "ts": "2019-11-21T04:56:41Z" }{ "event": "battery_remaining", "type": "gauge", "value": "Unlimited", "ts": "2019-11-21T04:56:41Z" }{ "event": "unread_email", "type": "gauge", "value": "6", "ts": "2019-11-21T04:57:16Z" }{ "event": "chrome_tabs", "type": "gauge", "value": "22", "ts": "2019-11-21T04:57:16Z" }{ "event": "cpu_temp", "type": "gauge", "value": "130.33°F", "ts": "2019-11-21T04:57:16Z" }{ "event": "battery_remaining", "type": "gauge", "value": "Unlimited", "ts": "2019-11-21T04:57:16Z" }{ "event": "unread_email", "type": "gauge", "value": "6", "ts": "2019-11-21T04:57:51Z" }{ "event": "chrome_tabs", "type": "gauge", "value": "22", "ts": "2019-11-21T04:57:51Z" }{ "event": "cpu_temp", "type": "gauge", "value": "134.94°F", "ts": "2019-11-21T04:57:51Z" }{ "event": "battery_re
@bryansray
bryansray / menu.js
Created October 8, 2019 23:55
Vuetify Menu with List
<v-menu v-if="isAuthenticated" class="d-block" bottom offset-y nudge-right="10">
<template v-slot:activator="{ on }">
<v-list class="pa-0">
<v-list-item @click.stop="on">
<v-list-item-avatar>
<img :src="jwtPicture" :title="jwtName">
</v-list-item-avatar>
<v-list-item-content>
<v-list-item-title>{{ jwtName }}</v-list-item-title>
</v-list-item-content>
<script lang="ts">
import Vue from "vue";
import { mapActions } from "vuex";
import router from "@/router";
export default Vue.extend({
name: 'callback',
data (): any {
this.handleAuthentication();
router.replace('/');
@bryansray
bryansray / codewars-javascript-magic-function.js
Created September 15, 2017 03:48
Javascript Magic Function
function isNumeric(n) {
return !isNaN(parseFloat(n)) && isFinite(n);
}
function MagicFunction(...numbers) {
let cache = numbers;
function magicFunction(...numbers) {
cache = cache.concat(numbers);
@bryansray
bryansray / mapper.ex
Created September 24, 2016 19:03
Mapping map keys from one to the other ...
defmodule Mapper do
def map(from, mapping) do
find_keys = Map.keys(mapping)
result = Map.new(find_keys, fn(key) ->
new_key = Map.get(mapping, key) || key
{ new_key, Map.get(from, key) }
end)
# Questions:
# 1. How can I specify that path for the cached item by something other than the URL?
# 2. I'd like to use pieces in the Response to generate the cache location, but then, how do I check if the cached file exists before making the API call?
defmodule Base
use HTTPoison.Base
# ... Basic HTTPoison Implementation ...
end
@bryansray
bryansray / episode_controller.ex
Last active September 9, 2016 20:28
Refactoring Episode Controller
def new(conn, %{"podcast_slug" => slug}, current_user) do
with podcast <- find_podcast_for_user(slug, current_user.id),
changeset <- build_episode(podcast) do
render(conn, :new, changeset: changeset, podcast: podcast)
else
_ -> redirect(conn, to: page_path(conn, :index))
end
end
class BaseSort
def less(v : Comparable, w : Comparable) : Bool
return v < w
end
def exchange(a : Array(Comparable), i : Int, j : Int)
t = a[i]
a[i] = a[j]
a[j] = t
end
# you prefer this ...
def this_function() do
IO.puts "Hello, World"
end
# over this ...
def this_function do
IO.puts "Better, World!"
config :rumbl, Rumbl.Endpoint,
http: [port: 4000],
debug_errors: true,
code_reloader: true,
cache_static_lookup: false,
check_origin: false,
watchers: [
{ :node, ["node_modules/.bin/watchify", "web/static/js/app.js", "-o", "priv/static/js/app.js", "--debug"] },
{ :node, ["node_modules/.bin/sheetify", "web/static/css/index.css", ">", "priv/static/css/app.css"] }
]