This file contains 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 { type StoreApi, useStore } from "zustand"; | |
type WithHookSelectors<S> = S extends { getState: () => infer T } | |
? S & { use: { [K in keyof T]: () => T[K] } } | |
: never; | |
export function createHookSelectors<S extends StoreApi<object>>(_store: S) { | |
const store = _store as WithHookSelectors<typeof _store>; | |
store.use = {}; | |
for (const key of Object.keys(store.getState())) { |
This file contains 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 type { ActionArgs, LoaderArgs } from "@vercel/remix"; | |
import type { Params } from "@remix-run/react"; | |
type Handler<T> = ((args: LoaderArgs) => T) | ((args: ActionArgs) => T); | |
type TesterArgs = { | |
path?: string; | |
body?: Record<string, string>; | |
headers?: HeadersInit; |
This file contains 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
name: ⚙️ CI | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} |
This file contains 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
% vehicle facts | |
vehicle(bicycle). | |
vehicle(car). | |
vehicle(taxi) :- | |
vehicle(car). | |
vehicle(bus). | |
distinct(bicycle, taxi). | |
distinct(bicycle, car). | |
distinct(bicycle, bus). |
This file contains 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
module Main where | |
import System.IO | |
import Data.List | |
import Data.List.Utils | |
data Tree a = Leaf a | Node a (Tree a) (Tree a) deriving Show | |
getLeft :: Tree a -> Tree a | |
getLeft (Node _ x _) = x |
This file contains 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
const getFrequency = text => { | |
let freqs = []; | |
for (let i = 0; i < text.length; i++) { | |
const letter = text[i]; | |
const letterIndex = freqs.findIndex(l => l.symbol === letter); | |
if (letterIndex > -1) { | |
freqs[letterIndex].weight++; | |
} else { |
This file contains 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
const constats = { | |
MIN_DISTANCE: 2, | |
MIN_VELOCITY: 3, | |
MAX_VELOCITY: 2, | |
MIN_TRAVEL_TIME: 2, | |
MAX_TRAVEL_TIME: 4 | |
}; | |
const followTarget = () => { | |
let vector = { |
This file contains 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
from zipfile import ZipFile | |
import itertools | |
charset = "0123456789" | |
minSize = 1 | |
maxSize = 3 | |
zipName = 'text.zip' | |
def genPassword(): |
This file contains 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
<?php | |
$user_id = get_current_user_id(); | |
$codes = array(); | |
global $wpdb; | |
$querystr = "SELECT * FROM wp_wcg_codes"; | |
$wcg_codes = $wpdb->get_results( $querystr, ARRAY_A); | |
foreach($wcg_codes as $row){ |
This file contains 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
function createBooking(agent) { | |
let guests = agent.parameters.guests; | |
let time = new Date(agent.parameters.time); | |
let date = new Date(agent.parameters.date); | |
let bookingDate = new Date(date); | |
bookingDate.setHours(time.getHours()); | |
bookingDate.setMinutes(time.getMinutes()); | |
let now = new Date(); | |
if (guests < 1){ |
NewerOlder