Quantcast
Channel: User Armin Ronacher - Stack Overflow
Browsing latest articles
Browse All 43 View Live

Comment by Armin Ronacher on How is an OpenID Client supposed look up the...

As I said. The HTML spec does not require it. You can check it yourself with a validator. The head section is implicit. It basically means that a <link> / <meta> tag can only appear inside...

View Article



Comment by Armin Ronacher on Multiple Internet Explorer instances on one machine

Afair that one does not work on Vista.

View Article

Comment by Armin Ronacher on How do I get monotonic time durations in python?

@Thomas: fixed that, removed the self @Kiv: byref should work, can't test that right now, but it should do the trick. I don't remember when byref() does not work, so i went the safe path here.

View Article

Comment by Armin Ronacher on Vim file navigation

It does not recurse into subfolders, no. But I adapted my workflow to that. Also once the file i open, i can just mention the name of the buffer and am fine. You can tell Vim to remember the open...

View Article

Comment by Armin Ronacher on Setting Position of NSWindow before Display

Indeed, that was causing that problem. Thanks

View Article


Comment by Armin Ronacher on Hidden features of Python

You can still do object.__reduce_ex__(p, 2)[2][1] then.

View Article

Comment by Armin Ronacher on Jinja2 compile extension after includes

Not sure I understand. I think if you want to continue go down that road, the Environment callback functions for streaming and pre/postprocessing are probably more of a help than the actual compiler...

View Article

Comment by Armin Ronacher on How can I override the HTTP methods for PUT and...

There is not as middlewares are operating on the WSGI layer. You can however let the middleware perform some basic path checks.

View Article


Comment by Armin Ronacher on Can a Jinja variable's scope extend beyond in an...

> Solution provided below. I am still curious why the suggestions above do not work though. Does anyone know for sure that they were deprecated? They were removed because it's not possible in...

View Article


Comment by Armin Ronacher on How can I securely pass an arbitrarily deep path...

That's your browser resolving the path. By itself the path converter does not sanitize the path. See my answer below for the proper solution for that problem.

View Article

Comment by Armin Ronacher on Scala: Iterate over CSV files in a functional way?

Funny story: that's like one of the two use cases of namedtuple's ability to accept filed names as comma separated string. So just drop the split :)

View Article

Comment by Armin Ronacher on Debugging a Flask app running in Gunicorn

That's the right answer. By default Flask runs in production mode where it does not report errors. For handling errors in production mode you want to have a look at this:...

View Article

Comment by Armin Ronacher on Python program hangs forever when called from...

The problem is not the lack of collection but the fact that it hangs. I assume what's happening is that it runs into issues on the interpreter shutdown.

View Article


Comment by Armin Ronacher on Lektor CMS how to get related objects of a model...

There is currently no automatic mapping of values to queries/models so this is kinda the documented way :)

View Article

Comment by Armin Ronacher on Error while deploying a lektor project to hithub...

Just run the installation script again.

View Article


Answer by Armin Ronacher for Dynamically add URL rules to Flask app

Every time you execute add_url_rule() the internal routing remaps the URL map. This is neither threadsafe nor fast. I right now don't understand why you need user specific URL rules to be honest. It...

View Article

Answer by Armin Ronacher for Access a static variable by $var::$reference

For calling static members you can use a code like this:call_user_func("MyClass::my_static_method");// orcall_user_func(array("MyClass", "my_static_method"));Unfortunately the only way to get static...

View Article


Answer by Armin Ronacher for Python itertools.combinations() memory problems

Combinations creates a pool by consuming the whole iterator provided. There is no way around that. See the pseudocode in the docs for the function:...

View Article

Answer by Armin Ronacher for Purpose of "let expression" (LetExpr) in the...

Generally speaking, why does it exist?It exists for autoboxing as Google suggests.If you have code like this:Integer foo = 0;foo++;Java internally makes this into this helper expression:Integer foo =...

View Article

Answer by Armin Ronacher for Werkzeug response too slow

The answer to that is pretty simple:x.read()<- reads the whole file into memory, inefficientsetting response to a file: very inefficient as the protocol for that object is an iterator. So you will...

View Article

Answer by Armin Ronacher for Is there a way to make Flask more verbose?

Error handling is off by default in production mode at the moment and can be set up here: http://flask.pocoo.org/docs/errorhandling/

View Article


Answer by Armin Ronacher for Flask 0.10 giving unicode error on session cookie

That's currently an issue with Flask-Login. As far as I know it's fixed in the git version of the extension.

View Article


Pixel Perfect Collision Detection in HTML5 Canvas

I want to check a collision between two Sprites in HTML5 canvas. So for the sake of the discussion, let's assume that both sprites are IMG objects and a collision means that the alpha channel is not 0....

View Article

Answer by Armin Ronacher for How do I use timezones with a datetime object in...

I recommend babel and pytz when working with timezones. Keep your internal datetime objects naive and in UTC and convert to your timezone for formatting only. The reason why you probably want naive...

View Article

Answer by Armin Ronacher for Does Flask support regular expressions in its...

You can hook in custom converters that match for arbitrary expressions: Custom Converterfrom random import randrangefrom werkzeug.routing import Rule, Map, BaseConverter, ValidationErrorclass...

View Article


What's the Name of the Python Module that Formats arbitrary Text to nicely...

A while ago I came across a Python library that formats regular text to HTML similar to Markdown, reStructuredText and Textile, just that it had no syntax at all. It detected indentatations, quotes,...

View Article

Plugin Development for Lektor

I am trying to develop a reStructuredText plugin and doing some basic mistake.My plugin object looks like this:class RSTPlugin(Plugin): name = 'RST' description = 'RST plugin' def on_setup_env(self,...

View Article

Answer by Armin Ronacher for Plugin Development for Lektor

This is a question that come up in the Lektor issue tracker: https://github.com/lektor/lektor/issues/77The answer is that Lektor does not use Jinja filters for field types. Instead one has to implement...

View Article

Answer by Armin Ronacher for Lektor installation fails on MacBookPro OS X 10.6.8

Most likely your version of OS X is too old to support the installation of watchdog with the version of gcc you have. If you cannot upgrade your OS X installation then I recommend installing a recent...

View Article



Answer by Armin Ronacher for php: output[] w/ join vs $output .=

If joined with implode() or join(), PHP is able to better optimize that. It goes through all strings in your list, calculates the length and allocates the required space and fills the space. In...

View Article

Answer by Armin Ronacher for Reverse proxy for Lektor CMS

The development server is not intended to be used for production. The production deployments are based on entirely static content and will resolve static assets correctly if you use the |url filter.

View Article

Answer by Armin Ronacher for My language switcher does not work only from the...

In Lektor versions < 2 there are some limitations with regards to the alts. This is working correctly in Lektor 2 which is currently in development only. But you can install it from the git master...

View Article

Answer by Armin Ronacher for Lektor: No Admin for flow fields

Currently the admin responds really badly to misconfiguration. Usually it just dies with an error you can see in the console window. Most likely the flow block itself does not exist or has a bug in it....

View Article


Answer by Armin Ronacher for Lektor Pagination - TemplateSyntaxError:...

If you are using Lektor 1 (currently released version) syntax errors are sometimes cached unfortunately. Clear the lektor cache to see if that solves the issue (you can do that with lektor clean.

View Article

Answer by Armin Ronacher for Why is assetsDir missing in...

From what I can tell 25.0.0 changes from gradle-core 1.3.1 to gradle-core 2.3.0 and that appears to be a completely different system.This is the old task:...

View Article

LLDB: Execute a python callback after target create to inject symbols

I'm trying to execute a python function after target create so I can iterate over all modules of the target, download missing symbols from the internet (based on GetUUIDString) and then override the...

View Article


Answer by Armin Ronacher for How can I normalize a URL in python

Have a look at this module: werkzeug.utils. (now in werkzeug.urls)The function you are looking for is called "url_fix" and works like this:>>> from werkzeug.urls import url_fix>>>...

View Article


POSIX Async Safety Linter for C/C++

I'm trying to understand if there are some simple ways to add some basic lints for async safety into a codebase. The idea was to keep a list of safe functions to call somewhere and then use clang...

View Article

Answer by Armin Ronacher for Passing HTML to template using Flask/Jinja2

MarkupSafe provides Jinja's autoescaping behavior. You can import Markup and use it to declare a value HTML safe from the code:from markupsafe import Markupvalue = Markup('<strong>The HTML...

View Article

Class to Instance Registry Typing in TypeScript

I'm trying to use classes as input values to a registry method where the return value is a cached instance of that instance. However I do not find a way to make this type safe.What I want is something...

View Article

Display DIV at Cursor Position in Textarea [duplicate]

For a project of mine I would love to provide auto completion for a specific textarea. Similar to how intellisense/omnicomplete works. For that however I have to find out the absolute cursor position...

View Article


Answer by Armin Ronacher for How to convert date to timestamp in PHP?

There is also strptime() which expects exactly one format:$a = strptime('22-09-2008', '%d-%m-%Y');$timestamp = mktime(0, 0, 0, $a['tm_mon']+1, $a['tm_mday'], $a['tm_year']+1900);Warnings:This function...

View Article

Get last n lines of a file, similar to tail

I'm writing a log file viewer for a web application and for that I want to paginate through the lines of the log file. The items in the file are line based with the newest item at the bottom.So I need...

View Article

Browsing latest articles
Browse All 43 View Live




Latest Images