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
| socktactoe [master *+]\ ⚲git status | |
| # On branch master | |
| # Changes to be committed: | |
| # (use "git reset HEAD <file>..." to unstage) | |
| # | |
| # modified: multi_tictactoe.py | |
| # modified: socktactoe_server.py | |
| # | |
| # Changes not staged for commit: | |
| # (use "git add <file>..." to update what will be committed) |
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
| Traceback (most recent call last): | |
| File "minimal_pdb_traceback.py", line 7, in <module> | |
| y = "line of code not triggering an error" | |
| AssertionError |
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
| To dissect the behavior of this server and client, I need two things: more realistic network latency than is produced by making connections directly to localhost, and some way to see a microsecond-bymicrosecond report on what the client and server are doing. | |
| These two goals may initially seem impossible to reconcile. If I run the client and server on the same machine, the network latency will not be realistic. But if I run them on separate servers, then any timestamps that I print will not necessarily agree because of slight differences between the machines’ clocks. | |
| My solution is to run the client and server on a single machine (my Ubuntu laptop, in case you are curious) but to send the connection through a round-trip to another machine (my Ubuntu desktop) by way of an SSH tunnel. See Chapter 16 and the SSH documentation itself for more information about tunnels. The idea is that SSH will open local port 1061 here on my laptop and start accepting connections from clients. Each connection will then be for |
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
| alias git=hub | |
| [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function* | |
| if [ -f $(brew --prefix)/etc/bash_completion ]; then | |
| . $(brew --prefix)/etc/bash_completion | |
| fi | |
| GIT_PS1_SHOWDIRTYSTATE=true | |
| GIT_PS1_SHOWSTASHSTATE=true |
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
| for attr in dir(obj): | |
| code = 'obj.' + attr | |
| print attr, eval(code) | |
| for attr in [x for x in dir(obj) if not callable(getattr(obj, x))]: | |
| code = 'obj.' + attr | |
| print attr, eval(code) |
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
| >>>a = '%s' | |
| >>>a %= 1 # equivalently, a = a % 1 | |
| >>>a == '1' | |
| True | |
| # A more clear version | |
| >>> f = '%s' % 1 | |
| >>> f | |
| '1' |
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
| #include <stdio.h> | |
| #include <stdlib.h> | |
| void quicksort(int *array, int length); | |
| void swap(int *a, int *b); | |
| void print(int *array, int length); | |
| int main() |
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
| #include <stdio.h> | |
| #include <stdlib.h> | |
| void quicksort(int *array, int length); | |
| void swap(int *a, int *b); | |
| void print(int *array, int length); | |
| int main() |
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
| for (int i=0; i<15; i++) | |
| { | |
| int c = rand(); | |
| printf("%d\n", c); | |
| } |
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
| # include <stdlib.h> | |
| # include <stdio.h> | |
| int main() | |
| { | |
| int myarray[10] = {100,4,'c','d','e','f','g','h','i','j'}; | |
| int *a_goddamn_pointer; | |
| int x, y, z, w; | |
| a_goddamn_pointer = &myarray; |