This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // import { useEffect, useState } from 'react'; | |
| import { useEffect, useState } from 'preact/compat'; | |
| interface Atom<T> { | |
| key: Symbol | |
| } | |
| interface StoreValue { | |
| value: any, | |
| listeners: Set<() => void> | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ApplicationRecord < ActiveRecord::Base | |
| self.abstract_class = true | |
| def self.bulk_insert(data) | |
| # @type [PG::Connection] conn | |
| conn = self.connection.raw_connection | |
| raise NotImplementedError.new 'Database Driver not supported!' unless conn.class.to_s == 'PG::Connection' | |
| raise ArgumentError "Data not an Array of Hashes!" unless data.is_a?(Array) && data.all? {|rec| rec.is_a? Hash } | |
| return nil unless data.count > 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| echo "Docker Entrypoint is called!" | |
| cd /website | |
| if [[ -f "/website/public/hot" ]]; then | |
| echo "Removing HOT_RELOAD file" | |
| rm /website/public/hot | |
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type PollingConfig = { | |
| timeout?: number; | |
| interval?: number; | |
| initialTimeout?: number | |
| }; | |
| type RequestFnResult <T> = { pending: true } | { data : T }; | |
| type Callback <T> = () => Promise<RequestFnResult<T>>; | |
| export const TimeoutError = Symbol('TimeoutError!'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://stackoverflow.com/questions/49752151/typescript-keyof-returning-specific-type | |
| type KeyOfType<T, V> = keyof { | |
| [P in keyof T as T[P] extends V ? P : never]: any; | |
| }; | |
| type InferArgs<TValueType> = TValueType extends (...args: infer U) => any ? U : never; | |
| type InferReturn<TValueType> = TValueType extends (...args: any) => infer U ? U : never; | |
| const replaceFunction = < | |
| TArgs extends InferArgs<TObject[TKey]>, | |
| TReturn extends InferReturn<TObject[TKey]>, | |
| TCallable extends (...args: any) => any, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { getCurrentScope, onScopeDispose } from 'vue'; | |
| type AnyFn = (...args: any[]) => any; | |
| interface UseDebounceFnReturn<T extends AnyFn> { | |
| (...args: Parameters<T>): void; | |
| cancel: () => void; | |
| flush: () => void; | |
| } |
OlderNewer