Skip to content

Instantly share code, notes, and snippets.

@winterdl
winterdl / app.build.gradle.kts
Created November 7, 2022 06:49 — forked from alexugthub/app.build.gradle.kts
Flutter Kotlin DSL
import java.util.Properties
val localProperties = Properties()
val localPropertiesFile = file(rootProject.file("local.properties"))
if (localPropertiesFile.exists()) {
localProperties.load(localPropertiesFile.inputStream())
}
val flutterRoot = localProperties.getProperty("flutter.sdk")
# Firestore Security Rules - Examples
Default: Every resource is locked down by default, and its a redundant rule, but can be a good reminder in the start of rules file
service cloud.firestore {
match /databases/{database}/documents {
match /{document=\*\*} {
allow read, write: if false;
}
}
}
@winterdl
winterdl / main.swift
Created August 7, 2021 04:10 — forked from helje5/main.swift
Using async/await concurrency on iOS 14 and before
// Created by Helge Heß 2021-06-17
import Foundation
// They use obfuscated names to hide it from us!
import JavaScriptCore
/// Setup our async/await runtime.
let runtime = JSContext()!
@winterdl
winterdl / SongConverter.cs
Created April 16, 2021 07:40 — forked from miodevs/SongConverter.cs
New song converter for the Piano Tiles 2 Template
//Song converter utility for the piano tiles 2 templates on SellMyApp https://www.sellmyapp.com/downloads/piano-tiles-template/
using UnityEngine;
using System.Collections;
using MovementEffects;
using Mio.TileMaster;
using System.Collections.Generic;
using System;
//using System.Runtime.Serialization.Formatters.Binary;
@winterdl
winterdl / page_turn.dart
Created April 7, 2021 01:15 — forked from slightfoot/page_turn.dart
Page Turn Effect - By Simon Lightfoot. Replicating this behaviour. https://www.youtube.com/watch?v=JqvtZwIJMLo
// MIT License
//
// Copyright (c) 2019 Simon Lightfoot
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@winterdl
winterdl / CustomPropertyJSValueLifetime.swift
Created January 21, 2021 17:00 — forked from leonbreedt/CustomPropertyJSValueLifetime.swift
JavaScriptCore custom property JSValue lifetime
import Cocoa
import JavaScriptCore
/// Something that can be represented as a `JSValue`.
protocol JSValueRepresentable {
/// The `JSValue` for this thing.
var jsValue: JSValue { get }
}
func loadCatFact(completion:@escaping (String) -> Void) {
let session = URLSession.shared
if let url = URL(string: "https://catfact.ninja/fact") {
let task = session.dataTask(with: url) { (data, response, error) in
if error == nil, let data = data {
let factData = String(data: data, encoding: .utf8)
completion(factData ?? "")
}
}
task.resume()
if let context = JSContext() {
let asynchronousCall: @convention(block) (JSValue) -> Void = { (callback) in
loadCatFact { (catFact) in
callback.call(withArguments: [catFact])
}
}
let printText:@convention(block) (String) -> Void = { (text) in
print("\(text)")
}
@winterdl
winterdl / JavaScriptCore+fetch.swift
Created January 19, 2021 07:21 — forked from yycking/JavaScriptCore+fetch.swift
add fetch, console.log and Promise.then/catch to JavaScriptCore on iOS/Mac
import JavaScriptCore
extension JSContext {
subscript(key: String) -> Any {
get {
return self.objectForKeyedSubscript(key)
}
set{
self.setObject(newValue, forKeyedSubscript: key as NSCopying & NSObjectProtocol)
}
import JavaScriptCore
import Foundation
let context = JSContext()!
import JavaScriptCore
@objc protocol MovieJSExports: JSExport {
var title: String { get set }
var price: String { get set }