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/zsh | |
if [ ! -e package.json ]; then | |
echo 'package.json does not exist' | |
exit 1 | |
fi | |
if [ $(jq -r '.scripts' package.json) = null ]; then | |
echo 'package.json has no scripts' | |
exit 2 | |
fi | |
if [ $(jq -r '.scripts|length' package.json) -eq 0 ]; then |
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
function ctorToFunc<C extends new (...args: any[]) => any, R extends Bar>( | |
cls: C extends new (...args: any[]) => R ? C : never, | |
...args: C extends new (...args: infer P) => R ? P : never | |
): InstanceType<C> { | |
return new cls(...args); | |
} | |
// Constructor Type Literals: https://github.com/Microsoft/TypeScript/blob/v2.6.1/doc/spec.md#3.8.9 | |
// What `class` logically does: https://exploringjs.com/tackling-ts/ch_classes-as-values.html#type-operator-typeof |
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
// Licensed under the MIT license. | |
import React from 'react'; | |
import { Stage } from 'react-konva'; | |
/** | |
* Bridge provided React contexts such that context consumers inside Konva Stage | |
* can use the context values that are provided outside. | |
* | |
* Do NOT call this function inside render methods. This function should be |
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
from itertools import islice | |
import io | |
import re | |
def rlines(f, BLOCK_SIZE = 1024): | |
f.seek(0, io.SEEK_END) | |
block_end_byte = f.tell() | |
block_number = -1 | |
blocks = [] | |
while block_end_byte > 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 math | |
adjlists = { | |
'A': ['B', 'D', 'H'], | |
'B': ['A', 'C', 'D'], | |
'C': ['B', 'D', 'F'], | |
'D': ['A', 'B', 'C', 'E'], | |
'E': ['D', 'F', 'H'], | |
'F': ['C', 'E', 'G'], | |
'G': ['F', 'H'], | |
'H': ['A', 'E', 'G'] |
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
create function to_char_dsinterval(period DSINTERVAL_UNCONSTRAINED, fmt varchar2) return varchar2 is | |
/* | |
==================================================================================================== | |
Filename : to_char_dsinterval.sql | |
Author : Bob Lee | |
Date : 28-Feb-2019 | |
Usage : convert dsinterval to varchar2, specifies format in fmt | |
recognized format elements are as follows, in regex and case-insensitive: | |
^s Add head plus/minus sign | |
s$ Add tail plus/minus sign |
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
create or replace function format_query_result ( | |
sql_stmt varchar2, | |
col_formats dbms_sql.varchar2a, | |
col_lengths dbms_sql.Number_Table, | |
show_full_col_name boolean default true | |
) return dbms_sql.varchar2a | |
authid current_user | |
is | |
--TODO: need extra param to allow self-defined column spec |
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
using System; | |
using System.Security.Cryptography; | |
using System.Text; | |
using System.Linq; | |
public class Program | |
{ | |
// adapted from https://paragonie.com/blog/2015/11/preventing-timing-attacks-on-string-comparison-with-double-hmac-strategy | |
static bool SecuredStringComparison(string x, string y) | |
{ |