Skip to content

Instantly share code, notes, and snippets.

View PierBover's full-sized avatar

Pier Bover PierBover

View GitHub Profile
var element = document.getElementById('fruits-template');
element.parentNode.removeChild(element);
var template = element.innerHTML;
var component = new Vue({
el: '#fruits',
template: template,
data: {
fruits: ['Apple', 'Mango', 'Banana']
}
@PierBover
PierBover / fruit.js
Last active November 15, 2018 04:49
<div id="fruit-template" class="vue-template">
<div class="fruit">
<h3>{{fruitName}}</h3>
</div>
</div>
<script>
Vue.component('my-fruit', {
template: '#fruit-template',
props: ['fruit-name']
{% include components/fruit.html %}
<div id="fruits">
<my-fruit v-for="fruit in fruits" :fruit-name="fruit"></my-fruit>
</div>
<script>
var component = new Vue({
el: '#fruits',
data: {
fruits: ['Apple', 'Banana', 'Mango']
}
<div id="my-thing-template">
<div class="my-thing" @click='edit'>
<div v-if="!editing">{{thing}}</div>
<div v-else>
<form @submit.prevent="onSubmit">
<input type="text" v-model="form.title">
<button type="submit">Submit</button>
<button @click="cancelEdit">Cancel</button>
</form>
</div>
@PierBover
PierBover / index.js
Created June 15, 2019 17:17
Node Kbps
const https = require('https');
const fs = require('fs');
const writeStream = fs.createWriteStream("./log.xls");
let bytes = 0;
https.get('https://edge.mixlr.com/channel/udesp', (resp) => {
resp.on('data', (buffer) => {
bytes += buffer.length;
});
@PierBover
PierBover / AppDelegate.swift
Last active September 2, 2019 17:22
Receive custom URL schema in macOS
class AppDelegate: NSObject, NSApplicationDelegate {
func applicationDidFinishLaunching(_ aNotification: Notification) {
NSAppleEventManager.shared().setEventHandler(self, andSelector: #selector(self.handleGetURLEvent(event:replyEvent:)), forEventClass: AEEventClass(kInternetEventClass), andEventID: AEEventID(kAEGetURL))
}
@objc func handleGetURLEvent(event: NSAppleEventDescriptor, replyEvent: NSAppleEventDescriptor) {
let urlString = event.paramDescriptor(forKeyword: AEKeyword(keyDirectObject))?.stringValue!
let url = URL(string: urlString!)!
debugPrint(url);
}
@PierBover
PierBover / index.js
Last active April 30, 2024 09:08
Micro router for Cloudflare Workers
const router = require('./router');
router.setRoutes([
{
path: '/ping',
method: 'GET',
handler: ping
},
{
path: '/hello/:name',
@PierBover
PierBover / explanation.md
Created May 8, 2020 15:55
FQL recursive function to get nested documents

This is how you'd call the function:

Call(Function("GetNestedDocument"), [Ref(Collection("SomeCollection"), "264260207986606612"), 0, 3])

Parameters:

  • A Ref of a document.
  • Current depth. Since AFAIK we cannot have default values in Lambda we need to pass 0 for the first level.
  • Max depth. The max number of levels the recursive function will go.
const routesFilesPlugin = {
name: 'route-files',
buildStart: async (options) => {
console.log('Generating routeModules.js');
const routesDir = path.resolve(__dirname, 'src/components/routes');
const routeFiles = fs.readdirSync(routesDir);
const routesString = routeFiles.map((filename) => {