$bid = 'myblock';
$block = \Drupal\block_content\Entity\BlockContent::load($bid);
$render = \Drupal::entityTypeManager()->getViewBuilder('block_content')->view($block);
$block_manager = \Drupal::service('plugin.manager.block');
/** | |
* Creates a temporary table to hold values from an uploaded CSV. | |
* @param $table_name | |
* @param $columns | |
* @param $message | |
* @param $context | |
*/ | |
function csv_import_create_temp_table($table_name, $columns) { | |
if (db_table_exists($table_name)) { | |
return; |
# ========================================================================= | |
# middleware.py | |
# ========================================================================= | |
import sqlalchemy.orm.scoping as scoping | |
class SQLAlchemySessionManager(object): | |
def __init__(self, session_factory, auto_commit=False): | |
self._session_factory = session_factory | |
self._scoped = isinstance(session_factory, scoping.ScopedSession) |
// first some helpful mixins | |
.abs { | |
position: absolute; | |
} | |
.rel { | |
position: relative; | |
} | |
.position(@top; @right; @bottom; @left) { | |
top: @top; | |
right: @right; |
; Register Style Plugin directory | |
plugins[panels][styles] = panels/styles |
# Given | |
Given I am on [the] homepage | |
Given I am on "url" | |
# When | |
When I go to [the] homepage | |
When I go to "url" | |
When I reload the page |
# admin.py: admin action definition | |
def make_copy(self, request, queryset): | |
form = None | |
if 'apply' in request.POST: | |
form = CopyPageForm(request.POST) | |
if form.is_valid(): | |
issue = form.cleaned_data['issue'] |
I've been using the Anaconda python package from continuum.io recently and found it to be a good way to get all the complex compiled libs you need for a scientific python environment. Even better, their conda tool lets you create environments much like virtualenv, but without having to re-compile stuff like numpy, which gets old very very quickly with virtualenv and can be a nightmare to get correctly set up on OSX.
The only thing missing was an easy way to switch environments - their docs suggest running python executables from the install folder, which I find a bit of a pain. Coincidentally I came across this article - Virtualenv's bin/activate is Doing It Wrong - which desribes a simple way to launch a sub-shell with certain environment variables set. Now simple was the key word for me since my bash-fu isn't very strong, but I managed to come up with the script below. Put this in a text file called conda-work
#!/bin/bash | |
# | |
# The reason of creating this script is that Endpoint Security VPN installs it's own application firewall kext cpfw.kext | |
# which prevents for example PPTP connections from this computer, which is not appropriate if you need subj connection just | |
# from time to time | |
# | |
# Usage: ./checkpoint.sh | |
# | |
# The script checks if Enpoint Security VPN is running. If it is, then it shuts it down, if it is not, it fires it up. | |
# Or, make an Automator action and paste the script. |