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
| ################################################################################ | |
| # Making custom named pipes | |
| ################################################################################ | |
| Open two ssh sessions to a system. In one, create your pipe and then send some command output to it. | |
| $ mkfifo mypipe | |
| $ cal > mypipe | |
| Don’t worry that your command just seems to hang. | |
| In the other, read from the pipe. |
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
| ################################################################################ | |
| # Calculate Pixels Per Inch | |
| ################################################################################ | |
| # Calculate w/ the Horizontal x Vertical resolution, Horizontal & Vertical size | |
| ################################################################################ | |
| Horizontal_Resolution = 2560 | |
| Vertical_Resolution = 1440 | |
| Horizontal_Size_MM = 597.89 | |
| Vertical_Size_MM = 336.31 |
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
| Cache is a net benefit in perf if time saved in cache hits exceeds time lost in cache overhead. | |
| L = Regular lookup | |
| H = Cache Hit | |
| M = Cache Miss | |
| R = Cache Hit Ratio (500 lookups/100 served from cache is 20%) | |
| H x R + M x (1 - R) < L |
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
| ;; Installation on Mac OS X | |
| ;; After downloading and installing into applications folder run the following commands from the terminal | |
| ;; sudo ln -s /Applications/MIT\:GNU\ Scheme.app/Contents/Resources /usr/local/lib/mit-scheme-x86-64 | |
| ;; sudo ln -s /usr/local/lib/mit-scheme-x86-64/mit-scheme /usr/bin/scheme | |
| ;; To Launch simply type "scheme" in the terminal | |
| ;; Using operators on operands (Scheme uses prefix notation) | |
| (+ 4 4) ; Add 4 + 4 = 8 | |
| ;; Add two numbers that are multiplied |
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
| RAM, random access memory, is the ability to store/read values based on address inputs | |
| (versus say sequentially). It is also commonly referred to as voltile memory because it | |
| requires a constant supply of electricity to retain its contents. | |
| The number of values that a RAM array can store is based on the number of address inputs. | |
| With 1 address input we can store 2 values (0 or 1). | |
| 2 addresses = 4 values (00, 01, 10, 11) | |
| 3 addresses = 8 values (000, 001, 010, 100, 011, 101, 110, 111) | |
| 4 addresses = 16 values |
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
| # Measure complexity as a function of input size | |
| # - Worst case scenario | |
| # - Largest factor in expression | |
| # Asymptotic Notation - provide a formal way to talk about the relationship between | |
| # the running time of an algorithm and the size of inputs. | |
| # | |
| # Asymptotic notation describes the complexity of an algorithm as the size of it's | |
| # inputs approaches infinity |
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
| # Server Side | |
| from SimpleXMLRPCServer import SimpleXMLRPCServer | |
| def file_reader(file_name): | |
| with open(file_name, 'r') as f: | |
| return f.read() | |
| server = SimpleXMLRPCServer(('localhost', 8000)) | |
| server.register_introspection_functions() |
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
| >>> import json | |
| >>> print(json.dumps(data)) # No indention | |
| {"status": "OK", "count": 2, "results": [{"age": 27, "name": "Oz", "lactose_intolerant": true}, {"age": 29, "name": "Joe", "lactose_intolerant": false}]} | |
| >>> print(json.dumps(data, indent=2)) # With indention | |
| { | |
| "status": "OK", | |
| "count": 2, | |
| "results": [ | |
| { | |
| "age": 27, |
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
| #!/usr/bin/env python | |
| # | |
| # Python Timer Class - Context Manager for Timing Code Blocks | |
| # Corey Goldberg - 2012 | |
| # | |
| from timeit import default_timer | |
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
| So what is a prime number anyway. Lets see what Wikipedia has to say: | |
| A prime number (or a prime) is a natural number greater than 1 that has no positive divisors other than 1 and itself. A natural number greater than 1 that is not a prime number is called a composite number. For example, 5 is prime, as only 1 and 5 divide it, whereas 6 is composite, since it has the divisors 2 and 3 in addition to 1 and 6. The fundamental theorem of arithmetic establishes the central role of primes in number theory: any integer greater than 1 can be expressed as a product of primes that is unique up to ordering. This theorem requires excluding 1 as a prime. | |
| Since there are infintely number of primes, it's always fun to see how fast and how many we can find. The largest know prime number has nearly 13 million decimal digits! | |
| Now thats out of the way lets see how we can test to see whether a number is prime or not using Powershell. Today we will look at a few different methods, including my favorite, Sieve of Eratosthenes. |
OlderNewer