Skip to content

Instantly share code, notes, and snippets.

@wimvds
wimvds / moveToGitHub.bash
Created July 25, 2011 08:51 — forked from roderik/moveToGitHub.bash
./moveToGitHub <githuburl>
#! /bin/bash
export $GITHUBURL="$1"
# clean up remote branch list
git fetch origin; git remote prune origin
# delete all local branches except master
git checkout master; git pull; git branch | while read repo; do branch=`echo "$repo" | cut -d" " -f 2`; if [ ! $branch == 'master' ]; then git branch -D $branch; fi; done; git gc
@wimvds
wimvds / gist:3987685
Last active October 12, 2015 06:48 — forked from roderik/gist:2868838
<?php
if (in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1', @$_SERVER['SERVER_ADDR']))) {
apc_clear_cache('user');
apc_clear_cache('opcode');
echo json_encode(array('success' => true));
} else {
die('SUPER TOP SECRET');
}
@wimvds
wimvds / dumpsitemap
Last active December 15, 2015 11:38
Fetch & dump all URLs from a Google XML sitemap
#!/usr/bin/env php
<?php
if ($argc !== 2) {
print "SYNTAX :\n";
print ' ' . $argv[0] . ' <url>';
print "\n";
return 0;
}
@wimvds
wimvds / gist:5300543
Last active December 15, 2015 17:59
Move all Drupal modules in sites/all/modules to sites/all/modules/contrib
#!/bin/bash
# First install registry_rebuild : drush dl registry_rebuild
# Execute the following :
for dir in */; do dir=${dir%*/}; if [ "custom" != "${dir}" -a "contrib" != "${dir}" ]; then mv ${dir} contrib/${dir}; fi; done
# Run registry_rebuild and clear all caches : drush rr && drush cc all
# Fingers crossed...
# To update your git repo afterwards, just use : git add -u
@wimvds
wimvds / bootstrap.sh
Last active December 16, 2015 06:58 — forked from roderik/bootstrap.sh
# FIRST: Install Vagrant (http://www.vagrantup.com/)
# and VirtualBox (https://www.virtualbox.org/)
#
# make sure the librarian gem is installed
gem install librarian-chef
# if you use rbenv you need to execute to make the librarian-chef command available:
# $ rbenv rehash
# checkout the sandbox from GitHub
git clone https://github.com/Kunstmaan/KunstmaanSandbox.git
# move into the sandbox folder
@wimvds
wimvds / test-composer-project-locally.md
Last active May 19, 2023 13:33
Test an existing composer project (create-project) locally

First, clone the repository of the project :

  mkdir /tmp/project-name
  git clone ...

Create a packages.json file in the root, containing the following :

@wimvds
wimvds / parameters.yml
Created October 28, 2013 15:21
Parameters.yml
parameters:
database_driver: pdo_mysql
database_host: localhost
database_port: ~
database_name: sandbox
database_user: sandbox
database_password: sandbox
mailer_transport: smtp
mailer_host: localhost
mailer_user: ~
@wimvds
wimvds / curlmirror.pl
Created October 15, 2014 11:35
Curl mirror
#!/usr/bin/perl
#
# curlmirror.pl
#
# Mirrors a web site by using curl to download each page.
# The result is stored in a directory named "dest" by default.
# Temporary files are stored in "/tmp".
#
# Author: Kjell.Ericson@haxx.se
#
@wimvds
wimvds / validateFormFields.php
Last active August 29, 2015 14:11
Validate form fields without submitting data
private function validateForm(Form $form, $entity, $groups = array('submission'))
{
$errors = $this->get('validator')->validate($entity, $groups, true, true);
foreach ($errors as $error) {
$propertyPath = $error->getPropertyPath();
if (strpos($propertyPath, '[') !== false || strpos($propertyPath, '.') !== false) {
/**
* Very dirty form field parser
*
* teamMember[0].role is converted to teamMember.0.role
@wimvds
wimvds / reflection-test.php
Last active August 29, 2015 14:22
Reflection vs real object instances performance
<?php
define('NUM_TESTS', 10);
header('Content-type: text/plain');
interface FooInterface
{
}