Skip to content

Instantly share code, notes, and snippets.

View antonio's full-sized avatar

Antonio Santos antonio

View GitHub Profile
@antonio
antonio / gist:736170
Created December 10, 2010 12:53
SeleniumMagic
public void drupalNodeCollectionXmlValidationWithContents()
throws IOException, DocumentException, InterruptedException {
DrupalGenerateContentsPage page = PageFactory.initElements(driver,
DrupalGenerateContentsPage.class);
page.open(drupalUrl);
page.unselectAllTypeCheckboxes();
page.selectCheckbox("node_types[node_test]");
page.selectCheckbox("kill_content");
page.setNumNodes(10);
page.setNodesNow();
@antonio
antonio / OpenCmsCollectionMetadata.java
Created February 23, 2011 10:35
OpenCms Collection Metadata Basic implementation
import java.util.Properties;
import es.juntadeandalucia.icms.data.AbstractCollectionMetadata;
import es.juntadeandalucia.icms.exceptions.ICMSException;
import groovy.util.ConfigObject;
public class OpenCmsCollectionMetadata extends AbstractCollectionMetadata<OpenCmsResourceMetadataCollection, OpenCmsResourceMetadata> {
final static String STRUCTURED_CONTENT_CONFIG_STRING = "structured_content_type";
public OpenCmsCollectionMetadata(final String providerId, final String id, final ConfigObject config) throws ICMSException {
@antonio
antonio / color-theme-tango.el
Created March 2, 2011 18:08
Emacs Tango color theme
;;; Color theme based on Tango Palette. Created by danranx@gmail.com
(defun color-theme-tango ()
"A color theme based on Tango Palette."
(interactive)
(color-theme-install
'(color-theme-tango
((background-color . "#2e3436")
(background-mode . dark)
(border-color . "#888a85")
(cursor-color . "#ffffff")
@antonio
antonio / gist:1400271
Created November 28, 2011 12:46
Automatically configure screens
#!/usr/bin/env ruby
EXTERNAL_SCREEN = 'VGA1'
LAPTOP_SCREEN = 'LVDS1'
def use_external_screen
system "xrandr --output #{EXTERNAL_SCREEN} --auto && xrandr --output #{LAPTOP_SCREEN} --off"
end
def use_laptop_screen
@antonio
antonio / TestCache.java
Created December 14, 2011 10:37 — forked from alecarrod/TestCache.java
Problem spying cache
Test Code:
package es.juntadeandalucia.icms.server.cache;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.internal.verification.VerificationModeFactory.atLeastOnce;
import static org.mockito.internal.verification.VerificationModeFactory.times;
@antonio
antonio / codility-demo-1.rb
Last active July 26, 2017 18:16
Codility Demos
def equi ( a )
return -1 if (a.nil? || a.empty?)
lower_sum = 0
higher_sum = 0
a.each { |x| higher_sum += x }
a.each_index do |p|
lower_sum += a[p-1] if p!=0
@antonio
antonio / gist:1527939
Created December 28, 2011 13:29
getList method in ConfigurationUtil
/**
* Returns the value of key as a String list. For example, it would return
* my_property = [ "first_element", "second_element" ]
* as new ArrayList<String>(){{ add("first_element"); add("second_element") }};
* @param key The key to return
* @return The List of values
*/
public static List<String> getList(String key) {
final List<String> result = new ArrayList<String>();
String rawString = getConfig(key);
@antonio
antonio / wottam.rb
Created March 1, 2012 13:20 — forked from juanghurtado/wottam.rb
Wottam description
def wottam
3.times { puts "AWESOME!" }
end
@antonio
antonio / git-validate
Created June 14, 2012 19:45
Example script showing how to extend git with new commands
#!/bin/sh
branch=$1
test -z $branch && echo "branch required." 1>&2 && exit 1
git checkout master
git merge $branch
git push origin master
git push origin :$branch
@antonio
antonio / 1.9.3-p286-perf
Created October 22, 2012 17:32
Ruby 1.9.3-p286 with the latest falcon patch
build_package_combined_patch() {
local package_name="$1"
{
curl https://raw.github.com/gist/3721565/falcon.patch | patch -p1
autoconf
./configure --prefix="$PREFIX_PATH" $CONFIGURE_OPTS
make -j 8
make install
} >&4 2>&1