Skip to content

Instantly share code, notes, and snippets.

View gcpantazis's full-sized avatar

George Pantazis gcpantazis

View GitHub Profile
@gcpantazis
gcpantazis / rabbit-mq-test.js
Created March 6, 2014 06:56
Demonstration on using topic exchanges in AMQP (RabbitMQ) to chunk data at a remote server, and route a response back to the appropriate process. For use in scalable user-facing servers.
'use strict';
var amqp = require('amqp');
var connection = amqp.createConnection({
url: process.env.RABBITMQ_EVENT_BUS
});
// Randomly generate a routing key. Let's say this is for "posts"
@gcpantazis
gcpantazis / ironmq_test.js
Created March 4, 2014 00:38
Brutish, unoptimized test of IronMQ with NodeJS.
'use strict';
//Testing IronMQ
var _ = require('underscore');
var msgBus = require('iron_mq');
var imq = new msgBus.Client({
'token': process.env.IRON_MQ_TOKEN,
'project_id': process.env.IRON_MQ_ID
});
@gcpantazis
gcpantazis / bounceback.js
Created March 3, 2014 05:35
Quick set of scripts to get some performance tests out of redis pubsub.
'use strict';
var redis = require('redis'),
url = require('url'),
clientUrlParsed = url.parse(process.env.REDIS_POST_EVENT_BUS),
clientPost = redis.createClient(clientUrlParsed.port, clientUrlParsed.hostname, {
'auth_pass': clientUrlParsed.auth.split(':')[1]
}),
(function(_, Enquire) {
'use strict';
window.BackboneEnquireMixin = {
enquire: function(breakpoints) {
var breakpoint, handler, method, _i, _len, _ref;
if (!breakpoints) {
breakpoints = this.breakpoints;
@gcpantazis
gcpantazis / countries.json
Created January 14, 2014 19:54
All the countries of the world
{
"afghanistan": {
"lat": 33,
"lng": 65
},
"albania": {
"lat": 41,
"lng": 20
},
"algeria": {
@gcpantazis
gcpantazis / gist:8050383
Created December 20, 2013 04:22
Unregistering and re-registering ngBlur.
var noopDirective = function() {
return function() {};
};
module.factory('ngBlurDirective', noopDirective);
module.directive('ngBlur', ['$parse',
function($parse) {
return {
compile: function($element, attr) {
@gcpantazis
gcpantazis / backup_dependencies
Last active December 27, 2015 12:19
Packaging dependencies (NPM/Bower) for CI and Heroku.
tar -cz -f modules.tar.gz node_modules/ bower_components/
scp modules.tar.gz username@www.myserver.com:/usr/share/www/ci-support
rm modules.tar.gz
@gcpantazis
gcpantazis / _template-fixtures.js.html
Created November 4, 2013 19:30
Yeoman templates for specs with templates, Bliss structure.
<script id="<%= dashName %>-fixture" type = "text/template">
@Html.Partial("app/modules/<%= dashName %>/html/<%= dashName %>")
</script>
@gcpantazis
gcpantazis / version-update.js
Last active December 25, 2015 00:48
Semantic version update for projects with a package.json in the target folder.
// Semantic Versioning Tool
// ========================
//
// See: http://semver.org/
// For projects with package.json in the target folder.
//
// * Author: George Pantazis
//
// * Usage:
// * Major (0.x.x -> 1.0.0) : `node version-update major`
@gcpantazis
gcpantazis / gist:6833091
Last active December 24, 2015 17:09
Element scrolled into view, with a 100 pixel threshold.
var checkActive = function(el) {
var self = this,
elRect = el.getBoundingClientRect(),
winRect = document.documentElement.getBoundingClientRect(),
isNearBottom = winRect.bottom - elRect.bottom < 100 && $(document).height() - ($(window).scrollTop() + $(window).height()) < 100;
if (elRect.top < 100 && elRect.top > 0 || isNearBottom) {
// Element is scrolled into view.
}