Skip to content

Instantly share code, notes, and snippets.

View andreypopp's full-sized avatar
🏠
Working from home

Andrey Popp andreypopp

🏠
Working from home
View GitHub Profile
@andreypopp
andreypopp / example.html
Created November 19, 2013 15:43
unnamed: React component
<!doctype>
<html>
<head>
<title>Component Example</title>
<link rel="stylesheet" href="bundle.css">
<style>
body {
padding: 10px;
}
</style>
@andreypopp
andreypopp / example.html
Created November 19, 2013 16:10
unnamed: React component
<!doctype>
<html>
<head>
<title>Component Example</title>
<link rel="stylesheet" href="bundle.css">
<style>
body {
padding: 10px;
}
</style>
@andreypopp
andreypopp / example.html
Created November 19, 2013 16:35
unnamed: React component
<!doctype>
<html>
<head>
<title>Component Example</title>
<link rel="stylesheet" href="bundle.css">
<style>
body {
padding: 10px;
}
</style>
@andreypopp
andreypopp / example.html
Created November 20, 2013 22:38
unnamed: React component
<!doctype>
<html>
<head>
<title>Component Example</title>
<link rel="stylesheet" href="bundle.css">
<style>
body {
padding: 10px;
}
</style>
#[crate_type = "lib"];
#[allow(ctypes)];
use std::c_str;
use std::libc;
use std::ptr;
use std::vec;
struct PyObject;
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;
}
}
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 ...
@andreypopp
andreypopp / di.sjs
Created February 3, 2014 08:23
Dependency injection DSL for JavaScript
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 ...} } => {
macro makeString {
case { _ $tok } => {
return [makeValue(#{$tok}[0].token.value, #{here})]
}
}
macro qw {
rule { ($delimited ...) } => { [$(makeString $delimited) (,) ...] }
}
qw(space separated words) // ["space", "separated", "words"]
var theme = require('my-theme');
module.exports = style {
background-color: {theme.bgColor};
}