Skip to content

Instantly share code, notes, and snippets.

@bnchdrff
bnchdrff / README.md
Created July 21, 2016 13:30
Add POST endpoint for performant Drupal 8 REST file uploads

Instead of accepting serialized files, I wanted to process file uploads as multipart/form-data.

I also wanted to use the crsf prevention API.

This is what I came up with. Replace modulename with your module and fileupload with whatever you want to name your class/endpoint.

In your routing.yml:

<?php
namespace Drupal\MODULE\Plugin\facets\processor;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\facets\FacetInterface;
use Drupal\facets\Processor\BuildProcessorInterface;
use Drupal\facets\Processor\ProcessorPluginBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
@bnchdrff
bnchdrff / laserharp.ino
Last active May 8, 2016 02:20
laser harp
int LaserState = LOW; // The variable that stores the state of the laser beam.
int sensor = 8; // Change this value to calibrate your harp's sensor
int delaylaser = 5; // If you increase this, the laser will be brighter, but the harp will be less fluid
int delaymotor = 300; // This variable affects the speed, and fluidity of the harp.
int LaserPin = 7; // Tell the arduino that the laser is on pin 7
int motorPin1 = 8; //Use these names for the pin numbers.
int motorPin2 = 9;
int motorPin3 = 10;
<?php
namespace Drupal\redactedmodulename\Plugin\facets\processor;
use Drupal\Core\Entity\EntityFieldManagerInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\facets\FacetInterface;
use Drupal\facets\FacetSource\SearchApiFacetSourceInterface;
use Drupal\facets\Processor\BuildProcessorInterface;
use Drupal\facets\Processor\ProcessorPluginBase;
@bnchdrff
bnchdrff / summarize-views.php
Created December 15, 2015 22:04
summarize all views on a drupal site
<?php
$views = [
[
'view machine name',
'view name',
'view desc',
'base table',
'display machine name',
'display title',
@bnchdrff
bnchdrff / keybase.md
Created November 10, 2015 16:18
keybase proof

Keybase proof

I hereby claim:

  • I am bnchdrff on github.
  • I am bnchdrff (https://keybase.io/bnchdrff) on keybase.
  • I have a public key whose fingerprint is 3C34 A3DE 0349 E9AB 0D33 72FA 4AEB E5B0 7441 5072

To claim this, I am signing this object:

#!/bin/bash
#
# A script that makes a local copy of a prod Acquia db.
#
# * Start a backup task on an Acquia remote site,
# * wait for it to finish,
# * download it to a temp file,
# * drop the existing db
# * and load it into the current environment's database with "drush sqlc"
@bnchdrff
bnchdrff / gnl-from-scratch.sh
Created July 1, 2015 00:34
Docker orchestra
# Data instances should already be there... but this is how they were made:
docker run -v /var/lib/mysql --name=gnl-db-data busybox true
docker run -v /srv/www -v /etc/nginx/sites-enabled --name=gnl-www-data busybox true
# DB instance uses gnl-db-data volume.
docker run -d --volumes-from=gnl-db-data --name=gnl-db bnchdrff/mariadb
# Backend PHP/nginx links to db instance & also offers ssh access for dirty admin tasks. gnl-www-data has files.
docker run -d -p 2222:22 --link=gnl-db:db --volumes-from=gnl-www-data --name=gnl-backend bnchdrff/nginx-php5-drupal
@bnchdrff
bnchdrff / mesh.sh
Created March 12, 2015 21:02
set up mesh on ubuntu 14
apt-get install batctl bridge-utils
ifconfig wlan0 down
iwconfig wlan0 mode ad-hoc essid puppycat channel 1
ifconfig wlan0 up
batctl if add wlan0
ifconfig wlan0 mtu 1527
cat /sys/class/net/wlan0/batman_adv/iface_status
# should be active
ifconfig wlan0 0.0.0.0
ifconfig bat0 up