A set of n records, each identified by one or more key fields.
Problem: Efficiently locate, insert and delete the record associated with any query key q.
Data structures include hash tables, skip lists and balanced/unbalanced binary search trees.
A set of n records, each identified by one or more key fields.
Problem: Efficiently locate, insert and delete the record associated with any query key q.
Data structures include hash tables, skip lists and balanced/unbalanced binary search trees.
function Timer() { | |
const startTime = React.useRef(performance.now()); | |
const [time, setTime] = React.useState(performance.now()); | |
React.useEffect(() => { | |
const id = setTimeout(() => { | |
ReactDOM.flushSync(() => { | |
setTime(performance.now()); | |
}); | |
}, 2); |
This is a list of guidelines to make your Javascript faster, often associated with jsPerf benchmarks.
If you have an existing codebase, don't get carried away with premature optimizations. Profile to find the slow bits and pick the low hanging fruit.
Some of the latter lessons in Code School's Chrome DevTools course will teach you how to profile your code.
from bs4 import BeautifulSoup | |
import requests | |
def getPlaylistLinks(url): | |
sourceCode = requests.get(url).text | |
soup = BeautifulSoup(sourceCode, 'html.parser') | |
domain = 'https://www.youtube.com' | |
for link in soup.find_all("a", {"dir": "ltr"}): | |
href = link.get('href') | |
if href.startswith('/watch?'): |
<!doctype html> | |
<title>Site Maintenance</title> | |
<style> | |
body { text-align: center; padding: 150px; } | |
h1 { font-size: 50px; } | |
body { font: 20px Helvetica, sans-serif; color: #333; } | |
article { display: block; text-align: left; width: 650px; margin: 0 auto; } | |
a { color: #dc8100; text-decoration: none; } | |
a:hover { color: #333; text-decoration: none; } | |
</style> |
# Ubuntu
sudo apt-get install gpa seahorse
# Mac
## | |
# Host Database | |
# | |
# localhost is used to configure the loopback interface | |
# when the system is booting. Do not change this entry. | |
## | |
127.0.0.1 localhost | |
255.255.255.255 broadcasthost | |
::1 localhost | |
fe80::1%lo0 localhost |
The early programmer struggles with the Javascript keyword this
. But understanding your this
context is easier than it seems.
This
is all about where a function is invoked.
Often, early programmers worry about where the function was declared. Perhaps the function was declared in a specific file or a particular object. Surely this changes it's this
!
Nope.
To understand this
, we need to see where it is invoked. Nothing else matters, with one exception which we'll cover in a moment.
# `ERROR: Error installing nokogiri: | |
# ERROR: Failed to build gem native extension. | |
# | |
# current directory: /usr/local/var/rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/nokogiri-1.7.0/ext/nokogiri | |
# /usr/local/var/rbenv/versions/2.3.1/bin/ruby -r ./siteconf20170103-68488-r71c9j.rb extconf.rb --with-xml=/usr/local/Cellar/libxml2/ --use-system-libraries | |
# checking if the C compiler accepts ... yes | |
# checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no | |
# Building nokogiri using system libraries. | |
# ERROR: cannot discover where libxml2 is located on your system. please make sure `pkg-config` is installed. | |
# *** extconf.rb failed *** |