Skip to content

Instantly share code, notes, and snippets.

View iurevych's full-sized avatar
💭
Helping great companies grow 🚀

Sergii Iurevych iurevych

💭
Helping great companies grow 🚀
View GitHub Profile
@sstur
sstur / dom-to-json.js
Last active October 8, 2023 04:17
Stringify DOM nodes using JSON (and revive again)
function toJSON(node) {
let propFix = { for: 'htmlFor', class: 'className' };
let specialGetters = {
style: (node) => node.style.cssText,
};
let attrDefaultValues = { style: '' };
let obj = {
nodeType: node.nodeType,
};
if (node.tagName) {
@shaneriley
shaneriley / gist:1157075
Created August 19, 2011 15:28
Haml2Html
require "hpricot"
require "open-uri"
Dir.glob('app/views/ui/*.html.haml').sort.each do |file|
route = file.gsub(/(\.html\.haml)|(app\/views)/, "")
filename = file.gsub(/(app\/views\/ui)|(\.haml)/, "")
unless route.match(/\/index/)
dom = Hpricot(open("http://localhost:3000#{route}"))
`mkdir static` unless File.directory?("static")
output = File.new("static#{filename}", "w")