Skip to content

Instantly share code, notes, and snippets.

function getFuelPrices() {
var tableBody = document.querySelectorAll('body table table table table')[1].childNodes[1];
var data = [];
for (var i = 1; i <= 5; i = i + 2) {
var row = {
label: tableBody.childNodes[i].childNodes[1].childNodes[0].data,
price: tableBody.childNodes[i].childNodes[3].childNodes[0].data
};
data.push(row);
}
@audacus
audacus / CustomDeserializer.java
Last active October 11, 2016 22:42
Example solution for stackoverflow question: http://stackoverflow.com/q/39986844/3442851
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import com.fasterxml.jackson.databind.module.SimpleModule;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
@audacus
audacus / ConeStuff.java
Last active October 11, 2016 22:46
Example solution for stackoverflow question: http://stackoverflow.com/q/39986249/3442851
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
/*
output:
** cones before **
label: bar
height: 13.37
@audacus
audacus / vanilla-js-ajax.js
Last active May 17, 2024 12:37
Template for making a AJAX request with vanilla JavaScript.
// create request object
var xhttp = new XMLHttpRequest();
// set params
var method = 'GET' || 'DELETE' || 'POST' || 'PUT' || 'PATCH';
var url = 'controller/action';
var asynchronous = true;
// open request
xhttp.open(method, url, asynchronous);
// set ajax headers
xhttp.setRequestHeader('X-Requested-With', 'XMLHttpRequest');