Skip to content

Instantly share code, notes, and snippets.

George Zografos gzog

Block or report user

Report or block gzog

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@gzog
gzog / tracking-snippet.js
Created Sep 1, 2017
GA - Product Detail Hits
View tracking-snippet.js
ga('require', 'ec');
ga('ec:addProduct', {
'id': '{{g:id}}', // Matches shopping feed g:id
'name': '{{title}}', // Matches shopping feed title
'category': '{{g:product_type}}', // Matches shopping feed g:product_type
'brand': '{{brand}}', // Matches shopping feed g:brand
});
ga('ec:setAction', 'detail');
@gzog
gzog / luhn.js
Created May 20, 2016 — forked from ShirtlessKirk/luhn.js
Luhn validation algorithm
View luhn.js
/**
* Luhn algorithm in JavaScript: validate credit card number supplied as string of numbers
* @author ShirtlessKirk. Copyright (c) 2012.
* @license WTFPL (http://www.wtfpl.net/txt/copying)
*/
var luhnChk = (function (arr) {
return function (ccNum) {
var
len = ccNum.length,
bit = 1,
@gzog
gzog / chatServer.js
Created May 20, 2016 — forked from creationix/chatServer.js
A simple TCP based chat server written in node.js
View chatServer.js
// Load the TCP Library
net = require('net');
// Keep track of the chat clients
var clients = [];
// Start a TCP Server
net.createServer(function (socket) {
// Identify this client
@gzog
gzog / object-watch.js
Created May 20, 2016 — forked from eligrey/object-watch.js
object.watch polyfill in ES5
View object-watch.js
/*
* object.watch polyfill
*
* 2012-04-03
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/
@gzog
gzog / api.js
Created May 20, 2016 — forked from fwielstra/api.js
An example NodeJS / Mongoose / Express application based on their respective tutorials
View api.js
/* The API controller
Exports 3 methods:
* post - Creates a new thread
* list - Returns a list of threads
* show - Displays a thread and its posts
*/
var Thread = require('../models/thread.js');
var Post = require('../models/post.js');
@gzog
gzog / uri.js
Created May 20, 2016 — forked from jlong/uri.js
URI Parsing with Javascript
View uri.js
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@gzog
gzog / slugify.js
Created May 20, 2016 — forked from mathewbyrne/slugify.js
Javascript Slugify
View slugify.js
function slugify(text)
{
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}
@gzog
gzog / static_server.js
Created May 20, 2016 — forked from ryanflorence/static_server.js
Node.JS static file web server. Put it in your path to fire up servers in any directory, takes an optional port argument.
View static_server.js
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(process.cwd(), uri);
@gzog
gzog / ajax-form.js
Created May 20, 2016 — forked from havvg/ajax-form.js
jQuery AJAX form submit with Twitter Bootstrap modal
View ajax-form.js
jQuery(function($) {
$('form[data-async]').live('submit', function(event) {
var $form = $(this);
var $target = $($form.attr('data-target'));
$.ajax({
type: $form.attr('method'),
url: $form.attr('action'),
data: $form.serialize(),
@gzog
gzog / gist:67d23aaebb65cdcee7edc3b778bea483
Created May 20, 2016 — forked from jcsrb/gist:1081548
get avatar from google profiles, facebook, gravatar, twitter, tumblr
View gist:67d23aaebb65cdcee7edc3b778bea483
function get_avatar_from_service(service, userid, size) {
// this return the url that redirects to the according user image/avatar/profile picture
// implemented services: google profiles, facebook, gravatar, twitter, tumblr, default fallback
// for google use get_avatar_from_service('google', profile-name or user-id , size-in-px )
// for facebook use get_avatar_from_service('facebook', vanity url or user-id , size-in-px or size-as-word )
// for gravatar use get_avatar_from_service('gravatar', md5 hash email@adress, size-in-px )
// for twitter use get_avatar_from_service('twitter', username, size-in-px or size-as-word )
// for tumblr use get_avatar_from_service('tumblr', blog-url, size-in-px )
// everything else will go to the fallback
// google and gravatar scale the avatar to any site, others will guided to the next best version
You can’t perform that action at this time.