Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Andrey Popp andreypopp

🏠
Working from home
Block or report user

Report or block andreypopp

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
View gist:8865144
function condition(props) {
return props.if ? Array.prototype.slice.call(arguments, 1) : [];
}
var Component = React.createClass({
render: function() {
return (
<div>
<condition if={this.state.show}>
True!
View Component.css
@import "./theme" as theme
.Component {
.Child {
width: var(theme.width);
}
}
View with-macros.sjs
var theme = require('my-theme');
module.exports = style {
background-color: {theme.bgColor};
}
View qw.sweet.js
macro makeString {
case { _ $tok } => {
return [makeValue(#{$tok}[0].token.value, #{here})]
}
}
macro qw {
rule { ($delimited ...) } => { [$(makeString $delimited) (,) ...] }
}
qw(space separated words) // ["space", "separated", "words"]
@andreypopp
andreypopp / di.sjs
Created Feb 3, 2014
Dependency injection DSL for JavaScript
View di.sjs
macro emitQuery {
case { _ $id:ident } => {
letstx $name = [makeValue(#{$id}[0].token.value, #{$id})];
letstx $registry = [makeIdent('registry', #{$id})];
return #{ var $id = $registry.query($name) }
}
}
macro inject {
case { _ $id:ident (,) ... { $body ...} } => {
View asyncawait.sjs
macro __rejectAwait {
case { _ $body ... } => {
letstx $await = [makeIdent('await', #{$body ...}[0])];
return #{
macro $await {
case { $name:ident $e:expr } => {
throwSyntaxError('await', 'cannot use await keyword outside of async function', #{$name});
}
}
$body ...
View jsx-macro
macro jsx {
case { _ $body } => {
var transform = require('react-tools').transform;
var body = #{ $body }[0].token.value.raw;
var transformed = transform('/** @jsx React.DOM */' + body).slice(21);
var tokens = parser.read(transformed);
tokens.pop(); // EOF
return tokens;
}
}
View mylib.rs
#[crate_type = "lib"];
#[allow(ctypes)];
use std::c_str;
use std::libc;
use std::ptr;
use std::vec;
struct PyObject;
@andreypopp
andreypopp / example.html
Created Nov 20, 2013
unnamed: React component
View example.html
<!doctype>
<html>
<head>
<title>Component Example</title>
<link rel="stylesheet" href="bundle.css">
<style>
body {
padding: 10px;
}
</style>
@andreypopp
andreypopp / example.html
Created Nov 19, 2013
unnamed: React component
View example.html
<!doctype>
<html>
<head>
<title>Component Example</title>
<link rel="stylesheet" href="bundle.css">
<style>
body {
padding: 10px;
}
</style>
You can’t perform that action at this time.