Skip to content

Instantly share code, notes, and snippets.

View rafaqz's full-sized avatar

Rafael Schouten rafaqz

  • Center for Macroecology, Evolution and Climate
  • Copenhagen
View GitHub Profile
@rafaqz
rafaqz / growshare_feeds.patch
Last active December 18, 2015 17:39
Drupal Feeds Patch to add location and group handling
diff --git a/plugins/FeedsProcessor.inc b/plugins/FeedsProcessor.inc
index c2b0af5..7bcd238 100755
--- a/plugins/FeedsProcessor.inc
+++ b/plugins/FeedsProcessor.inc
@@ -178,6 +178,25 @@ abstract class FeedsProcessor extends FeedsPlugin {
$state = $source->state(FEEDS_PROCESS);
while ($item = $parser_result->shiftItem()) {
+ //hack to get location target id from feed source
+ if ($source->config["FeedsCSVParser"]) {
@rafaqz
rafaqz / growshare_feeds_xls_case.patch
Last active December 18, 2015 17:39
Adds better case handling to feeds xls. Probably should make an issue on drupal.org...
diff --git a/FeedsExcelParser.inc b/FeedsExcelParser.inc
index 3a0e5da..29d66c0 100644
--- a/FeedsExcelParser.inc
+++ b/FeedsExcelParser.inc
@@ -102,7 +102,7 @@ class FeedsExcelParser extends FeedsParser{
$cellIterator->setIterateOnlyExistingCells(false); // Loop all cells, even if it is not set
foreach($cellIterator as $cell){
if(!is_null($cell)){
- $headers[] = trim($cell->getCalculatedValue());
+ $headers[] = trim(drupal_strtolower($cell->getCalculatedValue()));
@rafaqz
rafaqz / zurb-foundation-extra-layouts.patch
Last active January 11, 2016 13:12
A patch to add extra panels layouts to the drupal zurb-foundation theme
diff --git a/layouts/foundation_2col_stacked_narrow_r/foundation-2col-stacked-narrow-r.tpl.php b/layouts/foundation_2col_stacked_narrow_r/foundation-2col-stacked-narrow-r.tpl.php
new file mode 100644
index 0000000..39eed1e
--- /dev/null
+++ b/layouts/foundation_2col_stacked_narrow_r/foundation-2col-stacked-narrow-r.tpl.php
@@ -0,0 +1,44 @@
+<?php
+/**
+ * @file
+ * Template for a 2 column panel layout.
@rafaqz
rafaqz / fix_queue.patch
Created May 23, 2014 11:43
Patches drupal message subscribe module to fix queue
diff --git a/message_subscribe.module b/message_subscribe.module
index da35358..026a2dc 100755
--- a/message_subscribe.module
+++ b/message_subscribe.module
@@ -152,30 +152,26 @@ function message_subscribe_send_message($entity_type, $entity, Message $message,
message_notify_send_message($cloned_message, $options, $notifier_name);
// Check we didn't timeout.
- if ($use_queue && $subscribe_options['queue']['end time'] && time() < $subscribe_options['queue']['end time']) {
- continue 2;
;
; This is a stub make file that downloads the OFF install profile.
;
core = 7.x
api = 2
projects[drupal][version] = "7.28"
; +++++ Profiles +++++
@rafaqz
rafaqz / fortran-julia.jl
Last active March 17, 2024 21:34
Fortran-Julia conversion script
#=
This julia script converts fortran 90 code into julia.
It uses naive regex replacements to do as much as possible,
but the output WILL need further cleanup.
Known conversion problems such as GOTO are commented and marked with FIXME
Most variable declaration lines are entirely deleted, which may or
may not be useful.
julia> sol = solve(prob, FunctionMap(scale_by_time = true)); nothing
ERROR: UndefVarError: photosynthesize not defined
Stacktrace:
[1] assimilation!(::DynamicEnergyBudgets.Organ{DynamicEnergyBudgets.StatePVMCNE{Unitful.Quantity{Float64,Unitful.Dimensions{(Unitful.Dimension{:Amount}(1//1),)},Unitful.FreeUnits{(Unitful.Unit{:Mole,Unitful.Dimensions{(Unitful.Dimension{:Amount}(1//1),)}}(0, 1//1),),Unitful.Dimensions{(Unitful.Dimension{:Amount}(1//1),)}}}},DynamicEnergyBudgets.Params{Unitful.Quantity{Float64,Unitful.Dimensions{(Unitful.Dimension{:Amount
}(-1//1), Unitful.Dimension{:Mass}(1//1))},Unitful.FreeUnits{(Unitful.Unit{:Gram,Unitful.Dimensions{(Unitful.Dimension{:Mass}(1//1),)}}(0, 1//1), Unitful.Unit{:Mole,Unitful.Dimensions{(Unitful.Dimension{:Amount}(1//1),)}}(0, -1//1)),Unitful.Dimensions{(Unitful.Dimension{:Amount}(-1//1), Unitful.Dimension{:Mass}(1//1))}}},DynamicEnergyBudgets
@rafaqz
rafaqz / loadraster.jl
Last active June 15, 2018 03:33
Load a world raster with ArchGDAL and crop australia
using ArchGDAL
function readtiff(file)
img = ArchGDAL.registerdrivers() do
ArchGDAL.read(file) do dataset
ArchGDAL.read(dataset)
end
end
img ./= maximum(img)
img .= max.(0.0, img)
@rafaqz
rafaqz / makefile
Created August 3, 2018 02:29
A makefile for pandoc.
## Put this Makefle in your project directory---i.e., the directory
## containing the paper you are writing. Assuming you are using the
## rest of the toolchain here, you can use it to create .html, .tex,
## and .pdf output files (complete with bibliography, if present) from
## your markdown file.
## - Using `make` without arguments will generate html, tex, and pdf
## output files from all of the files with the designated markdown
## extension. The default is `.md` but you can change this.
## - You can specify an output format with `make tex`, `make pdf` or
## - `make html`.
using Unitful, Base.Filesystem, HDF5, Dates
using Unitful: °C, K, hr, d
using Base: tail
# Fix unitful handling of missing
import Base.*
*(::Missing, ::T) where {T<:Unitful.Units} = missing
*(::T, ::Missing) where {T<:Unitful.Units} = missing