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
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
#!/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
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
// 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
$projectName = Get-ChildItem .\ -Filter "*.sln" | Select-Object -ExpandProperty Name | |
if (!$projectName) { | |
Write-Host "Not found any *.SLN files in current directory!" | |
Write-Host "Exit with error..." | |
exit | |
} | |
$projectName = [io.path]::GetFileNameWithoutExtension($projectName) | |
$targetZip = $projectName + ".zip" |
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
const Utils = { | |
findUsersByMessage(ev) { | |
const findUsers = ev => { | |
const regExMention = /<@(\d+)>/g; | |
const users = [...ev.content.matchAll(regExMention)]; | |
return users.map(x => x[1]); | |
} | |
const findGroups = ev => { | |
const regExMention = /<@&(\d+)>/g; | |
const groupsIds = [...ev.content.matchAll(regExMention)].map(x => x[1]); |
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
const commander = require('commander'); | |
const colors = require('colors'); | |
const replace = require('replace-in-file'); | |
const fs = require('fs'); | |
const util = require('util'); | |
let path = null; | |
commander | |
.version('0.1.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
// Now if you adding a domain with wildcard A record, Cloudflare uses strange scan, which added a 1000 trash domains (like 1-100, some english words like "ai", "air", "android"). | |
// There's no way to bulk delete it, you can delete it only using their API. | |
// So I write a script that can help you with this problem. | |
// Discussions about same problem: | |
// https://community.cloudflare.com/t/delete-all-records-using-api/13410/2 | |
// https://community.cloudflare.com/t/bulk-delete-dns-record/89540 | |
const settings = { | |
email: 'your@email', |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>IE10 Compatibility Vue SFC Loader</title> | |
<script src="https://unpkg.com/[email protected]/dist/vue.js"></script> | |
<script src="https://unpkg.com/[email protected]/dist/polyfill.min.js"></script> | |
</head> | |
<body> |
NewerOlder