This file contains hidden or 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
# First the server | |
#!/usr/bin/env python | |
#!/usr/bin/env python | |
""" | |
A basic, multiclient 'chat server' using Python's select module | |
with interrupt handling. | |
Entering any line of input at the terminal will exit the server. |
This file contains hidden or 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
/* | |
Copyright 2014 Google Inc. All rights reserved. | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, software |
This file contains hidden or 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
(LET ((server (SOCKET:SOCKET-SERVER))) | |
(FORMAT t "~&Waiting for a connection on ~S:~D~%" | |
(SOCKET:SOCKET-SERVER-HOST server) (SOCKET:SOCKET-SERVER-PORT server)) | |
(UNWIND-PROTECT | |
;; infinite loop, terminate with Control+C | |
(LOOP (WITH-OPEN-STREAM (socket (SOCKET:SOCKET-ACCEPT server)) | |
(MULTIPLE-VALUE-BIND (local-host local-port) (SOCKET:SOCKET-STREAM-LOCAL socket) | |
(MULTIPLE-VALUE-BIND (remote-host remote-port) (SOCKET:SOCKET-STREAM-PEER socket) | |
(FORMAT T "~&Connection: ~S:~D -- ~S:~D~%" | |
remote-host remote-port local-host local-port))) |
This file contains hidden or 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 ( | |
"net/http" | |
"fmt" | |
"html" | |
"regexp" | |
"log" | |
"os" | |
"time" |
This file contains hidden or 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
#generate CA self-signed certificate | |
openssl genrsa -out private\ca.key -rand private\.rnd -des 2048 | |
openssl req -new -x509 -days 3650 -key private\ca.key -out private\ca.crt -config openssl.cnf | |
openssl x509 -in private\ca.crt -noout -text | |
#generate server certificate | |
openssl genrsa -out private\server.key 1024 | |
openssl req -new -key private\server.key -out newcerts\server.csr -config openssl.cnf | |
openssl ca -in newcerts\server.csr -cert private\ca.crt -keyfile private\ca.key | |
-config openssl.cnf -policy policy_anything -out certs\server.crt |
This file contains hidden or 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
Graphics File Formats | |
This topic describes the graphics-file formats used by the Microsoft Windows | |
operating system. Graphics files include bitmap files, icon-resource files, | |
and cursor-resource files. | |
Bitmap-File Formats | |
Windows bitmap files are stored in a device-independent bitmap (DIB) format | |
that allows Windows to display the bitmap on any type of display device. The |
This file contains hidden or 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
(defun reproduce (population) | |
(let ((offspring nil) | |
(d (distribution population))) | |
(dotimes (i (/ (length population) 2)) | |
(let ((x (selectone d)) | |
(y (selectone d))) | |
(crossover x y) | |
(setq offspring (nconc (list x y) offspring)))) | |
offspring)) |
This file contains hidden or 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 code in this file was mechanically extracted from the TeX | |
; source files of _Ansi Common Lisp_, except for bst-remove and | |
; bst-delete and their subroutines, which replace broken versions | |
; in the book. | |
; If you have questions or comments about this code, or you want | |
; something I didn't include, send mail to [email protected]. | |
; This code is copyright 1995 by Paul Graham, but anyone who wants | |
; to use it is free to do so. |
This file contains hidden or 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 ( | |
"log" | |
"net/http" | |
"os" | |
) | |
func Log(handler http.Handler) http.Handler { | |
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
This file contains hidden or 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 | |
-------------------------- | |
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 |
OlderNewer