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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <script src="http://code.jquery.com/jquery-2.1.1.min.js"></script> | |
| </head> | |
| <body> | |
| Limit: <input id="num"> <button>Show</button> | |
| <ul id="melons"> |
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
| class Node: | |
| def __init__(self, data, children=None): | |
| self.data = data | |
| self.children = children or [] | |
| def find(self, data): | |
| for i in self.descendants(): | |
| if i.data == data: | |
| return i | |
| def descendants(self): | |
| yield self |
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
| /** | |
| * Demonstrate types of strings & mutability & storage | |
| * | |
| * Joel Burton <joel@joelburton.com> | |
| **/ | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> |
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
| void insertNode(TreeNode **root, COMPARE compare, void* data) { | |
| TreeNode *node = (TreeNode*) malloc(sizeof(TreeNode)); | |
| node->data = data; | |
| node->left = NULL; | |
| node->right = NULL; | |
| if (*root == NULL) { | |
| *root = node; | |
| return; | |
| } |
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
| /* C Declaration explainer. | |
| * | |
| * Reads a C declaration from standard input and explains what it means. | |
| * | |
| * For example: | |
| * | |
| * $ echo "char *stuff[]" | this_program | |
| * stuff is an array of pointer to char | |
| * | |
| * Adapted from Peter van der Linden's "Expert C Programming". |
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
| __version__ = "1.0" | |
| class Cat(object): | |
| def __init__(self): | |
| print "making cat" | |
| print "see?", type(self) | |
| self.name = "fluffy" | |
| def __add__(self, other): | |
| if not type(other) == Cat: |
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
| """Evil Hangman. | |
| Hangman, except avoid choosing a real word and, on a letter guess, reduce | |
| the set of possible words to the set that gives the player as little | |
| advantage as possible. | |
| """ | |
| import random, collections | |
| word_len = int(input("what length word do you want (2-20) [6]") or 6) |
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 sys | |
| from cStringIO import StringIO | |
| class fake_input(object): | |
| def __init__(self, *args): | |
| text = "\n".join(args) + "\n" | |
| self.stdin = sys.stdin | |
| self.input = StringIO(text) | |
| def __enter__(self): | |
| sys.stdin = self.input |
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
| """Console-based guess-the-secret-word game.""" | |
| import cmd | |
| import random | |
| class WordGuess(cmd.Cmd): | |
| """REPL for a guess-the-secret-word game.""" | |
| prompt = "\nWordGuess > " | |
| intro = "Guess the secret word! (Control-D quits)" |
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
| @app.route("/movies/ajax/<int:movie_id>", methods=['POST']) | |
| def movie_detail_ajax_process(movie_id): | |
| """Add/edit a rating.""" | |
| # Get form variables | |
| score = int(request.form["score"]) | |
| user_id = session.get("user_id") | |
| if not user_id: |
OlderNewer