Skip to content

Instantly share code, notes, and snippets.

View jcarlosgarcia's full-sized avatar

José Carlos García jcarlosgarcia

View GitHub Profile
@jcarlosgarcia
jcarlosgarcia / gist:1555569
Created January 3, 2012 16:16
Waiting for an element to be loaded with Selenium/WebDriver
(new WebDriverWait(driver, TIMEOUT)).until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return driver.findElement(By.xpath("myXPathExpression")).isDisplayed();
}
});
@jcarlosgarcia
jcarlosgarcia / gist:1621770
Created January 16, 2012 16:55
Set system properties via Spring XML configuration
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd">
<bean id="systemProps" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetObject" value="#{@systemProperties}" />
<property name="targetMethod" value="putAll" />
@jcarlosgarcia
jcarlosgarcia / post_jersey_client.java
Created July 4, 2012 15:32
Sending a POST request to a REST service using Jersey Client
ClientConfig config = new DefaultClientConfig();
Client client = Client.create(config);
WebResource service = client.resource(getBaseURI());
MultivaluedMap<String, String> formData = new MultivaluedMapImpl();
formData.add("parameter1", "value1");
formData.add("parameter2", "value2");
ClientResponse response = service.path("resource").accept(MediaType.APPLICATION_JSON).post(ClientResponse.class, formData);
@jcarlosgarcia
jcarlosgarcia / gist:3059977
Created July 6, 2012 12:44
Sending a POST request to a REST service using Apache HttpClient
HttpClient client = new HttpClient();
String url = "url destination";
PostMethod method = new PostMethod(url);
method.setParameter("param1", "value1");
method.addParameter("param2", "value2");
client.executeMethod(method);
InputStream response = method.getResponseBodyAsStream();
@jcarlosgarcia
jcarlosgarcia / gist:4466060
Last active December 10, 2015 17:09
Compiling and installing the alx driver for an Atheros AR8161 ethernet card in Linux
cd compat-wireless-2012-02-28-p/
./scripts/driver-select alx
make
sudo make install
sudo modprobe alx
@jcarlosgarcia
jcarlosgarcia / gist:4525205
Created January 13, 2013 17:28
Installing eventmachine with SSL support and other useful gems
gem install eventmachine -- --with-ssl-dir=/usr/bin/openssl
gem install em-http-request
gem install json
@jcarlosgarcia
jcarlosgarcia / hello_world.tpl
Created June 26, 2014 20:29
M101P hello_world.tpl
<!DOCTYPE hml>
<html>
<head>
<title>Hello World!</title>
</head>
<body>
<p>
Welcome {{username}}
<p>
<ul>
@jcarlosgarcia
jcarlosgarcia / fruit_selection.tpl
Created September 16, 2014 19:51
M101P fruit_selection.tpl
<!DOCTYPE html>
<html>
<head>
<title>Fruit selection confirmation</title>
</head>
<body>
<p>
<p>
Your favorite fruit is {{fruit}}
</body>
@jcarlosgarcia
jcarlosgarcia / hello_world.tpl
Created September 16, 2014 19:56
M101P hello_world.tpl
<!DOCTYPE hml>
<html>
<head>
<title>Hello World!</title>
</head>
<body>
<p>
Welcome {{username}}
<p>
<ul>
@jcarlosgarcia
jcarlosgarcia / gridfs_example.py
Created September 14, 2015 20:53
GridFS and Bottle example
import bottle
import pymongo
import gridfs
from bottle import response
# this is the handler for the default path of the web server
@bottle.route('/img/<filename>')
def show_img(filename):