Skip to content

Instantly share code, notes, and snippets.

#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;
// Why this?
operandPos += 2;
value = (uint)(short)image.ReadInt16(operandPos - 2);
// Why not this instead?
value = (uint)(short)image.ReadInt16(operandPos);
operandPos += 2;
# 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."
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 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"))
# 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):
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]
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
[server:main]
use = egg:Paste#http
host = 127.0.0.1
port = 9999
[filter-app:main]
use = egg:Paste#evalerror
next = filter
[app:filter]