Skip to content

Instantly share code, notes, and snippets.

View jdavis's full-sized avatar
💾

Josh Davis jdavis

💾
View GitHub Profile
@jdavis
jdavis / ternary.c
Created April 11, 2013 05:18
Code sample showing the wonkiness of the precedence of the ternary statement in C.
#include <stdio.h>
char identity(char x);
int main(int argc, const char *argv[]) {
int compound;
printf("For reference:\n");
printf(" the ASCII value of %c is %d\n", ';', ';');
printf(" the ASCII value of %c is %d\n", '}', '}');
@jdavis
jdavis / solution.pdf
Last active December 14, 2015 21:49
Homework #4 for Computer Science 331 - Theory of Computing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jdavis
jdavis / open_port.py
Created November 8, 2012 17:26
Find an open port in Python.
import socket
def find_open_port():
"""
Use socket's built in ability to find an open port.
"""
sock = socket.socket()
sock.bind(('', 0))