Skip to content

Instantly share code, notes, and snippets.

View martinandert's full-sized avatar

Martin Andert martinandert

View GitHub Profile
var Authenticated = React.createClass({
statics: {
willTransitionTo (transition) {
if (!authenticated()) {
transition.redirect('login');
}
}
}
});
@tarjei
tarjei / Modal.jsx
Created June 17, 2014 11:02
Foundation.reveal as a React.js component
/**
* @jsx React.DOM
*/
var React = require('react/addons');
/* the link component is used to navigate away from th current url. Some of it is app spesific and
therefore not included here. */
var Link = require('../components/Link.jsx');
var cx = React.addons.classSet;
@dliggat
dliggat / mixpanel_export.rb
Last active January 14, 2017 14:41
Export data from Mixpanel
#!/usr/bin/env ruby
require 'active_support/time'
require 'digest'
API_KEY = 'YOUR KEY'
API_SECRET = 'YOUR SECRET'
args = {
'from_date' => Date.new(2014,9,1).iso8601,
@Tvaroh
Tvaroh / TransitSvc.js
Last active June 2, 2017 19:40
transit-js bridge to immutable 3.0
define(['transit', 'immutable'], function (Transit, Imm) {
'use strict';
var reader = Transit.reader('json', {
arrayBuilder: {
init: function () { return Imm.List.of().asMutable(); },
add: function (ret, val) { return ret.push(val); },
finalize: function (ret) { return ret.asImmutable(); },
fromArray: function (arr) { return Imm.List(arr); }
},
@mislav
mislav / html.rb
Created May 12, 2010 08:31
Pretty up HTML with Nokogiri and XSLT
require 'nokogiri'
ugly = Nokogiri::HTML ARGF
tidy = Nokogiri::XSLT File.open('tidy.xsl')
nice = tidy.transform(ugly).to_html
puts nice
import React from 'react';
import md5 from 'MD5';
class Avatar extends React.Component {
static propTypes = {
email: React.PropTypes.string,
size: React.PropTypes.number
}
static defaultProps = {
@mattheworiordan
mattheworiordan / cli.rb
Created January 9, 2015 12:21
Thor with subcommands that work correctly with help
#!/usr/bin/env ruby
require 'thor'
class SubCommandBase < Thor
def self.banner(command, namespace = nil, subcommand = false)
"#{basename} #{subcommand_prefix} #{command.usage}"
end
def self.subcommand_prefix
@dylanjha
dylanjha / 0. sprockets_depend_on_config.rb
Last active May 11, 2020 15:11
Adds Sprockets Directive `depend_on_config`. I'm using this to load .yml locale translations on the server into the client in json
=begin
Useage:
#assets/locales/en.js.erb
```js
//= depend_on_config 'locales/es.yml'
```
=end
@sebmarkbage
sebmarkbage / ReactCanvasDrawing.js
Created July 25, 2014 19:14
Canvas Drawing Example
/** @jsx React.DOM */
var Graphic = React.createClass({
componentDidMount: function() {
var context = this.getDOMNode().getContext('2d');
this.paint(context);
},
componentDidUpdate: function() {
'use strict';
var React = require('react-native');
var {
Bundler,
StyleSheet,
Text,
TouchableHighlight,
View,
ScrollView,