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 -*- | |
| """ | |
| codegen | |
| ~~~~~~~ | |
| Extension to ast that allow ast -> python code generation. | |
| :copyright: Copyright 2008 by Armin Ronacher. | |
| :license: BSD. | |
| """ |
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 <cstdlib> | |
| #include <iostream> | |
| #include <cmath> | |
| using namespace std; | |
| int checkCompletion(int pos[3][3]); | |
| int dist(int num, int x, int y); | |
| int bestTile(int tiles[3][3], int & x, int & y); | |
| void printBoard(int tiles[3][3]); |
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 completion(board): | |
| "Returns a score of how far the board is from completion" | |
| total = 0 | |
| for pos in range(9): | |
| i, j = pos // 3, pos % 3 | |
| val = board[i][j] - 1 | |
| if val < 0: continue | |
| v1, v2 = val % 3 - j, val / 3 - i | |
| total += (v1 if v1 > 0 else -1 * v1) + (v2 if v2 > 0 else -1 * v2) | |
| return total |
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
| Public Class frmDvd | |
| Private myParent As frmMain | |
| Private Sub frmCustomer_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated | |
| Dim idx As Integer | |
| Dim panel As ToolStripStatusLabel | |
| idx = myParent.searchForPanel("DVDs") | |
| If idx <> -1 Then |
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 quantumify(evaluator, answers): | |
| quantum_value = evaluator() | |
| if any(map(lambda a: a in quantum_value, answers)): | |
| pass | |
| return "BOTH" |
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 gen(data): | |
| def g(): | |
| for token in data.split(" "): | |
| yield token | |
| return g().next | |
| defs = {"+": lambda x, y: x + y, | |
| "-": lambda x, y: x - y, | |
| "*": lambda x, y: x * y, |
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 irc = require('irc'); | |
| var client = new irc.Client('irc.mozilla.org', 'hugbot', { | |
| channels: ['#amo', '#webdev', '#interns'], | |
| }); | |
| huggable = {}; | |
| hugdelay = {}; | |
| function contains(message, list) { | |
| for(var i=0;i<list.length;i++) { |
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 reduce(a, b): | |
| return "%s\n%s" % (a, b) |
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 log_gen(n): | |
| import math | |
| y = 1 | |
| while y < n: | |
| adder = max(1, 10 ^^ int(math.log10(y))) | |
| yield int(y) | |
| y += adder |
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 argv = ['damper.js', '--host', '0.0.0.0', '--port', '8675']; | |
| var opts = argv.slice(1); | |
| function options(opts, defaults) { | |
| var out = defaults || {}, last; | |
| for(var i = 0; i < opts.length; i++) { | |
| var is_flag = opts[i].substr(0, 1) === '-'; | |
| if (is_flag && last) { | |
| out[last] = true; | |
| } else if (!is_flag && last) { |
OlderNewer