About twenty years ago Jobs and Wozniak, the founders of Apple, came up with the very strange idea of selling information processing machines for use in the home. The business took off, and its founders made a lot of money and received the credit they deserved for being daring visionaries. But around the same time, Bill Gates and Paul Allen came up with an idea even stranger and more fantastical: selling computer operating systems. This was much weirder than the idea of Jobs and Wozniak. A computer at least had some sort of physical reality to it. It came in a box, you could open it up and plug it in and watch lights blink. An operating system had no tangible incarnation at all. It arrived on a disk, of course, but the disk was, in effect, nothing more than the box that the OS came in. The product itself was a very long string of ones and zeroes that, when properly installed and coddled, gave you the ability to manipulate other very long strings of ones and zeroes. Even those few who actually understood what
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
http://eloquentjavascript.net/index.html | |
http://eloquentjavascript.net/00_intro.html | |
http://eloquentjavascript.net/01_values.html | |
http://eloquentjavascript.net/02_program_structure.html | |
http://eloquentjavascript.net/03_functions.html | |
http://eloquentjavascript.net/04_data.html | |
http://eloquentjavascript.net/05_higher_order.html | |
http://eloquentjavascript.net/06_object.html | |
http://eloquentjavascript.net/07_elife.html | |
http://eloquentjavascript.net/08_error.html |
CREATE VIEW blocking_processes AS
SELECT
pg_locks2.pid as blocking_pid,
ka.usename as blocking_user,
ka.query as blocking_query,
pg_locks1.pid as blocked_pid,
psa.usename as blocked_user,
psa.query as blocked_query,
to_char(age(now(), psa.query_start),'HH24h:MIm:SSs') as age
SELECT
table_name,
pg_size_pretty(table_size) AS table_size,
pg_size_pretty(indexes_size) AS indexes_size,
pg_size_pretty(total_size) AS total_size
FROM (
SELECT
table_name,
pg_table_size(table_name) AS table_size,
given a database named db:
SELECT pg_terminate_backend(pid)
FROM pg_stat_activity
WHERE datname='db'
AND state = 'idle in transaction'
SELECT pg_terminate_backend(pid)
FROM pg_stat_activity
WHERE pid <> pg_backend_pid()
AND state = 'idle'
AND state_change < current_timestamp - INTERVAL '5' MINUTE;
for k in $(git branch | sed /\*/d); do
if [ -n "$(git log -1 --since='12 week ago' -s $k)" ]; then
git branch -D $k
fi
done
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 multiprocessing, threading, logging, sys, traceback | |
class MultiProcessingLog(logging.Handler): | |
def __init__(self, name, mode='w', maxsize=0, rotate=0): | |
logging.Handler.__init__(self) | |
self._handler = logging.handlers.RotatingFileHandler(name, mode, maxsize, rotate, encoding='utf-8') | |
self.queue = multiprocessing.Queue(-1) | |
t = threading.Thread(target=self.receive) |
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
# Author: Pieter Noordhuis | |
# Description: Simple demo to showcase Redis PubSub with EventMachine | |
# | |
# Update 7 Oct 2010: | |
# - This example does *not* appear to work with Chrome >=6.0. Apparently, | |
# the WebSocket protocol implementation in the cramp gem does not work | |
# well with Chrome's (newer) WebSocket implementation. | |
# | |
# Requirements: | |
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby |
Following example class shows how to use boto3 to upload files to s3 using a programmable configuration
from uuid import uuid1
import boto3
from botocore.client import Config
from boto3.session import Session
class S3Storage(object):
OlderNewer