Skip to content

Instantly share code, notes, and snippets.

View davebeach's full-sized avatar

David Beach davebeach

View GitHub Profile
@davebeach
davebeach / picture-element.md
Last active September 4, 2016 23:21
picture element

Use cases of picture element

##The device-pixel-ratio Use Case

<img srcset="normal.jpg 1x, retina.jpg 2x"
   src="normal.jpg"
   alt="device-pixel-ratio use case" />
@davebeach
davebeach / block--header-branding.html.twig
Created September 5, 2016 07:34
Drupal 8 SVG Logo TWIG Branding Block
{# The easiest way to add link to home page and SVG logo is to put the SVG into the active theme directory root named logo.svg. To have default for browsers that cannot display SVG, see GIST https://gist.github.com/davebeach/064996d9b234c742642f8ca45585139a - then in the twig block just add the anchor and image elements. There is a lot of complex settings, by passing the block further down to another content file, but this makes no sense. The most difficult part is the anchor link, which just set it to /, don't try and is_front until the bugs are worked out with that functionality. #}
{% block content %}
<div class="container-content region-fixed-content">
<a class="logo" href="{{ '/' | page }}">
<img src="{{ logo }}" alt="{{ 'Home'|t }}"/>
</a>
</div>
@davebeach
davebeach / drupal-svg-inline-example.md
Last active September 10, 2016 04:36
svg for drupal 8 logo with png fallback.

##svg for drupal 8 logo with png fallback.

Recommendations found at [Blog](http://thoughtfulweb.com/thoughts/on/the-best-way-to-add-an-svg-image-to-your-website/ title="SVG INLINE METHOD") [^2]

  1. Must be set up as in-line SVG. In adobe illustrator this is an option when exporting to svg.
  2. You need to maniupulate the SVG code, to the the following tags.
  3. It is important that you declare xmlns:xlink="http://www.w3.org/1999/xlink" in the svg tag.
  4. You can add a CSS class and attempt to style it, note however that I have not been able for this to be adopted by most browsers (more future functionality).

GULP Workflow

Steps to set up project.

  1. Create project folder. mkdir projectName
  2. Initialize npm project. npm init
  3. Setup project gulpfile.js:
{
@davebeach
davebeach / unixpermissions.md
Last active September 14, 2016 00:29
Unix Permissions

##Key Permissions

*OWNER:READ GROUP:READ USER:READ chmod 0444

*OWNER:READ WRITE GROUP:READ USER:NONE chmod 0640

*OWNER:READ-WRITE-EXECUTE GROUP:READ-WRITE-EXECUTE USER:READ-EXECUTE chmod 0775

@davebeach
davebeach / drupal8-settings-reinstall.md
Last active October 14, 2016 02:33
Create settings.php and the files directory Drupal 8 - To Reinstall Site

Drupal Important Permission Settings Pre-Install and Post-Install.

Pre-Install or Already Installed but Dumping Database to Reinstall

Create settings.php and the files directory for install.

chmod 644 sites/default/settings.php
chmod -r 755 sites/default

ImageMagick Workflow via Command Line

Install - Global

Mac OS X

brew install imagemagick

For LiNUX Cloud Server Command Line

apt-get install imagemagick
@davebeach
davebeach / twig.md
Last active November 8, 2016 06:18

Various Twig Tips and Tricks

Content

Content Without Title Field

It is possible to pass the content without the title printing. Without title:``` {{ content|without('field_title') }}

With title:```
{{ content| }}

Procedure to Recover Instance

Moving Persistent Disk to Another Instance To Regain Access

Procedure for Google Cloud

  • Create a snapshot of your instance’s persistent disk. Using the Google cloud console, create a snapshot of the instance. Console Instructions for Snapshot Example: Instance name is disk-bitnami-drupal-dm-3d36. Name the snapshot - snapshot-1

  • Create a new persistent disk from this snapshot. From the gcloud console for the project execute command:

@davebeach
davebeach / SSHcommands.md
Last active November 20, 2016 21:24
SSH Commands

Misc Commands

  • To remove a entry from Known_hosts in .ssh directory
ssh-keygen -R hostname
ssh-keygen -F myhost         # shows myhosts's line in the known_hosts file
ssh-keygen -l -F myhost # additionally shows myhost's fingerprint