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
| def trace_calls(frame, event, arg): | |
| if event != 'call': | |
| return | |
| co = frame.f_code | |
| func_name = co.co_name | |
| if func_name == 'write': | |
| # Ignore write() calls from print statements | |
| return | |
| func_line_no = frame.f_lineno | |
| func_filename = co.co_filename |
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
| var Anchors = document.getElementsByTagName("a"); | |
| for (var i = 0; i < Anchors.length ; i++) { | |
| Anchors[i].addEventListener("click", | |
| function (event) { | |
| event.preventDefault(); | |
| if (confirm('Are you sure?')) { | |
| window.location = this.href; | |
| } | |
| }, |
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
| /** | |
| * Implementation example of writable response bodies. | |
| * Based on the draft of the Streams API (19 March 2014) | |
| * https://dvcs.w3.org/hg/streams-api/raw-file/tip/Overview.htm | |
| * Design document for response body reading/writing: | |
| * https://docs.google.com/document/d/1iE6M-YSmPtMOsec7pR-ILWveQie8JQQXTm15JKEcUT8 | |
| */ | |
| /* globals chrome, ByteStream, URL, XMLHttpRequest */ | |
| 'use strict'; |
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
| ; Sample supervisor config file. | |
| [unix_http_server] | |
| file=/tmp/supervisor.sock ; (the path to the socket file) | |
| ;chmod=0700 ; sockef file mode (default 0700) | |
| ;chown=nobody:nogroup ; socket file uid:gid owner | |
| ;username=user ; (default is no username (open server)) | |
| ;password=123 ; (default is no password (open server)) | |
| ;[inet_http_server] ; inet (TCP) server disabled by default |
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
| # coding: utf-8 | |
| # In[196]: | |
| import timeit | |
| # In[197]: |
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
| def get_open_port(): | |
| import socket | |
| s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
| s.bind(("", 0)) | |
| s.listen(1) | |
| port = s.getsockname()[1] | |
| s.close() | |
| return 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
| from IPython.core.display import Image as image | |
| from PIL import Image | |
| def save_and_display(arr, fname): | |
| pilimg = Image.fromarray(arr) | |
| pilimg.save(fname) | |
| return image(filename=fname, width=600) |
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
| tail -f /tmp/tty.LightBlue-Bean | gawk '{ print strftime("%Y-%m-%d %H:%M:%S"), $0; fflush(); }' |
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
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
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
| #!/bin/sh | |
| # | |
| # Author: D. Lee | |
| # | |
| # | |
| # Assume the input file has a format as follows: | |
| # XXXXX ID URL YYYYY | |
| # |