I'm extracting data from a website and was testing some XPath expressions in Chrome Developer Tools (using $x(...)
in console). After creating the expressions I need, I've automated the process using lxml to extract this data using Python. Problem: the number of results in lxml is different from the number I've got using Developer Tools! It seems lxml delete some data and adds a lot of </table>
in the end (doing the process of loading the HTML into an lxml.html.Element
and then extracting it using lxml.html.tostring
results in completely different HTMLs - the majority of the data is removed).
The HTML is attached in this gist (e-SIC.html
) and the XPath is the following: //table[@class="padrao"]
.
I've tested the XPath in Developer Tools by executing the code in console: $x('//table[@class="padrao"]').length
- it returns 2496
.
const createChat = ({ | |
id = 0, | |
msg = '', | |
user = 'Anonymous', | |
timeStamp = 1472322852680 | |
} = {}) => ({ | |
id, msg, user, timeStamp | |
}); | |
const createState = ({ |
It's frustrating to decipher the websocket frames in Chrome Dev Tools, so I setup a workflow to use Sublime Text to display the frames as JSON.
- Sublime Text installed
- Package PrettyJSON is installed (https://github.com/dzhibas/SublimePrettyJson)
- Package RegReplace is installed (https://github.com/facelessuser/RegReplace)
var sequelize = new Sequelize('postgres:/tmp'); | |
var CM = sequelize.transactionManager.ConnectorManager; | |
sequelize.transactionManager.ConnectorManager = function (sequelize, config) { | |
var cm = new CM(sequelize, config); | |
cm.pg.defaults.database = 'database_name'; | |
return cm; | |
} | |
sequelize.getQueryInterface().QueryGenerator |
Just like how we use Git to version control source code, we use migrations to manage the state of our database schemas.
Imagine you're working on project with another developer, and you're both tasked with creating a specific part of an event planning application. Let's say you are in charge of creating the Users
and your friend is going to create the Events
.
Let's say you and your friend divided the work in a way so that neither of you will have to to use each other's code to finish your tasks. While you're working on your part of the application, you only really need to touch the Users
table when you are working with the database.
Make sure that the project you are in is a node project (it has a package.json
) and you have already installed and initialized sequelize (npm install --save sequelize
, sequelize init
). Also make sure that your config.json
file has the correct credentials to connect to your database.
javascript:(function () { | |
//Served by rawgit: https://rawgit.com/ | |
//From https://gist.github.com/theredpea/d08d5918a8c88889dfa26ad72dd17140#file-adapting_showobjectids-js | |
//To https://cdn.rawgit.com/theredpea/d08d5918a8c88889dfa26ad72dd17140/raw/9b32a0d0ac9e1a9cc85005fcbf83e20275d99fd4/adapting_showObjectIds.js | |
document.body.appendChild(document.createElement('script')).src = 'https://rawgit.com/abodelot/jquery.json-viewer/master/json-viewer/jquery.json-viewer.js'; | |
var head = document.getElementsByTagName('head')[0]; | |
$(document.createElement('link')).attr({ | |
type: 'text/css', | |
href: 'https://rawgit.com/abodelot/jquery.json-viewer/master/json-viewer/jquery.json-viewer.css', | |
rel: 'stylesheet' |
'use strict'; | |
var path = require('path'); | |
var fontnik = require('../'); | |
var Benchmark = require('benchmark'); | |
var opensans = path.resolve(__dirname + '/../fonts/open-sans/OpenSans-Regular.ttf'); | |
var suite = new Benchmark.Suite(); |
license: mit | |
height: 2000 | |
scrolling: yes |
,\s*?\]|,\s+} |
<!DOCTYPE html> | |
<html> | |
<head> | |
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script> | |
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> | |
</head> | |
<body> | |
<table id="split"> | |
<thead></thead> | |
<tbody></tbody> |