Skip to content

Instantly share code, notes, and snippets.

View michaelevensen's full-sized avatar

Michael Nino Evensen michaelevensen

View GitHub Profile
@michaelevensen
michaelevensen / LocalCollection.swift
Created August 20, 2019 08:57
LocalCollection to be used together with DataSource for Firestore Queries.
//
// Copyright (c) 2016 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
@michaelevensen
michaelevensen / RestaurantTableViewDataSource.swift
Created August 20, 2019 08:56
Example #1 DataSource for FireStore.
//
// Copyright (c) 2018 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
@michaelevensen
michaelevensen / AVPlayer+Repeat.swift
Created May 10, 2019 19:45 — forked from junpluse/AVPlayer+Repeat.swift
AVQueuePlayer.repeatMode = .All
//
// AVPlayer+Repeat.swift
//
// Created by Jun Tanaka on 4/1/16.
// Copyright © 2016 eje Inc. All rights reserved.
//
import AVFoundation
private final class RepeatManager: NSObject {
@michaelevensen
michaelevensen / AudioPlayer.swift
Created April 23, 2019 07:03 — forked from netgfx/AudioPlayer.swift
A basic audio player with observers and extra features. Based on AVFoundation and AVQueuePlayer
//
// AudioPlayer.swift
//
// Created by MDobekidis
//
import Foundation
import AVFoundation
import UIKit
import Signals
@michaelevensen
michaelevensen / FireStoreQuery.swift
Created February 8, 2019 09:18
Default FireStore listener
self.albumQuery()
.order(by: "title", descending: true)
.getDocuments { (querySnapshot, error) in
if let err = error {
debugPrint("Error fetching documents \(err)")
}
else {
guard let documentSnapshot = querySnapshot else { return }
import React from "react";
import dateFns from "date-fns";
class Calendar extends React.Component {
state = {
currentMonth: new Date(),
selectedDate: new Date()
};
renderHeader() {
//Create TapGesture Recognizer
let tap = UITapGestureRecognizer(target: self, action: #selector(handleTap(rec:)))
//Add recognizer to sceneview
sceneView.addGestureRecognizer(tapRec)
//Method called when tap
@objc func handleTap(rec: UITapGestureRecognizer){
if rec.state == .ended {
import { Data, Override } from "framer";
export const data = Data({
isRecording: false
});
export const toggleRecording: Override = () => {
return {
onTap() {
data.isRecording = (data.isRecording ? false : true);
@michaelevensen
michaelevensen / DrawLabel.tsx
Created November 13, 2018 13:27
Draw Canvas Label
drawLabel(angle) {
var canvas: any = document.getElementById("canvas"),
ctx: CanvasRenderingContext2D = canvas.getContext('2d');
// Clear canvas first
ctx.clearRect(0, 0, canvas.width, canvas.height);
canvas.width = 500;
// Draw text
ctx.font = "20px Helvetica";
@michaelevensen
michaelevensen / HiddenPropertyControls.tsx
Created September 27, 2018 07:17
Conditionally show property controls based on props (or other values) in Framer X, returns `true` or `false`.
static propertyControls: PropertyControls = {
status: {
type: ControlType.Enum,
options: ["idle", "fetching", "success", "error"],
optionTitles: ["Idle", "Fetching", "Success", "Error"],
title: "Status"
},
errorText: {
type: ControlType.String,
title: "Error Text",