Skip to content

Instantly share code, notes, and snippets.

View wernerkrauss's full-sized avatar

Werner Krauß wernerkrauss

View GitHub Profile
@bradtraversy
bradtraversy / tailwind-webpack-setup.md
Last active July 31, 2025 05:45
Setup Webpack with Tailwind CSS

Webpack & Tailwind CSS Setup

Create your package.json

npm init -y

Create your src folder

Create a folder called src and add an empty index.js file. The code that webpack compiles goes in here including any Javascript modules and the main Tailwind file.

@sminnee
sminnee / herring.sh
Last active September 19, 2017 05:52
#!/bin/bash -eux
source $1
${@:2}
// this script loads the YouTube iframe-api, gets all instances and adds enablejsapi & origin-URL to the src-URL
// after initiating the API it adds playing-mode & paused-mode to the iframes
if ($('[src^="https://www.youtube.com/"]').length) {
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
}
/*
See: https://www.smashingmagazine.com/2016/05/fluid-typography/
1. without support for anything, the font size will be the minimum font-size (14px) so nothing will break.
2. with support for mediaqueries and not vw or calc or both then the font will jump up a pixel size at every appropriate breakpoint (I'm using http://include-media.com for syntactic-sugar, but you could rewrite without this)
3. with support for mediaqueries and calc and vw it will work as the article describes, with the fixes for older Safari and IE too
Ain't it pretty!? Haha - works well tho :)
*/
@bummzack
bummzack / silverstripe-gulp.md
Created November 4, 2015 10:28
Live-reload and fast CSS compilation for a SilverStripe website using gulp.js

Live-reload and fast CSS compilation for a SilverStripe website using gulp.js

Steps to success:

  1. Install gulp globally (do this only once): npm install -g gulp
  2. In your project folder, add gulp: npm install --save-dev gulp
  3. Install browser-sync to enable auto-updated and synchronised websites across all your browsers: npm install -g browser-sync
  4. Install libsass for super fast SCSS compilation: npm install --save-dev gulp-sass
  5. Install sourcemaps-plugin if you want them: npm install --save-dev gulp-sourcemaps
  6. Of course you can also add gulp plugins to concatenate and minify your JavaScript and CSS.
tinymce.PluginManager.add('smartquotes', function(editor) {
function convert(e) {
rootNodes = editor.dom.select("body > *");
for (var i = 0; i < rootNodes.length; i++) {
var el = rootNodes[i];
var contentEditable = editor.dom.getAttrib(el, "contenteditable");
if (contentEditable !== "false") {
convertBlock(el);
@Zauberfisch
Zauberfisch / BaseValidator.php
Last active August 29, 2015 14:13
Better SilverStripe Form Validator
<?php
/**
* @author zauberfisch
*/
class BaseValidator extends Validator {
protected $validateFields, $requireFields;
/**
* @param bool|string[]|\FormField[]|\FieldList $validateFields
@wernerkrauss
wernerkrauss / post-merge
Last active April 18, 2016 10:08
git post-merge hook for silverstripe installs.
#!/bin/bash
echo "running git post receive hook..."
DIR=$(git rev-parse --show-toplevel)
composer.phar install --no-dev -o
echo "running dev/build"
sudo -u www-data php $DIR/framework/cli-script.php dev/build flush=1
<?php
class Page extends SiteTree {
private static $db = array(
'ShowInFooter' => 'Boolean'
);
private static $defaults = array(
'ShowInFooter' => 1
@Zauberfisch
Zauberfisch / TranslatableControllerExtension.php
Last active December 23, 2015 13:41
SilverStripe Translatable defaults snippets
<?php
// file: mysite/code/TranslatableControllerExtension.php
class TranslatableControllerExtension extends Extension {
/**
* save the current controller to ensure we have access to it,
* this is necessary because Security crates a fake Page_Controller to render templates
* @var Controller
*/
protected static $actual_current_controller;