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
using System; | |
using System.Diagnostics; | |
using System.Runtime.InteropServices; | |
using System.Runtime.CompilerServices; | |
using System.Windows.Input; | |
using System.Windows.Threading; | |
using System.Collections.Generic; | |
namespace Ownskit.Utils | |
{ |
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
# MIT License | |
# | |
# Copyright (c) 2018 Jelle Hermsen | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is | |
# furnished to do so, subject to the following conditions: |
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
# This hosts file is brought to you by Dan Pollock and can be found at | |
# http://someonewhocares.org/hosts/ | |
# You are free to copy and distribute this file for non-commercial uses, | |
# as long the original URL and attribution is included. | |
#<localhost> | |
127.0.0.1 localhost | |
127.0.0.1 localhost.localdomain | |
255.255.255.255 broadcasthost | |
::1 localhost |
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
// Dev switch for loading prev state or force canned eg. | |
let activateSaveState = true; | |
let showParseCount = true; | |
// Prelim sample input, drawn from the cli/src/tests/query_test.rs (as-is, excess space). | |
const eg = { | |
lang: 'javascript', | |
code: ` | |
class Person { | |
// the constructor |
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
-- Returns the Levenshtein distance between the two given strings | |
function string.levenshtein(str1, str2) | |
local len1 = string.len(str1) | |
local len2 = string.len(str2) | |
local matrix = {} | |
local cost = 0 | |
-- quick cut-offs to save time | |
if (len1 == 0) then | |
return len2 |
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
using namespace System.Collections | |
using namespace System.Management.Automation | |
using namespace System.ComponentModel.DataAnnotations | |
using namespace System.Runtime.Serialization | |
class MandatoryProperties { | |
MandatoryProperties([IDictionary]$properties) { | |
$this.GetType().GetProperties([System.Reflection.BindingFlags]'Instance,Public') | ForEach-Object { | |
$propertyName = $PSItem.Name | |
[bool]$isOptional = $PSItem.GetCustomAttributes([OptionalFieldAttribute], $true).count -gt 0 | |
if ( |
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
///<reference types="tampermonkey"/> | |
// @ts-check | |
// ==UserScript== | |
// @name DevTools - GM API on console | |
// @name:zh-CN 开发工具:在控制台启用 GM API | |
// @namespace https://github.com/cologler/ | |
// @version 0.1.0.3 | |
// @description Modified fork of original script <gist.github.com/Cologler/323558e1e55d20b73eadc8a5eb6bebde> | |
// @description:zh-CN try to take over the world! |
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
// Branchless, vectorized `atan2f`. Various functions of increasing | |
// performance are presented. The fastest version is 50~ faster than libc | |
// on batch workloads, outputing a result every ~2 clock cycles, compared to | |
// ~110 for libc. The functions all use the same `atan` approximation, and their | |
// max error is around ~1/10000 of a degree. | |
// | |
// They also do not handle inf / -inf | |
// and the origin as an input as they should -- in our case these are a sign | |
// that something is wrong anyway. Moreover, manual_2 does not handle NaN | |
// correctly (it drops them silently), and all the auto_ functions do not |
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
interface QueuedTask<T> { | |
task: () => T; | |
promise: { | |
resolve: (res: any) => void; | |
reject: (err: any) => void; | |
}; | |
} | |
interface RateLimitedTask<T> { | |
task: () => T; |
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
/** | |
* class for limiting the rate of function calls. | |
* Thanks to Pat Migliaccio. | |
* see https://medium.com/@pat_migliaccio/rate-limiting-throttling-consecutive-function-calls-with-queues-4c9de7106acc | |
* @example let l = new limit(); let logMessageLimited = l.throttleAndQueue(msg => { console.log(msg); }, 500); | |
*/ | |
class limit{ | |
public callQueue = [] | |
/** |
NewerOlder