Skip to content

Instantly share code, notes, and snippets.

View mariuswilms's full-sized avatar

Marius Wilms mariuswilms

View GitHub Profile
<?php
function transferTo($via, $from) {
extract($from);
$path = Media::short($file, $mimeType) . DS;
if (is_file($file)) {
$checksum = hash_file('adler32', $file);
} elseif (is_file($via['file'])) {
$checksum = hash_file('adler32', $via['file']);
} else {
@mariuswilms
mariuswilms / ievm_install.sh
Created November 30, 2009 22:04
Script to help with installing and converting MSs IE virtual machines for VirtualBox.
#!/bin/bash -x
#
# http://blog.mozmonkey.com/2008/vpc-ie6-ie7-ie8-on-mac-os-x/
# Requires: Q, VirtualBox
VERSION="$1"
IE_DOWNLOAD="http://download.microsoft.com/download/B/7/2/B72085AE-0F04-4C6F-9182-BF1EE90F5273/IE${VERSION}-XPSP3.exe"
WORK_DIR="/tmp/ievm"
mkdir $WORK_DIR
/**
* Date.parse with progressive enhancement for ISO-8601
* © 2010 Colin Snover <http://zetafleet.com>
* Released under MIT license.
*/
(function () {
'use strict';
var origParse = Date.parse;
Date.parse = function (date) {
var timestamp = origParse(date), minutesOffset = 0, struct;
@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
@mariuswilms
mariuswilms / copyright.html.php
Created October 28, 2011 19:05
Reusable Copyright Element for Lithium
@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 / 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);
#!/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 / 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=""
<div class="wrapper"><!--
--><?php $bar ? (echo 'foo') : '' ?><!--
--></div>