Skip to content

Instantly share code, notes, and snippets.

var namespace = 'mediacat'
function cx(classNames, options) {
var classes;
var states;
var bemClasses = [];
var baseClassName;
var stateClassName;
if (typeof classNames == 'object') {
@nathggns
nathggns / await.es6.js
Last active August 29, 2015 14:22
Await implemented in ES6.
function await(generatorFunction) {
let gen = generatorFunction();
/**
* @param {any?} err The error to throw in the generator, where yield was last called.
* @param {any?} result The result to pass to the genarator for the last call to yield
*/
function next(err, result) {
// If the last promise that was yielded was rejected,
// trigger an error inside the generator where yield was last called
import React from 'react';
import { createContainer, graphql } from '../../../Relux';
class EventDetail extends React.Component {
render() {
const { event } = this.props;
if (event) {
@quis
quis / imageProxy.php
Created March 16, 2012 10:47
Wordpress responsive image proxy
<?php
class ImageProxy {
function __construct($request) {
$this->sourceFolder = "/wp-content/uploads/";
$this->path = dirname($request);
$this->partialFileName = str_replace($this->path."/", "", $request);
@dearaujoj
dearaujoj / gist:2663082
Created May 11, 2012 23:29 — forked from anonymous/gist:2388015
iOS fix for iframe cropping
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
if (/iPhone|iPod|iPad/.test(navigator.userAgent))
$('iframe').wrap(function(){
var $this = $(this);
return $('<div />').css({
width: $this.attr('width'),
height: $this.attr('height'),
overflow: 'auto',
h('div.container', [
h('label.nameLabel', 'Name:'),
h('input.myinput', {attributes: {type: 'text'}}),
h('hr'),
h('h1.greeting', `Hello ${name}`)
])
// or
div('.container', [
@zkenda
zkenda / JsLitmus.js
Last active December 12, 2015 02:58
My approach to less.modifyVars. To avoid reparsing I just modify "expression tree" and then render again. Only intresting file is less-1.3.1.modifyVars.js and perhaps modified less-1.3.1.js (which is actually 1.3.3). Index.html, test.less and jsLitmus.js are for demonstration.
// JSLitmus.js
//
// Copyright (c) 2010, Robert Kieffer, http://broofa.com
// Available under MIT license (http://en.wikipedia.org/wiki/MIT_License)
(function() {
// Private methods and state
// Get platform info but don't go crazy trying to recognize everything
// that's out there. This is just for the major platforms and OSes.
@gabrielhpugliese
gabrielhpugliese / coderstv-router.js
Created November 8, 2013 14:21
Iron-router for http://coderstv.com with tracking - something may be missing because it's coderstv internals
Router.map(function () {
this.route('index', {
controller: 'BasicController',
layoutTemplate: 'indexLayout',
path: '/',
waitOn: function () {
return Meteor.subscribe('Channels');
}
});
<!-- Context should be the object you are tagging -->
<template name="tagInput">
<select class='tag-input' name='tags[]' multiple="multiple">
{{#each tags}}
<option value="{{this}}" selected="true">{{this}}</option>
{{/each}}
</select>
</template>
@developit
developit / _delegated-component.md
Last active October 20, 2016 21:39
DelegatedComponent

Experiment: Backbone-style events in Preact

What if we wanted to use backbone-style event delegation within the component paradigm afforded by react/preact/etc? Would that be useful?

Example

Basic usage: