Skip to content

Instantly share code, notes, and snippets.

View valentinkostadinov's full-sized avatar

Valentin Kostadinov valentinkostadinov

View GitHub Profile
@valentinkostadinov
valentinkostadinov / seo-server.js
Created May 17, 2014 20:32
PhantomJS SEO HTML snapshot server - for AJAX crawling / JavaScript SEO
/*
* SEO server
*
* Generates and serves HTML snapshots for crawlers, esp. GoogleBot.
* See https://developers.google.com/webmasters/ajax-crawling/docs/specification
*
* Note: This is run by phantonjs, not node. See http://phantomjs.org
*
*/
var system = require('system')
@valentinkostadinov
valentinkostadinov / seo-express-filter.js
Last active August 29, 2015 14:01
AJAX crawling / JavaScript SEO for MEAN stack web apps
/*
* Redirect _escaped_fragment_ requests to SEO server for HTML snapshots
*
* Place in your middleware stack. Watch out for correct placement:
* - after any static handler
* - before app routes (router)
*
* app.use(require('./seo-express-filter')(app))
*
*/
@valentinkostadinov
valentinkostadinov / hex.js
Created June 27, 2013 10:29
JavaScript HEX encoding
function toHex(s) {
// utf8 to latin1
var s = unescape(encodeURIComponent(s))
var h = ''
for (var i = 0; i < s.length; i++) {
h += s.charCodeAt(i).toString(16)
}
return h
}
@valentinkostadinov
valentinkostadinov / .conkyrc
Last active October 28, 2021 09:14
My .conkyrc file - minimalist conky config.
conky.config = {
background = true,
double_buffer = true,
alignment = 'top_right',
draw_shades = false,
use_xft = true,
font = 'Noto Mono:size=9',
minimum_width = 120,
maximum_width = 120,
gap_y = 150,
@valentinkostadinov
valentinkostadinov / WorkerPool.js
Created January 15, 2013 09:29
A simple HTML5 web worker pool (think thread pool) implementation for parallel execution of computationally intensive operations. The pool will lazily grow up to its given capacity. On saturation, messages will be queued up until a worker from the pool becomes available. The interface hides the Worker listener pattern and instead provides a sing…
/**
* A web worker pool implementation for parallel execution of
* computationally intensive operations. The pool will lazily grow up to its
* given capacity. On saturation, messages will be queued up until a worker
* from the pool becomes available.
*
* var capacity = 3;
* var pool = new WorkerPool(capacity, "./worker.js");
* for (var i = 0; i < 10; i++) {
* pool.postMessage(msg, function(err, result) {