Skip to content

Instantly share code, notes, and snippets.

View vlastachu's full-sized avatar

Vlad Chuprin vlastachu

View GitHub Profile
@vlastachu
vlastachu / ts-advent-2024-12.ts
Created December 14, 2024 13:46
ts-advent-2024-12.ts
type StrToNum<S extends string> =
S extends `${infer I extends number}` ? I : never;
type NaughtyOrNice<S extends string, Result = 'naughty'> =
S extends "" ? Result :
S extends `${infer _}${infer R}`
? NaughtyOrNice<R, Result extends 'naughty' ? 'nice' : 'naughty'>
: never;
type FormatNames<A extends string[][]> =
import SwiftUI
import AVFoundation
import CoreML
import Vision
struct ContentView: View {
@ObservedObject var cameraManager = CameraManager()
var body: some View {
VStack {
import SwiftUI
import AVFoundation
import CoreML
import Vision
struct ContentView: View {
@ObservedObject var cameraManager = CameraManager()
var body: some View {
VStack {
type Alley = " ";
type MazeItem = "🎄" | "🎅" | Alley;
type DELICIOUS_COOKIES = "🍪";
type MazeMatrix = MazeItem[][];
type Directions = "up" | "down" | "left" | "right";
type As<From, To> = From extends To? From : never;
type Num = 1[]
type i<num extends Num> = num['length']
@vlastachu
vlastachu / aot-23.ts
Created December 24, 2023 09:12
aot-23
type Connect4Chips = '🔴' | '🟡';
type Connect4Cell = Connect4Chips | ' ';
type Connect4State = '🔴' | '🟡' | '🔴 Won' | '🟡 Won' | 'Draw';
type EmptyBoard = [
[" ", " ", " ", " ", " ", " ", " "],
[" ", " ", " ", " ", " ", " ", " "],
[" ", " ", " ", " ", " ", " ", " "],
[" ", " ", " ", " ", " ", " ", " "],
[" ", " ", " ", " ", " ", " ", " "],
import 'dart:async';
import 'package:bloc/bloc.dart';
import 'package:flutter/widgets.dart';
// interface to close something
abstract class AppClosable {
void close();
}
import 'dart:math';
import 'package:cli/cli.dart' as cli;
abstract class AbstactBinarySearch {
final List<int> nums;
final int target;
int start = 0;
int end;
require 'digest'
require 'openssl'
require 'base64'
require 'net/http'
require 'json'
require 'time'
VWS_ENDPOINT = 'vws.vuforia.com'
TARGETS_PATH = '/targets'
/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow
*/
import React, { Component } from 'react';
import { Platform, StyleSheet, Text, View, Button } from 'react-native';
var _ = new Proxy({}, {get: (object, prop) => x => Reflect.get(x, prop)})
// Now you can use `_.method` instead of `x => x.method`
var a = {someMethod: x => x + 1}
_.someMethod(a)(1) // => 2
a.prototype.prototypeMethod = (a, b) => a + b
_.prototypeMethod(a)(1, 2) // => 3