Skip to content

Instantly share code, notes, and snippets.

View kostajh's full-sized avatar

Kosta Harlan kostajh

View GitHub Profile
Security Updates Best Practices
==================================
The general workflow for running security updates is:
1. Make sure your local development environment for the site is up-to-date (sync the database from production, if needed)
1. If the site hasn't been managed for a long time, use `drush rsync @example.prod @example.local` (using the `--exclude` flag to exclude large directories like `sites/default/files`). Then type `git status`. If there are any unmanaged files, add them to version control.
2. In your local environment, run `drush up --security-only`.
1. Look at the list of packages that will be updated. Go to each project page on Drupal.org and read the release notes.
2. You may need to read several versions worth of release notes. You want to see if there are mentions of breaking changes or any changes to features/functionality your site uses. This is usually the most time consuming and difficult part of running the updates.
@kostajh
kostajh / phpstorm-tuxjdk.patch
Created October 28, 2014 15:50
PhpStorm TuxJDK patch
diff -u PhpStorm/bin/phpstorm64.vmoptions PhpStorm.bak/bin/phpstorm64.vmoptions
--- PhpStorm/bin/phpstorm64.vmoptions 2014-10-22 23:36:30.000000000 -0400
+++ PhpStorm.bak/bin/phpstorm64.vmoptions 2014-10-17 15:16:05.857777854 -0400
@@ -8,4 +8,6 @@
-Djsse.enableSNIExtension=false
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=50
--Dawt.useSystemAAFontSettings=lcd
+-Dawt.useSystemAAFontSettings=gasp
+-Dswing.aatext=true
@kostajh
kostajh / bump-versions.php
Created October 21, 2014 15:27
git flow bump versions script
<?php
/**
* @file
* Drush script for bumping versions according to a git release.
*/
// Get the context.
$context = drush_get_context();
if (!$context['alias']) {
@kostajh
kostajh / smart-features-revert.php
Created September 11, 2014 20:38
Use with Jenkins. Add this as a build step.
<?php
// This script analyzes the files affected between GIT_PREVIOUS_COMMIT and
// GIT_COMMIT. See https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin for
// more information on these parameters.
// If the files affected are in the /features directory, then we will call
// `drush features-revert {feature}` for each feature affected.
// Why is this necessary? Because `features-revert-all` will revert every
// feature on your site; we only want to revert features that are overridden.
/**

Keybase proof

I hereby claim:

  • I am kostajh on github.
  • I am kosta (https://keybase.io/kosta) on keybase.
  • I have a public key whose fingerprint is F809 9E36 EF23 7A0F 392A 469D 921B 04B1 FFEE D3F7

To claim this, I am signing this object:

<?php
/**
* Write JSON encoded data to disk.
*/
protected function writeJson($filename, $data) {
if (!file_exists($this->getJsonDirectory())) {
if (!drush_mkdir($this->getJsonDirectory())) {
return drush_set_error('NO_JSON_DIR', dt('Unable to create JSON directory at !file', array('!file' => $this->getJsonDirectory())));
}
}
<?php
/**
* Read a CSV file.
*/
public function readCSV($file) {
$data = array();
if (file_exists($file)) {
$file_handle = fopen($file, 'r');
while (!feof($file_handle)) {
<?php
$headers = array();
foreach ($xml->ROW->children() as $field) {
$headers[] = $field->getName();
}
$csv_filename = str_replace('xml', 'csv', $filename);
$file = $this->getCsvDirectory() . '/' . $csv_filename;
if (file_exists($file)) {
@kostajh
kostajh / example_api.module
Created March 24, 2014 15:29
Example API for redirecting CasperJS to Drupal data.
<?php
/**
* Implements hook_menu().
*/
function example_api_menu() {
$items = array();
$items['api'] = array(
'page callback' => 'example_api_redirect',
'page arguments' => array(1, 2),
// Publication Authors
casper.test.begin('Verifying Publication Authors entity migration', function suite(test) {
// Load the JSON document.
var json = require(json_dir + '/' + datestamp + '/PUB_AUTHORS2.json');
var pubAuthorJoin = require(json_dir + '/' + datestamp + '/PUB_AUTHORS.json');
var currentRow = 0;
// Run the test.
casper.run(check);