Skip to content

Instantly share code, notes, and snippets.

View jcarlosgarcia's full-sized avatar

José Carlos García jcarlosgarcia

View GitHub Profile
import base64
code="aW1wb3J0IHB5bW9uZ28NCmltcG9ydCByYW5kb20NCmltcG9ydCByZQ0KaW1wb3J0IHN0cmluZw0KaW1wb3J0IHN5cw0KaW1wb3J0IGdldG9wdA0KaW1wb3J0IHBwcmludA0KDQojIENvcHlyaWdodCAyMDE1DQojIE1vbmdvREIsIEluYy4NCiMgQXV0aG9yOiBBbmRyZXcgRXJsaWNoc29uICAgYWplQDEwZ2VuLmNvbQ0KIw0KIyBJZiB5b3UgYXJlIGEgc3R1ZGVudCBhbmQgcmVhZGluZyB0aGlzIGNvZGUsIHR1cm4gYmFjayBub3csIGJlZm9yZQ0KIyB0aGUgTW9uZ29EQiBnb2RzIHNtaXRlIHlvdS4NCg0KY29ubmVjdGlvbiA9IE5vbmUNCmRiID0gTm9uZQ0KbW9uZ29zdHIgPSAibW9uZ29kYjovL2xvY2FsaG9zdDoyNzAxNyINCmRiX25hbWUgPSAiYWRtaW4iDQpyc19uYW1lID0gIm0xMDEiDQoNCiMgdGhpcyBzY3JpcHQgd2lsbCBjaGVjayB0aGF0IGEgcmVwbGljYSBzZXQgd2l0aCB0aHJlZSBub2RlcyBpcyBydW5uaW5nIG9uIGEgaG9zdA0KDQojIGNvbW1hbmQgbGluZSBhcmcgcGFyc2luZyB0byBtYWtlIGZvbGtzIGhhcHB5IHdobyB3YW50IHRvIHJ1biBhdCBtb25nb2xhYnMgb3IgbW9uZ29ocQ0KIyB0aGlzIGZ1bmN0aW9ucyB1c2VzIGdsb2JhbCB2YXJzIHRvIGNvbW11bmljYXRlLiBmb3JnaXZlIG1lLg0KZGVmIGFyZ19wYXJzaW5nKGFyZ3YpOg0KDQogICAgZ2xvYmFsIHdlYmhvc3QNCiAgICBnbG9iYWwgbW9uZ29zdHINCiAgICBnbG9iYWwgZGJfbmFtZQ0KDQogICAgdHJ5Og0KICAgICAgICBvcHRzLCBhcmdzID0gZ2V0
@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):
@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 / 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 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 / 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 / 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: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 / 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: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" />