Practical threaded programming with Python. Introduction The Global Interpretor Lock refers to the fact that the Python interpreter is not thread safe. There is a global lock that the current thread holds to safely access Python objects. Because only one thread can aquire Python Objects/C API, the interpreter regularly releases and reacquires the lock every 100 bytecode of instructions. The frequency at which the interpreter checks for thread switching is controlled by the sys.setcheckinterval() function. In addition, the lock is released and reacquired around potentially blocking I/O operations. Please see Gil and Threading State and Threading the Global Interpreter Lock in the resources section for more details.
It is important to note that, because of the GIL, the CPU-bound applications won’t be helped by threads. With Python, there is no shortage of options for concurrency, the standard library includes support for threading, processes, and asynchronous I/O. Hello Python threads Listing 1. hello_threads_example Listing 2. . #! 10 Ways to Make Python Go Faster « Get off the Table. Home > Python > 10 Ways to Make Python Go Faster On the “Sphere Online Judge” competition site, there are hundreds of programming challenges which you can attempt to solve in any of 40+ different programming languages. You simply submit your code, and the online judge will execute the code in a controlled environment. If you’re program generates the correct output (answers the set problem) within a specified time limit, you get some points on the scoreboard. Here’s the catch: The time limit is the same no matter what language you are using.
This obviously puts interpreted languages like Python at a disadvantage, and often you need to squeeze every last ounce of speed from you algorithm. Many problems have never been solved in Python due to the time limit… it pays to check whether there have been any sucessful Python solutions submitted for a given problem before getting too frustrated trying to find a fast enough solution. Optimise the innermost loop. Import psyco psyco.full() Like this:
Can someone with a mac help me with the equivalent of this Linux code? : Python. SQLite3, Full Text Search with FTS3, and iOS 4.0 | Regular Rate & Rhythm. Fulltext search in SQLite and Django app. Since version about 3.5.9 SQLite contains full-text search module called FTS3 (older releases may have FTS1, FTS2). Using this module we can easily add fast full text search to a Django application (or any other using SQLite). During my tests I got FTS3 only on Python 2.6. On Python 2.5 and using pysqlite may be hard to get FTS3 (try recompiling with -DSQLITE_ENABLE_FTS3=1 flag). Creating virtual table Here is an example table: CREATE VIRTUAL TABLE my_search using FTS3(slug, body); WHERE FTS3(columns...) defines table structure. FTS1 and FTS2 can be used exactly in the same way as FTS3. Adding data to a virtual table We can start with importing data from existing table. Indexing new entries we can handle in Django with signals.
Full-text in SQLite The query looks like this: SELECT slug FROM my_search WHERE body MATCH 'search term'; In Django we can execute such query like this: I'm testing this search solution on my JobMaster - job offer searcher hosted on megiteam.pl. Lucene - Building PyLucene PyLucene is completely code-generated by JCC whose sources are included with the PyLucene sources. Requirements To build PyLucene a Java Development Kit (JDK) and Ant are required; use of the resulting PyLucene binaries requires only a Java Runtime Environment (JRE). The setuptools package is required to build and run PyLucene on Python 2.3.5.
With later versions of Python, setuptools is only required for shared mode. For the Impatient Ones pushd jcc<edit setup.py to match your environment>python setup.py buildsudo python setup.py installpopd<edit Makefile to match your environment>makemake test (look for failures)sudo make install For the Rest of Us Before building PyLucene, JCC must be built first. Once JCC is built and installed, PyLucene is built via make which invokes JCC. There are limits to both how many files can fit on the command line and how large a C++ file the C++ compiler can handle. Notes for Solaris 11 with Sun Studio C++ 12 Notes for Solaris 11.1 with GCC 4.5. Apache Lucene - Indexing a Database and Searching the Content | kalani's Tech blog. Here is a Java code sample of using Apache Lucene to create the index from a database. (I am using Lucene version 2.3.2 and MySQL) I assumed that there is a table named pet in the "test" database with the fields "id" "name" and "color".
After running this a folder named index is created in the working directory including indexed content. The following code (lucene searcher) shows how to search a record containing a particular keyword using the created lucene index. Searcher searcher = new IndexSearcher(IndexReader.open("index")); Query query = new QueryParser("color",analyzer).parse("white"); Hits hits = searcher.search(query); String sql = "select * from pet where id = ?
" Searcher searcher = new IndexSearcher(IndexReader.open("index")); Query query = new QueryParser("color",analyzer).parse("white"); Hits hits = searcher.search(query); String sql = "select * from pet where id = ? " Espinozaulises/jquery-history-plugin. Edgarjs/instachrome. Yikulju/Hello-History. Core concepts - Dropbox. How To View a Google Chrome Extension’s Full Source Code - Oren Yomtov's Website. Home » Blog » How To View a Google Chrome Extension’s Full Source Code You can extract and view any Google Chrome extension’s full source code following the following easy steps. Every Google Chrome extension is basically a CRX file. When you click the “Install” button on the Google Chrome extension gallery you are basically clicking a link of the extension’s CRX file. The first step is downloading the extension’s CRX file. Instead of clicking it’s link, which will lead to that extension being installed on your browser, right-click the link and choose “Save link as…”.
Now that you have the CRX file on your computer, rename it’s extension from CRX to ZIP. Turns out that every CRX file is a renamed ZIP archive of the extension. All there is left to do is extract the ZIP archive to the desired destination. Have fun exploring other peoples code! Extensions developer workflow. By Andreas Bovens From Opera 15 onward, Opera 11 & 12’s extension format is no longer supported, and instead, we’ve switched to Chromium’s extension model. Check out our new documentation for developing extensions for Opera 15 and higher and start building your own extensions.
Contents Introduction In this short article, we’ll look at the developer workflow to create extensions, give some tips for extension development, and point out a couple of caveats. For this guide, we start with the Hello World example introduced in Saying hello world to Opera extensions! If you have gone through all steps except packaging, you should have something similar to the folder structure in Figure 1. Developer mode You can simply drag and drop the config.xml onto an open Opera window or its application icon, and the extension will be activated in the so-called “developer mode”.
You’ll also notice that each extension running in developer mode gets two extra buttons: “Reload” and “Open containing folder”. Chronzz/MobileSafariPlugin. How to create a browser plug in. How to Write a Chrome Extension in Three Easy Steps. I just installed a “hello world” Chrome extension from this Chrome Extension tutorial page. When you surf to www.google.com, the Google logo is replaced with a Lolcat: Here’s how to write your own Google Chrome extension in three steps: 1. Install the developer-channel version of Google Chrome. I don’t know if this is 100% necessary, but new support for plugins will probably show up in the developer version first. 2.
I like several things about the extension framework: - Your plugin has to have a unique identifier (40 digit hexadecimal number). The Chrome extension manifest, which has metadata about your extension such as name, version, etc., looks much simpler to me than how Firefox wants extensions to be packaged. 3. Once you see how it works, just start hacking around and see what happens. One more nice thing: it looks like installing extensions doesn’t require you to restart the browser.
And a hat-tip to Google OS for pointing out this document. Event listeners on plugin in document.onload events in opera. JavaScript Tip of the Week for October 7, 1996: History Tracker. For October 7, 1996: History Tracker Maybe its just me but I don't like the way Netscape keeps track of the history of pages you visited, so I created an alternative for JavaScript Tip of the Week.
It's logically named the History Tracker, and it will track every page on your web site. It doesn't track any pages that do not exist on your server for security reasons. It not only records the URL and title of a page, but it also allows you to replay your browsing activites in chronological order. This is just one of its features; more will be added in the future.
Modifiying this to work on your own site is very simple, it takes only the changing of three variables. bmDomain = "C|/"; <-- domain where tracker works bmReal = new Array(); bmName = "jtotw"; <-- name of history object bmTotal = 0; bmTotalallow = 20; <-- the total number of pages allowed bmReplayIP = false; urlLast = ""; This whole app is based on an aspect of JavaScript called user-defined objects. Mileswu/about-me-opera. Dodecagon/chrome-history. Nakah/Firefox-Chrome-History-Search. Jbrennan/Safari-History-Merger. About-me-opera/aboutme.rb at master · mileswu/about-me-opera. How to access Google Chrome browser history programmatically on local machine. Getting Started with HTML5 Local Databases « Dark Crimson Blog. Please note: This article was written in May 2010 and as of November 18, 2010, the Web Applications Working Group has reached an impasse and does not intend to maintain the Web SQL Database any longer.
Read more here. Starting with Safari 4, iOS OS3, Chrome 5, and Opera 10.5 (Desktop), HTML5 Local Databases (AKA Web SQL Databases) are now supported. I’ve been reading about local databases for quite some time and decided to do a write up with some basic examples on how to get started. Setting up the Database First we check if the browser supports the openDatabase method, is so we continue and define the database parameters: shortName is the DB name as it will be referred to by the browser and SQLversion openDatabase version. 1.0 for this (more on that here) displayName The full display name / description of the databasemaxSize This is max size in bytes is the size you expect the database to reach. Building the Table Select the data Making updates Dropping the table The demo: Resources.