From https://github.com/eamodio/vscode-gitlens/blob/master/src/constants.ts
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
git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch example.js' |
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
type Proxy = any[] | |
type Pop<T> = T extends [infer A, ...infer B] ? B : never | |
type Push<T> = T extends [...infer B] ? [any, ...B] : never | |
type Add<T extends Proxy, V extends Proxy> = [...T, ...V] | |
type Double<T extends Proxy> = [...T, ...T] | |
type Get<A extends Proxy> = A['length'] | |
type AddOne<A extends Proxy> = Push<A> | |
type SubOne<A extends Proxy> = Pop<A> |
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 { UnionToIntersection } from 'utility-types'; | |
type String<T> = T extends string ? T : any | |
type Keys<T, Field extends keyof T> = | |
T extends { [P in Field]: infer A } | |
? { [P in String<A>]: T } | |
: never | |
type LookupTable<Union, key extends keyof Union> = UnionToIntersection<Keys<Union, key>> |
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
type Unexact<T> = | |
T extends null | |
? null | |
: T extends undefined | |
? undefined | |
: T extends number | |
? number | |
: T extends boolean | |
? boolean | |
: T extends string |
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 sqlalchemy.ext.declarative import declarative_base | |
class Mixin: | |
def as_dict(self): | |
return {c.name: getattr(self, c.name) for c in self.__table__.columns} | |
def as_clear_dict(self): | |
_dict = {} | |
for c in self.__table__.columns: | |
if c.foreign_keys: | |
continue |
From: https://unix.stackexchange.com/questions/294600/i-cant-enable-swap-space-on-centos-7
Follow these steps, it works on DigitalOcean's droplets. I tested. Change the amount 4096 according to your need
yum install nano -y
sudo dd if=/dev/zero of=/swapfile count=4096 bs=1MiB
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
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 closest(num, arr) { | |
let idx = 0 | |
let curr = arr[idx] | |
let diff = Math.abs(num - curr); | |
for (var val = 0; val < arr.length; val++) { | |
var newdiff = Math.abs(num - arr[val]) | |
if (newdiff < diff) { | |
diff = newdiff | |
curr = arr[val] | |
idx = val |
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
CreateObject("Wscript.Shell").Run "cmd /c """"C:\Program Files\nodejs\node.exe"" ""C:\Users\Antho\AppData\Roaming\npm\node_modules\hotel\lib\daemon"" > ""C:\Users\Antho\.hotel\daemon.log""""", 0, true |
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
// Does a math equation on the bound value. | |
// Use @VALUE in your mathEquation as a substitute for bound value | |
// Operator order is parenthesis first, then Left-To-Right (no operator precedence) | |
public class MathConverter : IValueConverter | |
{ | |
private static readonly char[] _allOperators = new[] { '+', '-', '*', '/', '%', '(', ')' }; | |
private static readonly List<string> _grouping = new List<string> { "(", ")" }; | |
private static readonly List<string> _operators = new List<string> { "+", "-", "*", "/", "%" }; |