Skip to content

Instantly share code, notes, and snippets.

View kazuooooo's full-sized avatar
:octocat:
Taking a closer look, wombat!

kazuwombat kazuooooo

:octocat:
Taking a closer look, wombat!
View GitHub Profile
@kazuooooo
kazuooooo / addMokuji.js
Created August 16, 2021 05:00
STUDIOに目次をつけるコード
var assignMokuji = function(){
/**
* 指定したテキストでH1もしくはH2要素を見つける
* @param {*} text
* @returns
*/
var findH1OrH2ByText = function(text) {
var h1 = $("h1:contains(" + text + ")").first()
if(h1[0]){
return h1[0]
@kazuooooo
kazuooooo / obento-bot.js
Last active September 20, 2022 11:21
お弁当ボットのソースコードです(Google App Script)
Const = {
spreadSheetId: 'xxxxxxxxxxxxxxxxxx',
obentColumnIdx: 6,
sheetStartDate: new Date(2017, 0, 19),
sheetTopMarginRows: 4,
scheduleOrderTime: new Date(2017, 0, 1),
scheduleRemindTime: new Date(2017, 0, 1),
triggers: {
triggerDays: [ScriptApp.WeekDay.SUNDAY,
ScriptApp.WeekDay.MONDAY,
declare module 'pinia' {
export interface PiniaCustomProperties<Id, S, G, A> {
sync(key: string, ref: DocumentReference): Unsubscribe
sync(key: string, ref: CollectionReference): Unsubscribe
sync(key: string, ref: Query): Unsubscribe
}
}
store.sync = (key, ref) => {
// Document
if (ref instanceof DocumentReference) {
return onSnapshot(ref, (ds) => {
if (ds.exists()) {
store.$patch({ [key]: ds.data() })
}
})
}
import { CollectionReference, DocumentReference, onSnapshot, Query, Unsubscribe } from "firebase/firestore";
import { PiniaPluginContext } from "pinia";
export const PiniaFirestoreSync = ({ store }: PiniaPluginContext) => {
store.sync = (key, ref) => {
// Document
if (ref instanceof DocumentReference) {
return onSnapshot(ref, (ds) => {
if (ds.exists()) {
store.$patch({ [key]: ds.data() })
import { PiniaPluginContext } from "pinia";
// Plugin
const magicNumPlugin = ({ store }: PiniaPluginContext) => {
store.magicNumber = 5
}
// Typing
declare module 'pinia' {
export interface PiniaCustomProperties {
import { collection, getFirestore, query, where } from "firebase/firestore"
import { defineStore } from "pinia"
type ExampleDoc = {
name: string,
age: number
}
export type State = {
queryData: ExampleDoc[] | null,
}
this.sync(
'queryData' // Property name of State
query // Query
)
import { collection, getFirestore } from "firebase/firestore"
import { defineStore } from "pinia"
type ExampleDoc = {
name: string,
age: number
}
export type State = {
collectionData: ExampleDoc[] | null,
this.sync(
'collectionData' // State property name of State
collectionRef // Collection Reference
)