Skip to content

Instantly share code, notes, and snippets.

View maxidr's full-sized avatar

Maxi Dello Russo maxidr

  • mxHero
  • Buenos Aires, Argentina
  • X @maxidr
View GitHub Profile
function PublicRoute({ children, ...rest }) {
const { auth } = rest;
return (
<Route
{...rest}
render={() => {
if (!auth) return <Redirect to="/login" />;
return <Dashboard>{children}</Dashboard>;
}}
@maxidr
maxidr / gist:cd4c12857d3b4190c6cab21877fc144a
Created June 5, 2019 21:02
ruby-build.20190605174356.12792.log
/tmp/ruby-build.20190605174356.12792 ~/Projects/mxhero/new-dashboard
/tmp/ruby-build.20190605174356.12792/ruby-2.3.0 /tmp/ruby-build.20190605174356.12792 ~/Projects/mxhero/new-dashboard
checking for ruby... false
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
@maxidr
maxidr / snippet.js
Created October 3, 2017 17:11
Next Trip Widget
(function(w,d,s,a){
var t,f;w['NextTripBookingRef']=a;w[a]=w[a]||function(){(w[a].q=w[a].q||[]).push(arguments)};
w[a].s=w.location.origin;t=d.createElement('script');f=d.getElementsByTagName('script')[0];
t.async=1;t.src=s;f.parentNode.insertBefore(t,f);d.querySelectorAll('[data-nexttrip]').forEach(
function(b){b.addEventListener('click', function(e){w[a]('dataset', e.target.dataset);
e.preventDefault()})})
})(window, document,'http://localhost:3000/booking.js','nextTrip');
nextTrip.customerId = 'ALLUSA'
nextTrip.dealId = 'SHUTTLES'
@maxidr
maxidr / uniqueReq.js
Last active August 3, 2017 19:20
Make xhr request that will be aborted if you call it again. Using mithril request
const merge = require('ramda/src/merge')
const m = require('mithril')
/*
@param {string} key - The unique key of the request
@param {Object} params - The same params used in m.request of mithril
@returns Promise
@link https://mithril.js.org/request.html
@maxidr
maxidr / prop.js
Created August 26, 2016 13:46
Add change listener on mitrhil prop
const m = require('mithril')
function emitChangeToSubscribers(subscribers, newState, oldState){
subscribers.forEach(function(subscriber){
subscriber.call(null, newState, oldState)
})
}
module.exports = function(initState){
const store = m.prop(initState)
void function(m) {
function closure(fn) {
var component = {
controller : function(options) {
component.view = fn(options);
}
};
return component;
@maxidr
maxidr / routes.js
Last active August 29, 2015 14:26
#mithril Route separation logic example From https://gitter.im/lhorie/mithril.js?at=551bd24305184cd235fb971a
// The limited unauthenticated routemap
var authRoutes = {
'/signup' : modules.signup,
'/login' : modules.login
};
// The whole shebang
var appRoutes = Object.assign( {
'/:semantic/:app/:routes' : various.modules
}, authRoutes );
@maxidr
maxidr / randomHash.js
Last active August 29, 2015 14:24
Random hash in hexa: In nodejs (randomHash.js) In browser (randomHashBrowser.js)
var crypto = require('crypto');
crypto.randomBytes(16).toString('hex');
// 'e834ba2133229fb78a693f5ca3ae05de'
@maxidr
maxidr / 0_reuse_code.js
Last active August 29, 2015 14:24
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console