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
$('#vocab').contextMenu({ | |
selector: ".entry", | |
build: function($trigger, e) { | |
e.preventDefault(); | |
function buildMenu(buildMenuCallback){ | |
$.post('/vocabInLearning', { vocab: $('a', this).text() }, function(data) { | |
var isLearnt = (data === '1'); | |
buildMenuCallback({ |
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 subprocess | |
from pathlib import Path | |
from datetime import datetime | |
from PIL import ImageGrab | |
import atexit | |
from urllib.parse import quote | |
class Server: | |
def __init__(self, root, port=14074): |
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 shlex | |
import json | |
import re | |
ADDITIONAL_CHAR = ''.join(re.findall(r'\w', re.escape(''.join(chr(u) for u in range(0x10FFFF))))) | |
def parse_query(q: str, operators=(':', '=', '>', '<')): | |
""" | |
:param str q: |
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 ast | |
import re | |
class SearchBox: | |
ast_table = { | |
ast.Eq: ':', | |
ast.Is: '=', | |
ast.Or: 'or', | |
ast.And: 'and', |
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 lark | |
parser = lark.Lark(r''' | |
?atom : atom or atom | |
| atom and atom | |
| "(" atom ")" | |
| compare | |
| value | |
compare : value ":" value |
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
// yarn add googleapis@27 @types/node | |
import fs from "fs"; | |
import readline from "readline"; | |
import {google} from "googleapis"; | |
import { OAuth2Client } from "google-auth-library"; | |
const CRED_PATH = "secret/credentials.json"; | |
const TOKEN_PATH = "secret/token.json"; | |
const SCOPES = ["https://www.googleapis.com/auth/spreadsheets.readonly"]; |
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
a.sort((a, b) => { | |
function convert(x: any) { | |
return x[sortBy]; | |
} | |
function compare() { | |
const m = convert(a) || -Infinity; | |
const n = convert(b) || -Infinity; | |
if (typeof m === "string" && typeof n === "string") { | |
return m.localeCompare(n); |
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
export function mongoFilter(x: any, cond: any): boolean { | |
return Object.keys(cond).every((k) => { | |
if (k === "$or") { | |
return (cond[k] as any[]).some((c0) => mongoFilter(x, c0)); | |
} else if (k === "$and") { | |
return (cond[k] as any[]).every((c0) => mongoFilter(x, c0)); | |
} else { | |
let dotIndex = k.indexOf("."); | |
while (dotIndex !== -1) { | |
x = x[k.slice(0, dotIndex)]; |
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
************* Module src.test.test_search | |
src/test/test_search.py:1:0: C0111: Missing module docstring (missing-docstring) | |
src/test/test_search.py:4:0: C0111: Missing function docstring (missing-docstring) | |
src/test/test_search.py:8:0: C0111: Missing function docstring (missing-docstring) | |
************* Module src.python.server | |
src/python/server.py:1:0: C0111: Missing module docstring (missing-docstring) | |
src/python/server.py:17:0: C0103: Constant name "app" doesn't conform to UPPER_CASE naming style (invalid-name) | |
src/python/server.py:18:0: C0103: Constant name "socketio" doesn't conform to UPPER_CASE naming style (invalid-name) | |
src/python/server.py:28:0: C0111: Missing function docstring (missing-docstring) | |
src/python/server.py:33:0: C0111: Missing function docstring (missing-docstring) |
OlderNewer