Skip to content

Instantly share code, notes, and snippets.

View megclaypool's full-sized avatar

Meg Claypool megclaypool

View GitHub Profile
@rodneyrehm
rodneyrehm / prefilter.whitespace_control.php
Created June 28, 2012 20:44
Smarty: Whitespace Control - Prefilter Plugin
<?php
/**
* Smarty Whitespace Control
*
* {-tag} remove white space infront of tag up to the previous non-whitespace character or beginning of the line
* "text \n\n\t {-tag}" -> "text \n\n{tag}"
* "text \n\n\t text\t {-tag}" -> "text \n\n\t text{tag}"
* {--tag} remove white space infront of tag up to the previous non-whitespace character
* "text \n\n\t {--tag}" -> "text{tag}"
@seshness
seshness / HowToSharedRepoModelOnGitHub.md
Created October 24, 2012 01:45
Shared Repository Model for Pull Requests and Code Review

The Shared Repository Model

$ git clone git@github.com:berkeley-food-recommendations/data-gathering.git

You're cloning the main repository - be careful! We're going to enforce a "no committing to master directly" rule, so no committing directly to master, please.

Short Version

@denji
denji / homebrew-rvm.md
Last active February 6, 2024 08:52
Homebrew + RVM > Awesome

The MBP is my development machine, so I needed all of my tools installed with the ability to update them with ease. In the past, I used MacPorts to take care of my MySQL, Memcached, and Ruby installions and it worked just fine. This time around however, I wanted something new and fun. Homebrew.

Homebrew is a new package manager for OS X. Unlike Fink or MacPorts, Homebrew integrates with the core operating system, reducing the number of extra libraries to install etc. Another neat feature is the ability to write software package recipes in Ruby, awesome.

Here are some raw installation instructions (clean system). I like to keep everything under user ownership to make life more enjoyable, say no to sudo.

You will need the latest version of xcode, you can get it here. After the installation is complete, you may continue.

sudo mkdir /usr/local
@petemcw
petemcw / brew-instructions.sh
Last active March 27, 2024 15:59
Setup dnsmasq on Mac OS X
# Install `dnsmasq` and configure for *.test domains
$ brew install dnsmasq
$ vim /usr/local/etc/dnsmasq.conf
# Reload configuration and clear cache
$ sudo launchctl unload /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
$ sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
$ dscacheutil -flushcache
@aczietlow
aczietlow / gist:1d2c8f7694e1471f2874
Created December 8, 2014 15:38
Behat tests for checkout css properties
<?php
/**
* @Given /^The element "(?P<selector>[^"]*)" should have a css property "(?P<property>[^"]*)" with a value of "(?P<value>[^"]*)"$/
*
* @TODO Need to find a way to test for css styles on elements.
* Or possibly we should just be checking the markup, and not the styling... Research this more.
*/
public function assertElementHasCssValue($selector, $property, $value)
{
$page = $this->getSession()->getPage();
@szeidler
szeidler / d8-responsive-image-programmatically.php
Created March 15, 2016 08:42
Load and render responsive image from field in Drupal 8
<?php
function _load_header_image($variables) {
if ($node = $variables['node']) {
// Load main_image
$file = $node->field_main_image->entity;
if ($file) {
$variables = array(
'responsive_image_style_id' => 'header_image',
'uri' => $file->getFileUri(),
@jelera
jelera / gulpfile.js
Created August 18, 2016 02:06
Gulp Frontend Build System
var gulp = require('gulp');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var pug = require('gulp-pug');
var useref = require('gulp-useref');
var uglify = require('gulp-uglify');
var gulpIf = require('gulp-if');
var cssnano = require('gulp-cssnano');
var sourcemaps = require('gulp-sourcemaps');
var imagemin = require('gulp-imagemin');
@tmslnz
tmslnz / dnsmasq.md
Last active March 20, 2023 07:07
Setting up dnsmasq on OS X

Install dnsmasq

Via brew or other method

Set up DNS resolver order

In order to work on every connection and on any TLD, dnsmasq needs to be the first DNS resolver receving the query.

And since dnsmasq is a local process, all DNS queries need to go to 127.0.0.1

On macOS, /etc/resolv.conf is automaticaly created, depending on a variety of things (network settings, etc), so it cannot be edited.

@LittleCoding
LittleCoding / myelement.html.twig
Created September 27, 2016 13:37
Current URL path via Twig in Drupal 8
{#
/**
* @file
* Get the current URL path via Drupal 8 route name and twig function.
*/
#}
<a href="{{ url('<current>') }}">Current page</a>
@w00fz
w00fz / sphp.sh
Last active February 7, 2022 00:12
PHP switcher
#!/bin/bash
# Check if command was ran as root.
if [[ $(id -u) -eq 0 ]]; then
echo "The command \"sphp\" should not be executed as root or via sudo directly."
echo "When a service requires root access, you will be prompted for a password as needed."
exit 1
fi
# Usage