How to change matplotlib backends

Six years later and I came across a similar issue, when trying to decide which backend was available to use. Note see Caveats – below This code snippet works well for me: import matplotlib gui_env = [‘TKAgg’,’GTKAgg’,’Qt4Agg’,’WXAgg’] for gui in gui_env: try: print(“testing”, gui) matplotlib.use(gui,warn=False, force=True) from matplotlib import pyplot as plt break except: continue … Read more

Rails: store translations in database

i18n has built-in support for using the database as a translation backend. Create a table using this code in a migration: create_table :translations do |t| t.string :locale t.string :key t.text :value t.text :interpolations t.boolean :is_proc, :default => false end Then add an initializer in config/initializers/i18n.rb with contents: I18n.backend = I18n::Backend::ActiveRecord.new And last… put translations in … Read more

SequelizeConnectionError: self signed certificate

This is due to an (accidental) breaking change in node-postgres version 8 (see this GitHub issue). The solution is to pass rejectUnauthorized: false to the sequelize connection parameters inside of dialectOptions>ssl, as described here by GitHub user jsanta, bypassing the SSL certificate check (which is okay when connecting to a trusted server over a secure … Read more

How can I take a screenshot/image of a website using Python?

Here is a simple solution using webkit: http://webscraping.com/blog/Webpage-screenshots-with-webkit/ import sys import time from PyQt4.QtCore import * from PyQt4.QtGui import * from PyQt4.QtWebKit import * class Screenshot(QWebView): def __init__(self): self.app = QApplication(sys.argv) QWebView.__init__(self) self._loaded = False self.loadFinished.connect(self._loadFinished) def capture(self, url, output_file): self.load(QUrl(url)) self.wait_load() # set to webpage size frame = self.page().mainFrame() self.page().setViewportSize(frame.contentsSize()) # render image image … Read more

How to change backends in matplotlib / Python

Six years later and I came across a similar issue, when trying to decide which backend was available to use. Note see Caveats – below This code snippet works well for me: import matplotlib gui_env = [‘TKAgg’,’GTKAgg’,’Qt4Agg’,’WXAgg’] for gui in gui_env: try: print(“testing”, gui) matplotlib.use(gui,warn=False, force=True) from matplotlib import pyplot as plt break except: continue … Read more