Skip to content

Instantly share code, notes, and snippets.

Dmitriy Tkalich creativ

Block or report user

Report or block creativ

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
@creativ
creativ / analytics.js
Created Oct 2, 2014
Google analytics event tracker
View analytics.js
// Google analytics implementation
window.Analytics = (function(ga) {
function Analytics() { }
Analytics.prototype.trackEvent = function(category, action, label, value) {
ga.apply(this, ['send', 'event'].concat(Array.prototype.slice.call(arguments)));
};
Analytics.prototype.trackPage = function(options) {
ga.apply(this, ['send', 'pageview'].concat(Array.prototype.slice.call(arguments)));
View sign-middleware.coffee
class App.SignMiddleware
constructor: (@gameData, callback) ->
@name = 'requestSign'
@sessionKey = null
Psycho.ajax
url: "#{@gameData.endpointUrl}user/getSessionKey"
type: 'POST'
data: @_signRequestParams { userId: @gameData.userId }
View button.coffee
class App.Button extends createjs.Container
constructor: (buttonOptions={}) ->
defaultButtonOptions =
text: null
outlineText: null
@buttonOptions = Psycho.merge defaultButtonOptions, buttonOptions
@initialize()
@drawButton()
@creativ
creativ / bot.py
Created Aug 17, 2014
Cleverbot usage example
View bot.py
import md5
import urllib
import urllib2
import uuid
import xml.dom.minidom
"""
chatterbotapi
Copyright (C) 2011 pierredavidbelanger@gmail.com
@creativ
creativ / Makefile
Created Aug 6, 2014
Simple Makefile for CoffeeScript projects
View Makefile
COFFEEC = ./node_modules/.bin/coffee
DIST = dist
CONF = src/conf
all: build_dev build_prod
build_dev:
@$(COFFEEC) --join $(DIST)/lib-dev.js --compile src/lib.coffee $(CONF)/conf-dev.coffee
@echo 'Lib(Dev) successfully builded'
View cors-nginx.conf
#
# Slightly tighter CORS config for nginx
#
# A modification of https://gist.github.com/1064640/ to include a white-list of URLs
#
# Despite the W3C guidance suggesting that a list of origins can be passed as part of
# Access-Control-Allow-Origin headers, several browsers (well, at least Firefox)
# don't seem to play nicely with this.
#
# To avoid the use of 'Access-Control-Allow-Origin: *', use a simple-ish whitelisting
@creativ
creativ / factory_v3
Last active Jan 3, 2016
Simple factories
View factory_v3
def shape_factory(type, *args, **kwargs):
if type == "Circle": return Circle(*args, **kwargs)
elif type == "Square": return Square(*args, **kwargs)
else: None
class Shape(object):
def draw(self):
raise NotImplementedError()
def erase(self):
You can’t perform that action at this time.