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 <stdint.h> | |
| #include <inttypes.h> | |
| int main(void) | |
| { | |
| uint32_t a = UINT32_MAX - 10; | |
| printf("%" PRIi32 "\n", a); | |
| printf("%" PRIu32 "\n", a); | |
| int32_t b = (int32_t) a; |
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
| // Why this? | |
| operandPos += 2; | |
| value = (uint)(short)image.ReadInt16(operandPos - 2); | |
| // Why not this instead? | |
| value = (uint)(short)image.ReadInt16(operandPos); | |
| operandPos += 2; |
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
| # Please note, this is a simplified example that ignores | |
| # the function parameters. In practice, you should use | |
| # the decorator module or another method of maintaining | |
| # method signatures. | |
| def mydecorator(f): | |
| print "It would not be safe to use the session here." | |
| def decorated(): | |
| print "It would be safe to use the session here." | |
| return f() | |
| print "Once more, it would not be safe to use the session here." |
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 chefs = {}; | |
| var chefCount = 0; | |
| var wordFinder = /\w+/g; | |
| var chefCountPrefName = "bork.chefCount"; | |
| function chefPrefName(n) { | |
| return "bork.chef[" + n + "]"; | |
| } | |
| // called on load and reload | |
| function load( scriptFilePath ) { |
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
| ;; This code is licensed under the "X11 license". Copyright 2010 by Jon Rosebaugh. | |
| (defpackage :cl-bcrypt | |
| (:export :encode :check) | |
| (:use :common-lisp :cffi)) | |
| (in-package :cl-bcrypt) | |
| (define-foreign-library libbcrypt | |
| (:unix (:or "libbcrypt.so.1.0.4" "libbcrypt.so.1" "libbcrypt.so")) |
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
| # you may need to use the foreign_keys or primaryjoin arguments on the relationship | |
| class Door(Base): | |
| __tablename__ = "doors" | |
| locked = Column(Boolean) | |
| side_a_id = Column(Integer, ForeignKey("rooms.id"), nullable=False) | |
| side_a = relationship(Room) | |
| side_b_id = Column(Integer, ForeignKey("rooms.id"), nullable=False) | |
| side_b = relationship(Room) | |
| class Room(Base): |
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 inspect | |
| def restrict(**parameters): | |
| def wrapper(func, self, *args, **kwargs): | |
| spec = inspect.getargspec(func) | |
| # since we're assuming self will be the first argument, just take it out here | |
| args_spec = spec.args | |
| args_spec.pop(0) | |
| copy_kwargs = kwargs.copy() | |
| for arg_pair in zip(args_spec, args): | |
| copy_kwargs[arg_pair[0]] = arg_pair[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
| class rewrite(object): | |
| def __init__(self, real_app): | |
| self.real_app = real_app | |
| def __call__(self, environ, start_response): | |
| if environ.get('PATH_INFO', '') == 'old_url': | |
| environ['PATH_INFO'] = 'new_url' | |
| return self.real_app(environ, start_response) | |
| from myapp import wsgi_app | |
| from myserver import serve |
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:main] | |
| use = egg:Paste#http | |
| host = 127.0.0.1 | |
| port = 9999 | |
| [filter-app:main] | |
| use = egg:Paste#evalerror | |
| next = filter | |
| [app:filter] |