Skip to content

Instantly share code, notes, and snippets.

@etherealHero
etherealHero / README.md
Last active July 5, 2024 05:50
markdown ui kit

lib, framework, package, db, any
Static Badge Static Badge Static Badge Static Badge

if (typeof Object.create !== "function") {
/** Polyfill {@link https://developer.mozilla.org/zh-TW/docs/Web/JavaScript/Reference/Global_Objects/Object/create#polyfill} */
Object.create = (function () {
/** @constructor */
function Temp() {}
return function (proto) {
if (proto === null || (typeof proto !== "object" && typeof proto !== "function")) {
throw TypeError("Object prototype may only be an Object or null: " + proto);
}
/**
* @typedef {Object} MyObject
* @property {string} knownProperty - Известное свойство
*/
/**
* @returns {MyObject & { [key: string]: any }}
*/
function createObject() {
const obj = {
@etherealHero
etherealHero / theme_provider.dart
Created May 18, 2024 15:28
Flutter ThemeProvider with persistent storage
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
final prefs = await SharedPreferences.getInstance();
runApp(App(
themeController: ThemeController(prefs),
# change git author on local machine
git config --global --edit
git commit --amend --reset-author
git config --global user.name <username>
git config --global user.email <email>
git commit --amend --reset-author
git remote -v
git add . && git commit -m "try author" && git push
git pull
@etherealHero
etherealHero / freezed_isar.dart
Last active May 20, 2024 13:43
freezed & isar & isarLinks
import 'package:flutter/material.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:isar/isar.dart';
import 'package:path_provider/path_provider.dart';
part 'test.freezed.dart';
part 'test.g.dart';
@freezed
@Collection(ignore: {'copyWith'})
@etherealHero
etherealHero / fuzzysort-find.md
Created December 22, 2023 02:35
Fuzzysort find word in list
import chalk from 'chalk'
import fuzzysort from 'fuzzysort'

const findWord = 'lorem'
const resource = ['lorem ipsum', 'lorei mpsum', 'ipsum dolor', 'ipsum lor', 'losum remip', 'lor', 'loiem iplor']

console.log(
  [...fuzzysort.go(findWord, resource.map(a => ({title: a})), { keys: ['title'] })]
 .map(a =&gt; fuzzysort.highlight(a[0], (m) =&gt; chalk.yellow(m)))
@etherealHero
etherealHero / edge-sql.js
Last active December 22, 2023 00:04
NodeJS mssql by edge-js
const edge = require('edge-js');
const getProcedures = edge.func('sql', {
source: "SELECT TOP 10 name FROM sys.procedures",
connectionString: "Persist Security Info=False;Integrated Security=true;Initial Catalog=<database>;server=<server>"
});
const init = async () => {
const res = await new Promise((res, rej) => {
getProcedures(null, function (error, result) {
@etherealHero
etherealHero / .vimrc
Last active July 2, 2024 22:59
.vimrc_configuration
" vim-bootstrap 2024-07-02 04:39:38
"*****************************************************************************
"" Vim-Plug core
"*****************************************************************************
let vimplug_exists=expand('~/.vim/autoload/plug.vim')
if has('win32')&&!has('win64')
let curl_exists=expand('C:\Windows\Sysnative\curl.exe')
else
let curl_exists=expand('curl')