Skip to content

Instantly share code, notes, and snippets.

View arikon's full-sized avatar

Sergey Belov arikon

  • Yandex
  • Tivat, Montenegro
View GitHub Profile
var libxml = require('libxmljs');
var snippetXml = '<snippet><phone>123</phone><car>Ford Mondeo</car></snippet>',
snippetDoc = libxml.parseXmlString(snippetXml),
xml = '<doc id="123"></doc>',
doc = libxml.parseXmlString(xml);
doc.root().addChild(snippetDoc.root());
setTimeout(function(){
<?xml version="1.0" encoding="windows-1251"?>
<root>
<!-- Save this file with windows-1251 encoding! -->
<hello>Привет, товарищ!</hello>
</root>
diff --git a/include/cO3.h b/include/cO3.h
index 4f8ee4c..c3121d7 100644
--- a/include/cO3.h
+++ b/include/cO3.h
@@ -406,6 +406,7 @@ struct cO3 : cScr {
// unzip the downloaded module, validates it and put the dll in place
bool unpackModule(const Str& name, iStream* zipped, bool update=false )
{
+ /*
using namespace zip_tools;
var sys = require('sys'),
libxml = require('o3-xml');
var snippetXml = '<snippet><name>Sergey Belov</name><phone>+71111111111</phone><car>Ford Mondeo</car></snippet>',
snippetDoc = libxml.parseFromString(snippetXml),
xml = '<root><group><doc id="123"/></group></root>',
doc = libxml.parseFromString(xml);
// throws exception
doc.documentElement.selectSingleNode('group/doc').appendChild(snippetNode.documentElement);
var Q = require('q');
require('../lib/coa').Cmd()
.name(process.argv[0])
.helpful()
.opt()
.name('reject').title('Returns rejected promise')
.long('reject')
.flag()
.act(function(opts) {
console.log('** doing --reject act');
@arikon
arikon / cmd.js
Created September 23, 2011 11:50
require('../lib/coa').Cmd()
.name('cmd')
.title('Command test')
.helpful()
.cmd()
.name('command')
.title('Do command work')
.helpful()
.act(function() {
console.log('Doing command work...');
exports.match = function(file) {
if (isSvn(file)) return;
if (/blocks.*?/.test(file.self)) {
file.match = matchBlocksLevel;
return file.match(file);
}
};
function isSvn(file) {
return (file.self == '.svn' || /\/\.svn\//.test(file.path));
@arikon
arikon / stylus.js
Created September 21, 2012 23:00
Stylus plugin to resolve relative paths to images on @import
#!/usr/bin/env node
var S = require('stylus'),
FS = require('fs'),
URL = require('url'),
PATH = require('path');
var path = PATH.resolve('bundle.styl');
S(FS.readFileSync(path, 'utf8'))
.set('filename', path)
@arikon
arikon / bundle.deps.js
Created November 19, 2012 10:58
depsByTech
exports.deps = [
// regular deps
];
exports.depsByTechs = {
js: {
// deps for js tech of current block
bemhtml: [
// bemhtml deps for js tech of current block
]
@arikon
arikon / q-progress.js
Created November 24, 2013 13:44
deffered.notify() / promise.progress() test
var Q = require('q');
Q.thenResolve()
.then(function() {
var d = Q.defer(),
step = 0;
var interval = setInterval(function() {
d.notify('step ' + ++step);
}, 1000);