Skip to content

Instantly share code, notes, and snippets.

@Dither
Dither / cssify.js
Created February 25, 2012 17:38
Convert XPath to CSS selector
// JavaScript function for converting simple XPath to CSS selector.
// Ported by Dither from [cssify](https://github.com/santiycr/cssify)
// Example: `cssify('//div[@id="girl"][2]/span[@class="body"]//a[contains(@class, "sexy")]//img[1]')`
var sub_regexes = {
"tag": "([a-zA-Z][a-zA-Z0-9]{0,10}|\\*)",
"attribute": "[.a-zA-Z_:][-\\w:.]*(\\(\\))?)",
"value": "\\s*[\\w/:][-/\\w\\s,:;.]*"
};
@maxcnunes
maxcnunes / Debug-Knockout-JS.html
Last active May 22, 2024 11:08
Simple way to debug viewmodel data bind with knockout
<pre data-bind="text: ko.toJSON($data, null, 2)"></pre>