Skip to content

Instantly share code, notes, and snippets.

@lukepighetti
lukepighetti / paywall_showing_schedule.dart
Created March 4, 2024 02:08
My way of showing a paywall every day for a few days, then every week, then every two weeks. Good for about a year.
import 'package:collection/collection.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '/architecture/let.dart';
import '/membership/membership_state.dart';
import '/membership/membership_tasks.dart';
import '/telemetry/analytics.dart';
Future<void> appOpenAction() async {
$analytics.vglAppOpenActionRequested();
@sma
sma / sqlite_kv.dart
Created January 26, 2024 13:19
A simple key-value store w/persistent sqlite3 database.
/// A simple key-value store w/persistent sqlite3 database.
class KV {
KV._(this._db);
final Database _db;
static Future<KV> open(String name) async {
return KV._(sqlite3.open(name)..execute('create table if not exists kv (k text primary key, v jsonb)'));
}
Future<Object?> get(String key) async {
@thekitchenscientist
thekitchenscientist / gist:56969191bd2f33849fb2dfa10cfae0d9
Created October 14, 2023 17:30
Recreation of textfx.withgoogle.com locally using dolphin-2.1-mistral-7b, llama-cpp-python and streamlit
# -*- coding: utf-8 -*-
"""
Prompts by Google https://github.com/google/generative-ai-docs/tree/main/demos/palm/web/textfx
@author: thekitchenscientist and Bing Chat (conversion of prompts and basic app framework)
"""
class TextFX:
# Initialize the list attribute with an empty list
@rodydavis
rodydavis / flutter_infinite_canvas.dart
Last active April 9, 2024 15:04
Flutter infinite canvas with InteractiveViewer + CustomMultiChildLayout
import 'package:flutter/material.dart';
import 'package:vector_math/vector_math_64.dart' hide Colors;
void main() {
final controller = WidgetCanvasController([
WidgetCanvasChild(
key: UniqueKey(),
offset: Offset.zero,
size: const Size(400, 800),
child: Scaffold(
@rodydavis
rodydavis / flutter_canvas_demo.dart
Last active December 23, 2022 23:18
Flutter Canvas Demo
import 'package:flutter/material.dart';
void main() {
runApp(const StoryBoardExample());
}
class StoryBoardExample extends StatelessWidget {
const StoryBoardExample({super.key});
@override
@steveruizok
steveruizok / cache.ts
Last active March 31, 2023 14:43
weak map gist
export class Cache<T extends object, K> {
items = new WeakMap<T, K>()
get<P extends T>(item: P, cb: (item: P) => K) {
if (!this.items.has(item)) {
this.items.set(item, cb(item))
}
return this.items.get(item)!
}
@lukepighetti
lukepighetti / Fastfile
Last active August 22, 2022 08:17
How I build and release Flutter side projects on iOS https://twitter.com/luke_pighetti/status/1530156415611969537
default_platform(:ios)
APPLE_ISSUER_ID = ENV["APPLE_ISSUER_ID"]
APPLE_KEY_CONTENT = ENV["APPLE_KEY_CONTENT"]
APPLE_KEY_ID = ENV["APPLE_KEY_ID"]
DEVELOPER_APP_ID = ENV["DEVELOPER_APP_ID"]
DEVELOPER_APP_IDENTIFIER = ENV["DEVELOPER_APP_IDENTIFIER"]
GIT_AUTHORIZATION = ENV["GIT_AUTHORIZATION"]
GITHUB_RUN_NUMBER = ENV["GITHUB_RUN_NUMBER"]
PROVISIONING_PROFILE_SPECIFIER = ENV["PROVISIONING_PROFILE_SPECIFIER"]
@klich3
klich3 / iphone-addressbar-gap.html
Created January 25, 2022 12:24
Attach some dom element on the bottom of screen as absolute, triggered to move on resize address bar.
<!--
Author: <Anthony Sychev> (hello at dm211 dot com | a.sychev at jfranc dot studio)
Buy me a coffe: https://www.buymeacoffee.com/twooneone
Untitled-1 (c) 2022
Created: 2022-01-25 20:06:02
Desc: Attach some dom element on the bottom of screen as absolute, triggered to move on resize address bar.
-->
<html>
@shqld
shqld / css-size-comparison.csv
Last active October 3, 2022 21:13 — forked from primaryobjects/css-comparison.csv
A comparison of CSS library sizes.
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 8.
Caution,Name,Version,Size (raw),Size (minified),Size (gzipped),"Site","URL",Remarks
,Milligram,v1.4.1,11 kb,9.0 kb,2.3 kb,"https://milligram.io/","https://cdnjs.cloudflare.com/ajax/libs/milligram/1.4.1/milligram.min.css",
,Skelton,v2.0.4,11 kb,5.8 kb,1.6 kb,"http://getskeleton.com/","https://cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.min.css",
,Material Design Lite,v1.3.0,146 kb,62 kb,12 kb,"https://getmdl.io/","https://code.getmdl.io/1.3.0/material.min.js",
,Foundation,v6.6.3,168 kb,133 kb,17 kb,"https://get.foundation/","https://cdn.jsdelivr.net/npm/foundation-sites@6.6.3/dist/css/foundation.min.css",
,Materialize,v1.0.0,179 kb,141 kb,21 kb,"https://materializecss.com/","https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css",
,Bootstrap,v4.6.0,199 kb,161 kb,24 kb,"https://getbootstrap.com/docs/4.6/","https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css",
,Bootstrap,v5.1.2,206 kb,164 kb,24 kb,"https://getbootstrap.com/","https://cdn.jsdelivr.net/npm/b
// by dave @beesandbombs
int[][] result;
float t, c;
float ease(float p) {
return 3*p*p - 2*p*p*p;
}
float ease(float p, float g) {