This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs') | |
const pug = require('pug') | |
const glob = require('glob') | |
const templateRegex = new RegExp('<template lang="pug">(.*)</template>', 's') | |
const attributeRegex = new RegExp(/(\S*)="/, 'g') | |
function compilePug(pugCode) { | |
let cleanedPug = pugCode.split('\n').filter(line => line.trim().length > 0) | |
const initialTab = cleanedPug[0].match(/^\s*/)[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function loadStuff() { | |
state.loading = true | |
fetch('//myapi.com/stuff') | |
.then(res => res.json()) | |
.then(data => { | |
state.loading = false | |
state.stuff = data | |
}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tuxi from 'tuxi' | |
import Vuex from 'vuex' | |
import Vue from 'vue' | |
import api from './api' | |
Vue.use(Vuex) | |
const store = new Vuex.Store({ | |
strict: true, // tuxi works in strict mode! | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div class="wrapper"> | |
<div class="empty-message" v-if="articlesTask.empty"> | |
No articles | |
</div> | |
<div class="spinner" v-if="articlesTask.spinning"> | |
Loading articles... | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tuxi from 'tuxi' | |
import api from './api' | |
const articlesTask = tuxi.task(api.fetchArticles) | |
// ⚡ Fire the api call | |
articlesTask.start() | |
// The task is immediately set to pending | |
console.log(articlesTask.pending) // true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Create a Vuex store module to represent states for an asynchronous API getter. | |
* | |
* Includes defaultState, actions, and mutations for a standard value gotten via asynchronous call. | |
* See defaultState() function for list of states included. | |
* | |
* Usage: | |
* Assuming we have an async call to get documents (getDocuments) which takes a payload object as an arg, here's what we can do: | |
* | |
* ----- store.js ----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Cypress-ized and modified version of https://github.com/kemokid/scripting-sortable/blob/master/script_sortable_dnd.js | |
export function triggerSortableDragAndDrop(elemDrag, elemDrop) { | |
/* | |
Summary of what events this fires: | |
On elemDrag: | |
mouseDown | |
dragstart | |
On elemDrop: | |
dragover (repeat until it moves) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const progress = Array.from( | |
document.querySelectorAll('p[class^="progressNumbers"]') | |
) | |
.map(x => x.innerText) | |
.map(txt => { | |
let parsed = txt.match(/(\d+) of (\d+) complete/); | |
return { done: parseInt(parsed[1]), total: parseInt(parsed[2]) }; | |
}); | |
const done = progress.map(unit => unit.done).reduce((acc, val) => acc + val); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
train.visit_date = pd.to_datetime(train.visit_date) | |
test.visit_date = pd.to_datetime(test.visit_date) | |
def add_weather(dataset): | |
print('Adding weather...') | |
air_nearest = pd.read_csv( | |
'../../data/raw/weather/air_store_info_with_nearest_active_station.csv') | |
unique_air_store_ids = list(dataset.air_store_id.unique()) | |
weather_dir = '../../data/raw/weather/1-1-16_5-31-17_Weathe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
const code = '(print (+ 1 (* 2 3) 3))' | |
const parsed = parse(code) | |
console.debug('Parsed AST', parsed) | |
evaluate(parsed[0]) | |
function parse(phrase) { | |
let seek = 0 | |
const parsed = [] |
NewerOlder