Skip to content

Instantly share code, notes, and snippets.

View thigm85's full-sized avatar

Thiago G. Martins thigm85

View GitHub Profile
require(ggplot2)
# Figure 1
ggplot(GermanCredit, aes(x = Class)) +
geom_bar(aes(y = (..count..)/sum(..count..))) +
labs(y = "prob.")
@thigm85
thigm85 / YahooFinance_odb_table.R
Last active December 17, 2015 12:09
This is the first step to establish a simple and free database to hold stock quotes downloaded from Yahoo Finance!
require(ODB)
database_path = "~/example_path/my_database.odb"
# Create a database
odb.create(database_path)
# Connect to the database
ODB <- odb.open(database_path)
require(ggplot2)
require(gridExtra)
require(reshape2)
set.seed(1)
predictors = data.frame(x1 = rnorm(1000, mean = 5, sd = 2),
x2 = rexp(1000, rate=10))
p1 = ggplot(predictors) + geom_point(aes(x = x1, y = x2))
@thigm85
thigm85 / node_js_first_application.js
Created January 20, 2016 14:23
A minimal node.js application
var http = require("http");
http.createServer(function (request, response) {
// Send the HTTP header
// HTTP Status: 200 : OK
// Content Type: text/plain
response.writeHead(200, {'Content-Type': 'text/plain'});
// Send the response body as "Hello World"
<html>
<head>
<title>File Uploading Form</title>
</head>
<body>
<h3>File Upload:</h3>
Select a file to upload: <br />
<form action="http://127.0.0.1:8081/file_upload" method="POST"
enctype="multipart/form-data">
<input type="file" name="file" size="50" />
@thigm85
thigm85 / pre_post_clean_pom.xml
Created February 17, 2016 21:25
POM file where a goal is executed in the pre-clean, clean and post-clean phases of the clean lifecycle. Reference: http://www.tutorialspoint.com/maven/maven_build_life_cycle.htm
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.companyname.projectgroup</groupId>
<artifactId>project</artifactId>
<version>1.0</version>
<build>
<plugins>
@thigm85
thigm85 / mininal-maven-pom.xml
Created February 17, 2016 21:50 — forked from torgeir/minimal-maven-pom.xml
A minimal maven pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>gd.wa</groupId>
<artifactId>minimal-pom</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
@thigm85
thigm85 / python_unittest.py
Created March 2, 2016 14:42
Code sample for writing python unit tests with the unittest module.
import unittest
# Subclass TestCase class
class TestUM(unittest.TestCase):
# Execute code prior to unit tests being run
def setUp(self):
pass
# create unit tests using assert methods
<?xml version="1.0"?>
<data>
<country name="Liechtenstein">
<rank>1</rank>
<year>2008</year>
<gdppc>141100</gdppc>
<neighbor name="Austria" direction="E"/>
<neighbor name="Switzerland" direction="W"/>
</country>
<country name="Singapore">
import xml.etree.ElementTree as ET
# parse XML from a file
tree = ET.parse(file_path) # parse the file and obtain ElementTree obj
root = tree.getroot() # get the root Element obj
# parse XML in a string format
root = ET.fromstring(country_data_as_string)
root = ET.XML(country_data_as_string) # equivalent to above