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
-- Define the Lua table that maps names to URLs | |
local urlTable = { | |
john = "https://example.com/john", | |
alice = "https://example.com/alice", | |
bob = "https://example.com/bob", | |
} | |
-- Register a callback for the custom hammerspoon:// URLs | |
hs.urlevent.bind("example", function(eventName, params, senderPID) | |
local event = eventName -- The event name is the host in hammerspoon://host |
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 symtable | |
def print_symbol_table_info(symbol_table: symtable.SymbolTable, indent=0): | |
# Print the information of the current symbol table | |
print(" " * indent + f"Symbol Table: {symbol_table.get_name()}") | |
print(" " * (indent + 2) + f"Type: {symbol_table.get_type()}") | |
print(" " * (indent + 2) + f"Identifier: {symbol_table.get_id()}") | |
print(" " * (indent + 2) + f"First Line Number: {symbol_table.get_lineno()}") | |
# print(" " * (indent + 2) + f"Is Optimized: {symbol_table.is_optimized()}") | |
# print(" " * (indent + 2) + f"Is Nested: {symbol_table.is_nested()}") |
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
package main | |
import "fmt" | |
type Cell struct { | |
x int | |
y int | |
state int | |
} |
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
package main | |
import ( | |
"fmt" | |
"sync" | |
) | |
func main() { | |
ch := make(chan int) | |
wg := sync.WaitGroup{} |
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
""" | |
Convert Avro schema files to swagger object definitions. | |
""" | |
import argparse | |
import json | |
from dataclasses import dataclass | |
from typing import Dict, List | |
parser = argparse.ArgumentParser( | |
description="Convert avro schema file to swagger object definition" |
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 steampy import guard | |
import pyperclip | |
pyperclip.copy(guard.generate_one_time_code("shared secret")) |
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 django.contrib.auth import get_user_model | |
from utils.test_utils import APITestCase | |
from .graphql_requests import ( | |
CREATE_LINK_MUTATION | |
) | |
class LinkTestCase(APITestCase): | |
def setUp(self): |
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 django.contrib.auth.models import AnonymousUser | |
from django.test import RequestFactory | |
from snapshottest.django import TestCase | |
from graphene.test import Client | |
from hackernews.schema import schema | |
class APITestCase(TestCase): | |
def setUp(self): |
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 asyncio | |
import time | |
import random | |
async def task(i): | |
await asyncio.sleep(i* 0.01) | |
print(i) | |
async def main(): | |
a = [random.randint(0, 100) for _ in range(0, 100)] | |
coroutines = list() |
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 selenium.webdriver.common.keys import Keys | |
from selenium import webdriver | |
from time import sleep | |
from ast import literal_eval | |
import random | |
from selenium.webdriver.support import ui | |
from selenium.webdriver.support import expected_conditions as EC | |
from selenium.webdriver.common.by import By | |
from selenium.common.exceptions import NoSuchElementException | |
from selenium.common.exceptions import WebDriverException |
NewerOlder