Skip to content

Instantly share code, notes, and snippets.

View mariuswilms's full-sized avatar

Marius Wilms mariuswilms

View GitHub Profile
#!/usr/bin/env node
/*!
* CSS: The Next Generation
*
* Copyright (c) 2017 Atelier Disko. All rights reserved. This source
* code is distributed under the terms of the BSD 3-Clause License.
*/
const fs = require('fs');
const postcss = require('postcss');
@mariuswilms
mariuswilms / reset-copyright-year.sh
Last active May 3, 2017 07:18
Reset copyright year of each source file in Git
@mariuswilms
mariuswilms / li3_custom_form_helper.php
Last active September 2, 2016 08:27
li3_custom_form_helper.php
<?php
namespace app\extensions\helper;
class Form extends \lithium\template\helper\Form {
public function field($name, array $options = array()) {
$options += [
'class' => null,
'type' => isset($options['list']) ? 'select' : 'text',
<div class="wrapper"><!--
--><?php $bar ? (echo 'foo') : '' ?><!--
--></div>
@mariuswilms
mariuswilms / mongo_migrate_posts_li3.sh
Last active August 29, 2015 14:07
Migration scripts to change URLs in blog posts from lithify.me to li3.me
#!/bin/bash
# Fill in your connection details.
DATABASE="blog"
COLLECTION="posts"
USER=""
PASS=""
#
AUTH=""
#!/bin/bash
#
# Continuously checks online/offline status and notifies
# you when the status changes. Works only where the "say"
# command is available.
#
# Dedicated to the public domain.
#
last=
@mariuswilms
mariuswilms / li3_filter_inject_data_into_elements.php
Created October 25, 2013 06:41
Lithium filter to inject data into elements.
<?php
use lithium\net\http\Media;
$injectDataIntoElements = function(array $elements = [], array $data = []) {
Media::applyFilter('view', function($self, $params, $chain) use ($elements, $data) {
$view = $chain->next($self, $params, $chain);
$view->applyFilter('_step', function($self, $params, $chain) use ($elements, $data) {
$whitelisted = in_array($params['params']['template'], $elements);
@mariuswilms
mariuswilms / pre-commit
Last active May 19, 2022 09:36
Git pre-commit Hook
#!/bin/bash
#
# Language agnostic GIT pre commit hook.
#
# Copyright (c) 2013 Marius Wilms.
# All rights reserved.
#
# Distributed under the terms of the BSD 3-clause license. Redistributions
# of this file must retain the above copyright notice. For the full license
# text see: http://opensource.org/licenses/BSD-3-Clause.
@mariuswilms
mariuswilms / copyright.html.php
Created October 28, 2011 19:05
Reusable Copyright Element for Lithium
@mariuswilms
mariuswilms / gist:859371
Created March 7, 2011 22:07
Exemplaric beforeDelete hook for a file model, to delete corresponding version.
<?php
public function beforeDelete($cascade = true) {
if (!$cascade) {
return true;
}
$result = $this->find('first', array(
'conditions' => array($this->primaryKey => $this->id),
'fields' => array('dirname', 'basename'),
'recursive' => -1