Skip to content

Instantly share code, notes, and snippets.

View gcpantazis's full-sized avatar

George Pantazis gcpantazis

View GitHub Profile
// views needed, generated by the back-end.
var views = ['an', 'array', 'of', 'views'];
require(['libraries'], function () {
require(['global', 'plugins'], function(){
require(['models', 'collections'], function(){
require(views);
});
});
});
@gcpantazis
gcpantazis / gist:5447085
Last active December 16, 2015 14:09
Exposing jQuery plugins via require, instead of accessing them via the jQuery global object.
// Returning the jQuery plugin at the end of its requirejs module.
return function( $elem, options ) {
return $elem.someJQueryPlugin.apply($elem, Array.prototype.slice.call( arguments, 1 ));
};
// Instead of this:
$foo.someJQueryPlugin({'bar': true});
@gcpantazis
gcpantazis / router.js
Last active December 17, 2015 15:29
Lightweight Backbone-ish Router
// Router Module
// --------------------------------------------
//
// * **Class:** Router
// * **Version:** 0.1
// * **Modified:** 05/01/2013
// * **Author:** George Pantazis
//
// This class is a lightweight extraction of Backbone's router object. For more information, please
// refer to [that project's documentation](http://backbonejs.org/#Router).
@gcpantazis
gcpantazis / gist:6059042
Last active December 20, 2015 02:49
A rough idea for establishing the data models for a module within the module itself, for a future generator with a CMS tie-in.
// schema/killer-thing.json
{
"parents": ["Grid", "Container"], // Grids and Containers can add KillerThing as a submodule.
"model": {
"foo": "String",
"bar": "Integer",
"baz": "Boolean",
"a": ["CoolThing"], // An Array of CoolThing Models.
"b": "RadThing" // A single RadThing Model.
# Installing OpenCV python libs on mac to work with virtualenv
# OpenCV 2.4.3
# Python 2.7.3 installed with brew
# assuming you have virtualenv, pip, and python installed via brew
# assuming $WORKON_HOME is set to something like ~/.virtualenvs
# using homebrew - make sure we're current
brew update
@gcpantazis
gcpantazis / gist:6092838
Last active December 20, 2015 07:19
OpenCV, rotate an image 180 degrees.
#include <opencv2/gpu/gpu.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace cv;
int main(int argc, char* argv[])
{
Mat src_img, dst_img;
@gcpantazis
gcpantazis / getPlaceholder
Last active December 20, 2015 18:49
Use ImageMagick's `identify` command to create a CLI command for evaluating images and getting a same-sized placeholder.
#!/bin/bash
echo "http://placehold.it/$(identify $1 | sed -n 's/.* \([0-9][0-9]*x[0-9][0-9]*\) .*/\1/p')"
@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.
}
@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 / _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>