Skip to content

Instantly share code, notes, and snippets.

/**
* Implements callback_redirect_form().
*/
function commerce_monogram_redirect_form($form, &$form_state, $order, $payment_method) {
$wrapper = entity_metadata_wrapper('commerce_order', $order);
switch ($payment_method['method_id']) {
case 'monogram_tatrapay_tb':
break;
case 'monogram_eplatby_vub':
@havran
havran / Crb.rb
Last active August 29, 2015 14:17
Simple Ruby on Rails 4 model with ElasticSearch query.
require 'elasticsearch/model'
class Cbr
include ActiveModel::Model
include Elasticsearch::Model
index_name 'cbr'
document_type 'UC_CBR_003'
# Digital Objects per day
# Store CBRFilter objects
#
class CBRFilters
include Enumerable
extend Forwardable
attr_accessor :filters
def_delegators :@filters, :each, :size, :<<, :push
#!/bin/bash
# CentOS rbenv system wide installation script
# Forked from https://gist.github.com/1237417
# Installs rbenv system wide on CentOS 5/6, also allows single user installs.
# Install pre-requirements
yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel \
make bzip2 autoconf automake libtool bison iconv-devel git-core
{
"head": [
{
"CoType": "CoType",
"objects": "objects",
"objects_avg_quality": "objects_avg_quality"
}
],
"rows": [
{
@havran
havran / pluck_to_hash_example.rb
Created April 8, 2016 09:00
GEM pluck to hash example
if @records
posts = @records.map{|p| p.post_id}
posts_extra_data = Message::Post
.joins(
'LEFT JOIN "message_webs" ON "message_webs"."post_id" = "message_posts"."id"',
'LEFT JOIN "source_sources" ON "source_sources"."id" = "message_posts"."source_source_id"',
'LEFT JOIN "source_sections" ON "source_sections"."id" = "message_posts"."source_section_id"'
)
.where(id: posts)
# Spustit cez []->Source
#
library(curl)
library(jsonlite)
# Zistime si meno adresara v ktorom sa nachadza subor so scriptom
sourceDir <- getSrcDirectory(function(dummy) {dummy})
# Vlozime script s funciami pre geocoding.
source(paste(sourceDir, '/', 'geocoding.R', sep = ''))
# Geocoding script for large list of addresses.
# Shane Lynn 10/10/2013
#load up the ggmap library
library(ggmap)
# get the input data
infile <- "input"
data <- read.csv(paste0('c:\\Temp\\R scripts\\', infile, '.csv'), fileEncoding = "UTF-8")
# get the address list, and append "Ireland" to the end to increase accuracy
var createSubmitForm = function(path, parameters, method = 'POST') {
var form = $('<form></form>');
form.attr('action', path);
form.attr('method', method);
parameters.authenticity_token = $('meta[name="csrf-token"]').attr('content');
for (var key in parameters) {
if (parameters.hasOwnProperty(key)) {
@havran
havran / sort-columns-in-row.sql
Last active February 8, 2017 05:09
PostgreSQL - sort columns in row
-- Table: public.testy
-- DROP TABLE public.testy;
CREATE TABLE public.testy
(
id integer NOT NULL DEFAULT nextval('testy_id_seq'::regclass),
prod1 integer,
prod2 integer,
prod3 integer,