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 openai import OpenAI | |
client = OpenAI( | |
api_key='ollama', | |
base_url="http://localhost:11434/v1", | |
) | |
# this will fail, showing openai.NotFoundError: 404 page not found | |
data = client.embeddings.create( | |
input='hi', |
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
{% if context.params.rectype != 'PETscan' and | |
context.params.rectype != 'PETreport' and | |
context.params.rectype != 'PETprepare' and | |
context.params.rectype != 'PETinj' %} | |
{% error "rectype should be PETscan, PETreport, PETprepare or PETinj" %} | |
{% endif %} | |
{% set body = {"body": {"chtno": context.params.chtno, "deptNo": context.params.deptno, "recType": context.params.rectype}} %} | |
select |
- Assuming that the tools are widely used, mature, and employed in various technology stacks, there is little reason to doubt the quality. Of course, if the tool is an early release, or used by only a few people worldwide, or a piece of seldom downloaded, version 0.1, open source software, there may be good reason to suspect the software. (Equally, an alpha version of commercial software might be suspect.)
- All the usual debugging advice applies, so isolate the problem, stub out calls, and surround it with tests; check calling conventions, shared libraries, and version numbers; explain it to someone else; look out for stack corrup- tion and variable type mismatches; and try the code on different machines and different build configurations, such as debug and release.
- Question your own assumptions and the assumptions of others.
- Multithreaded problems are another source of bugs that turn hair gray and induce screaming
Notes: you need to have the Refactoring: Web Edition account in order to see details of Refactoring Strategies
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
class Twitter: | |
def __init__(self): | |
""" | |
Initialize your data structure here. | |
""" | |
self.tweets = [] | |
self.following_dict = {} | |
self.followed_dict = {} |
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 numpy as np | |
from matplotlib import pyplot as plt | |
# helper function to check if (x, y) is in red section | |
# x and y may be a single point or a numpy array | |
def is_in_quarter_section(x, y): | |
return x*x + y*y <= 1 | |
def approximate_pi(sample_size=10000): | |
# initialization |
- 682. Baseball Game
- 葉致煜
- Runtime: 40 ms, faster than 52.00% of Python3 online submissions for Baseball Game
- 葉致煜
- Memory Usage: 12.9 MB, less than 5.15% of Python3 online submissions for Baseball Game.
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
/* | |
Referenced from Stanford CS193p | |
#: important | |
##: very important | |
##Protocols | |
- Protocol Syntax | |
- Property Requirements | |
- Method Requirements |
NewerOlder