Skip to content

Instantly share code, notes, and snippets.

@rpominov
rpominov / foo.ejs
Created August 6, 2014 19:56
An example of how to export functions from template to template in ejs
<%
catchExports.foo = function(buf, text) {
%><h1><%= text %></h1><%
}
catchExports.bar = function(buf, text) {
%><p><%= text %></p><%
}
// old API
$('[data-track-click]').each(function(){
var $el = $(this);
var params = ['_trackEvent'].concat(
$el.data('track-click').split(',')
);
$el.click(function(){
_gaq.push(params);
});
@rpominov
rpominov / normalize.v3.0.1.min.css
Created May 26, 2014 19:09
normalize.v3.0.1.min.css
/*! normalize.css v3.0.1 | MIT License | git.io/normalize */
html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}
body{margin:0}
article,aside,details,figcaption,figure,
footer,header,hgroup,main,nav,section,summary{display:block}
audio,canvas,progress,video{display:inline-block;vertical-align:baseline}
audio:not([controls]){display:none;height:0}[hidden],template{display:none}
a{background:0 0}
a:active,a:hover{outline:0}
abbr[title]{border-bottom:1px dotted}
@rpominov
rpominov / ns.js
Last active August 29, 2015 13:56
Simple js modules system
window.ns = (function(){
var modules = {};
function _ns(name, initializer) {
if (initializer) {
return modules[name] = function() {
var module = {
exports: {}
};
initializer(module.exports, module);
modules[name] = function() {
@rpominov
rpominov / bacon-swipes-and-drags.coffee
Last active January 1, 2016 01:39
Bacon.js swipes and mouse-drags
do (exports = window.baconSwipes = {}) ->
getPos = (e) ->
source = (if e.originalEvent.touches
e.originalEvent.touches[0]
else
e.originalEvent)
x: source.clientX
y: source.clientY
event: e
@rpominov
rpominov / bacon-animation-frames.coffee
Created December 21, 2013 20:08
Bacon.js requestAnimationFrame
Bacon.fromBinder (sink) ->
request =
window.requestAnimationFrame or
window.webkitRequestAnimationFrame or
window.mozRequestAnimationFrame or
window.oRequestAnimationFrame or
window.msRequestAnimationFrame or
(f) -> window.setTimeout(f, 1000 / 60)
subscribed = true
handler = ->
@rpominov
rpominov / gist:6489439
Created September 8, 2013 23:15
impossibear.js concept
<div class="js-spoiler">
<button class="js-toggle">скрыть/показать</button>
<p class="js-content">контент контент контент</p>
</div>
catbug """
.js-spoiler
.js-toggle
.js-content
""", ->
@rpominov
rpominov / bookmark.url
Last active December 10, 2015 18:29
Help read bookmarklet
javascript:(function()%7Bvar%20script%3Ddocument.createElement(%27script%27)%3Bscript.src%3D%27https://gist.github.com/raw/4475306/readhelp.js%3F%27%2BMath.floor((%2Bnew%20Date)/(864e5))%3Bdocument.body.appendChild(script)%3B%7D)()
@rpominov
rpominov / dabblet.css
Created December 2, 2012 22:17
resize image without popup (concept)
.wrap {
width: 1000px;
margin: 0 auto;
}
p, img {
width: 500px;
margin: .5em auto;
display: block;
}
img {
@rpominov
rpominov / ajax-validation.coffee
Created November 16, 2012 21:29
Thoughts on javascript modules.
module 'AjaxValidation', (M) ->
M.tree """
form
"""
M.events """
ajax:error root showErrors
ajax:beforeSend root hideErrors
"""
M.methods
showErrors: (__1, __2, errors) ->