Skip to content

Instantly share code, notes, and snippets.

Pier Bover PierBover

Block or report user

Report or block PierBover

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@PierBover
PierBover / AppDelegate.swift
Last active Sep 2, 2019
Receive custom URL schema in macOS
View AppDelegate.swift
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);
}
View index.js
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;
});
View thing.html
<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>
View 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']
}
View fruit.js
<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']
View fruit.js
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']
}
View fruit.js
var component = new Vue({
el: '#fruits',
template: '#fruits-template',
data: {
fruits: ['Apple', 'Mango', 'Banana']
}
});
View fruit.js
<div id="fruits">
<ul>
<li v-for="fruit in fruits">{{fruit}}</li>
</ul>
</div>
<script>
var component = new Vue({
el: '#fruits',
data: {
View store.js
var persistentStore = {
state: JSON.parse(localStorage.getItem('persistent-state')),
save () {
localStorage.setItem('persistent-state', JSON.stringify(this.state));
}
};
You can’t perform that action at this time.