Skip to content

Instantly share code, notes, and snippets.

View sdboyer's full-sized avatar

sam boyer sdboyer

View GitHub Profile
@ircmaxell
ircmaxell / raw.php
Created July 29, 2014 18:31
Dump Gliph to GraphViz
<?php
public function dump(DirectedAdjacencyList $func, $filename) {
$ctr = 0;
$graph = Graph::create("dump");
$nodes = new \SplObjectStorage;
$scope = new \SplObjectStorage;
foreach ($func->eachVertex() as $vertex => $_) {
$nodes[$vertex] = Node::create('node_' . $ctr++);
$graph->setNode($nodes[$vertex]);
@skriptble
skriptble / FizzBuzzTransducers.go
Last active August 29, 2015 14:10
FizzBuzz with Transducers!
package main
import (
"fmt"
"github.com/sdboyer/transducers-go"
)
func FizzyBuzzyNumbers() transducers.ValueStream {
fizzyBuzzyCurr := 0
@sdboyer
sdboyer / gist:825176
Created February 13, 2011 21:48
merge horribleness
Original LCAS:
set(['drumm@delocalizedham.com-20110114031905-tf0ean18fij48avq',
'hudson@util.drupal.org-20101231175052-vh23b2wb4m4fuyrf',
'hudson@util.drupal.org-20110115180021-3pa9rxlzj0b4m7ux',
'hudson@util.drupal.org-20110116201349-pt6bqho1lfldzmev',
'hudson@util.drupal.org-20110124022445-53hs3ux2ek0fjw23',
'hudson@util.drupal.org-20110126103810-nz8z9m6uk958031d',
'killes@util.drupal.org-20101222010347-tqtq6pn8q9g3622d'])
Using LCAS:
set(['hudson@util.drupal.org-20110115180021-3pa9rxlzj0b4m7ux'])

Summary

I had a look at calls to _preprocess_html and _process_html and what they do in core. I've listed what we need to provide and a summary of existing implementations.

It seems that everything existing in core can be potentially solved by:

  • Providing the ability to add/modify attributes to the <body> tag and the <html> tag. Most of the time, it's class attributes, but RDFa will have other needs.
  • Better asset management (CSS/JS). Preprocessors sometimes call drupal_add_js, etc. We're already talking about this in core.
  • Providing an API for theme hook/template suggestions outside of preprocessors. (There's an issue for this)
  • Providing the ability to add/modify and tags, and the tag, all within. This is on sdboyer's radar.

Example for terminology:

  • hook = hook
  • themeID = node
  • suggestionID = article

1) Definition

hook_theme()
@sdboyer
sdboyer / theme.php
Last active December 17, 2015 18:09
notes on what to do with page preprocessing
<?php
function template_preprocess_page(&$variables) {
$language_interface = language(LANGUAGE_TYPE_INTERFACE); // DC
$site_config = config('system.site'); // DC
// Move some variables to the top level for themer convenience and template cleanliness.
$variables['show_messages'] = $variables['page']['#show_messages']; // Bad
foreach (system_region_list($GLOBALS['theme']) as $region_key => $region_name) {
if (!isset($variables['page'][$region_key])) {
@lewisnyman
lewisnyman / gist:5651296
Created May 26, 2013 00:22
template_preprocess_html
/**
* Prepares variables for HTML document templates.
*
* Default template: html.html.twig.
*
* @param array $variables
* An associative array containing:
* - page: A render element representing the page.
*
* @see system_elements()
Turning The Design Clock Back
Object-oriented design principles haven't had the effect we hoped for. The
SOLID principles are excellent design guidelines, but experience shows that
programmers find them difficult to follow. What do we do about this?
Surprisingly, the Structured Design literature of forty years ago contains
compelling solutions to many current design problems. They're simple and easy
to understand, but were lost in the noise as OO rose to popularity. We'll
reinterpret these simple design ideas in a modern context, finding that many of
our most promising new design ideas resemble them. Rapid web application
@rafecolton
rafecolton / Golang-binary-versioning.md
Last active July 27, 2017 11:15
Copypasta for easy versioning for your Go binaries

Golang Binary Versioning Trick

To use, place the code in version_trick.go in your project. Don't forget to change the namespace to match yours to the actual name of your package.

In addition to version_trick.go, there's a makefile-snippet, that includes the secret sauce for making this trick work. Be sure to change the package name there as well.

Enjoy!

P.S. Special thanks to @meatballhat by way of @syscomet for showing me this trick!

// Have some complicated non-React widgets that manipulate DOM?
// Do they manage a list of DOM elements? Here's how to wrap it
// into a React component so you can "constantly rerender" it.
// A dumb non-react widget that manually manage some DOM node that
// represent a list of items
function NonReactWidget(node) {
this.node = node;
}