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
// https://github.com/Vincit/objection.js/issues/1477 | |
import { Model, QueryBuilder } from "objection"; | |
class Person extends Model { | |
static get tableName() { | |
return "persons"; | |
} | |
id!: number; |
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
// Prevents have to do a callback in setTimeout | |
function wait(ms) { | |
return new Promise((resolve) => setTimeout(resolve, ms)); | |
} | |
// no top level await :/ | |
async function someAsyncFunction() { | |
await wait(1000); // Wait for 1 second | |
} |
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
// hides the code coverage boxes on gh file pr diff view. | |
// added this because it makes it difficult to read | |
const rule = '.check-annotation-warning { display: none; }' | |
const sheet = window.document.styleSheets[0]; | |
sheet.insertRule(rule, sheet.cssRules.length); | |
// workaround to make snippet gloab fn | |
// can run hideCC() from console | |
window.hideCC = function (value) { | |
const sheet = window.document.styleSheets[0]; |
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
// navigate to https://app.codecov.io/gh/[ORG]/[REPO]/pulls?prStates%5B0%5D=MERGED | |
function sleep(delay) { | |
return new Promise(function(resolve) { | |
setTimeout(resolve, delay); | |
}); | |
} | |
async function loadAll(){ | |
while(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
import json | |
def reorder_execution_count(infile, outfile): | |
with open(infile, encoding='utf-8') as f: | |
nb = json.load(f) | |
count = 1 | |
for c in nb['cells']: |
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 command-line test gets an input from the user and | |
# attempts to square it. If there are no issues it | |
# prints the result of squaring the input. If the input | |
# is not an integer a ValueError is raised which triggers | |
# the 'except' which prints the issue to the user. If another | |
# exception occurs it will not be caught and will terminate the | |
# program and print the error message to the console. | |
while True: | |
val = input("Enter a number to square: ") |
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
# In this python command-line assertion test, ENTER | |
# results in an assertion failure which stops the program. | |
# Anything else will continue, which results in being asked for | |
# input again and again. | |
while True: | |
# Get command-line input | |
val = input("Press enter to test assertion failure: ") | |
# Enter for assertion failure | |
if 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
DROP DATABASE IF EXISTS grades_leaderboard; | |
CREATE DATABASE IF NOT EXISTS grades_leaderboard CHARACTER SET utf8 COLLATE utf8_general_ci; | |
USE grades_leaderboard; | |
DROP TABLE IF EXISTS grades; | |
DROP TABLE IF EXISTS study_sessions; | |
DROP TABLE IF EXISTS users; | |
DROP TABLE IF EXISTS courses; | |
DROP VIEW IF EXISTS modules_with_grades; |