Skip to content

Instantly share code, notes, and snippets.

View icodeforlove's full-sized avatar
:octocat:
Indefinitely In Bangkok

Chad icodeforlove

:octocat:
Indefinitely In Bangkok
View GitHub Profile
/* Component CSS for TestName */
.app-component.app-test-name {
width: 100px;
height: 100px;
}
.app-component.app-test-name.app-test-name_state-test {
width: 223px;
}
.app-component.app-test-name .app-test-name_header {
width: 100px;
@component TestName {
width: 100px;
height: 100px;
.state-test & {
width: 223px;
}
.header {
width: 100px;
@icodeforlove
icodeforlove / RCSPreprocess.js
Last active August 29, 2015 14:04
playing around with the idea of vars and inline js
// this would add variable support and inline JS support
var RCSPreprocess = (function () {
var varRegExp = /\$([a-z0-9-_]+)/ig,
singleVarRegExp = /\$([a-z0-9-_]+)/i,
codeRegExp = /\$\{([\s\S]+)\}\$/igm,
varDefineRegExp = /\$([a-z0-9-_]+): ([^;]+);/ig,
rcsVars = {};
function process (example) {
example = example.replace(varDefineRegExp, function (string, name, value) {
@icodeforlove
icodeforlove / overlay.jsx
Created July 25, 2014 10:14
react directive-like overlay
var WrappedOverlayExample = React.createClass({
handleClose: function () {
this.refs.overlay.fadeOut(function () {
this.props.onClose();
}.bind(this));
},
render: function () {
return (
<Overlay ref="overlay">
@icodeforlove
icodeforlove / react-with-addons-and-routes.js
Created July 20, 2014 13:47
react-with-addons-and-routes.js
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
@icodeforlove
icodeforlove / hapi-routes.js
Created July 17, 2014 23:01
hapi-routes.js
// routes/products.js
module.exports = [
{
method: 'GET',
path: '/products',
config: {
validate: {
query: {
name: Joi.string().required(),
@icodeforlove
icodeforlove / rcs.settings.js
Created July 14, 2014 19:40
rcs settings example
function RCSPropertiesInit (Properties) {
Properties.setBaseUrl('/');
// defaulting number values to px values
Properties.registerProperty(/.*/, function (name, value) {
var stringValue = String(value),
numberPropertyKeys = /^(?:column-count|fill-opacity|flex|flex-grow|flex-shrink|font-weight|line-clamp|opacity|order|orphans|widows|z-index|zoom)$/,
numberValues = /^([a-z0-9.]+) ?(?:([a-z0-9.]+) ?)?(?:([a-z0-9.]+) ?)?(?:([a-z0-9.]+) ?)?$/;
if (name.match(numberPropertyKeys) || !numberValues.test(stringValue)) {
@icodeforlove
icodeforlove / react-js-harmony-fiddle-integration.js
Created July 14, 2014 18:59
react-js-harmony-fiddle-integration.js
(function() {
var tag = document.querySelector(
'script[type="application/javascript;version=1.7"]'
);
if (!tag || tag.textContent.indexOf('window.onload=function(){') !== -1) {
alert('Bad JSFiddle configuration, please fork the original React JSFiddle');
}
tag.setAttribute('type', 'text/jsx;harmony=true');
tag.textContent = tag.textContent.replace(/^\/\/<!\[CDATA\[/, '');
})();
@icodeforlove
icodeforlove / GameControls.h
Created July 9, 2014 14:40
SpriteKit component
//
// GameControls.h
// Hiss
//
// Created by Chad Scira on 6/21/14.
// Copyright (c) 2014 Chad Scira. All rights reserved.
//
#import <SpriteKit/SpriteKit.h>
<!-- react code -->
<script type="text/jsx">
/**
* @jsx React.DOM
*/
var Example = React.createClass({
style: `
view {
width: 100px;
height: 100px;