Skip to content

Instantly share code, notes, and snippets.

@bdlangton
bdlangton / Blocks.md
Last active October 12, 2023 08:40
Drupal 8 programmatic solutions

Render custom blocks

$bid = 'myblock';
$block = \Drupal\block_content\Entity\BlockContent::load($bid);
$render = \Drupal::entityTypeManager()->getViewBuilder('block_content')->view($block);

Render plugin blocks

$block_manager = \Drupal::service('plugin.manager.block');
@magnetikonline
magnetikonline / README.md
Last active February 4, 2024 07:45
List all Git repository objects by size.

List all Git repository objects by size

Summary

Bash script to:

  • Iterate all commits made within a Git repository.
@fndtn357
fndtn357 / module.php
Last active February 28, 2017 16:14 — forked from kevinquillen/module.php
/**
* 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;
@kgriffs
kgriffs / gist:b4eb14c91212f2fa3a0a
Created November 18, 2014 18:49
SQLAlchemySessionManager (B)
# =========================================================================
# 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)
@cfxd
cfxd / chosenjs-less-for-bootstrap-and-woocommerce-checkout.less
Last active August 29, 2015 14:03
This will style WooCommerce's ChosenJS select boxes on the WooCommerce checkout page to match your existing Bootstrap form styles (assuming you've made any style changes in LESS) and even replaces the default background images with Bootstrap's built in Glyphicons.
// first some helpful mixins
.abs {
position: absolute;
}
.rel {
position: relative;
}
.position(@top; @right; @bottom; @left) {
top: @top;
right: @right;
@ndeet
ndeet / MYTHEME.info
Last active February 8, 2018 14:41
Drupal 7, Panels 3.3+ Pane Style Plugin
; Register Style Plugin directory
plugins[panels][styles] = panels/styles
@mnapoli
mnapoli / behat-reference.feature
Last active February 12, 2024 10:54
Behat Mink reference
# 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
@rturowicz
rturowicz / page.py
Last active December 19, 2018 11:50
django - intermediate admin 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']
@mangecoeur
mangecoeur / a-conda-workon-tool.md
Last active February 9, 2021 14:53
A "virtualenv activate" for Anaconda environments

A "virtualenv activate" for Anaconda environments

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

@bubenkoff
bubenkoff / checkpoint.sh
Last active February 14, 2024 21:38
Endpoint Security VPN FULL start/stop script for Mac OS X
#!/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.