It's now here, in The Programmer's Compendium. The content is the same as before, but being part of the compendium means that it's actively maintained.
🤦♂️
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
Mute these words in your settings here: https://twitter.com/settings/muted_keywords | |
ActivityTweet | |
generic_activity_highlights | |
generic_activity_momentsbreaking | |
RankedOrganicTweet | |
suggest_activity | |
suggest_activity_feed | |
suggest_activity_highlights | |
suggest_activity_tweet |
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 warnings | |
from collections import ( | |
Counter, MutableMapping, OrderedDict, deque, | |
) | |
from datetime import timedelta | |
from tornado import gen | |
from tornado.ioloop import IOLoop, PeriodicCallback | |
class ExpiringCounter(MutableMapping): |
The official AWS command line tools, have support for configuration profiles. See Configuring the AWS Command Line Interface - Named Profiles.
Managing multiple profiles with the AWS CLI itself is relatively straight forward, switching between them with --profile
flag on the command line or the AWS_PROFILE
environment variable.
These helpers extend that functionality for convenience with other tools in the ecosystem.
This is a small demo of how to create a library in Rust and call it from Python (both CPython and PyPy) using the CFFI instead of ctypes
.
Based on http://harkablog.com/calling-rust-from-c-and-python.html (dead) which used ctypes
CFFI is nice because:
- Reads C declarations (parses headers)
- Works in both CPython and PyPy (included with PyPy)
- Lower call overhead than
ctypes
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
"""Demo of streaming requests with Tornado. | |
This script features a client using AsyncHTTPClient's body_producer | |
feature to slowly produce a large request body, and two server | |
handlers to receive this body (one is a proxy that forwards to the | |
other, also using body_producer). | |
It also demonstrates flow control: if --client_delay is smaller than | |
--server_delay, the client will eventually be suspended to allow the | |
server to catch up. You can see this in the logs, as the "client |
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
CREATE OR REPLACE FUNCTION public.json_append(data json, insert_data json) | |
RETURNS json | |
IMMUTABLE | |
LANGUAGE sql | |
AS $$ | |
SELECT ('{'||string_agg(to_json(key)||':'||value, ',')||'}')::json | |
FROM ( | |
SELECT * FROM json_each(data) | |
UNION ALL | |
SELECT * FROM json_each(insert_data) |
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
# The following are suggested values | |
# They should be set in all configs, | |
# so that if a secondary needs to be promoted | |
# it will be generating the correct WAL level | |
wal_level = hot_standby | |
archive_mode = on # allows archiving to be done | |
# (change requires restart) | |
archive_command = 'cp -f %p /data/pgsql/archive/%f </dev/null' # command to use to archive a logfile segment | |
max_wal_senders = 5 # max number of walsender processes | |
# (change requires restart) |
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 __name__ == '__main__': | |
import sys | |
import chunkypushproducer | |
raise SystemExit(chunkypushproducer.main(sys.argv)) | |
from zope.interface import implementer | |
from twisted.internet.interfaces import IPushProducer | |
from twisted.internet.task import react, deferLater, cooperate | |
from twisted.internet.protocol import Protocol |
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
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
NewerOlder