Skip to content

Instantly share code, notes, and snippets.

View mtt87's full-sized avatar
🍔

Mattia mtt87

🍔
View GitHub Profile
@mtt87
mtt87 / Component_1.js
Created March 5, 2019 01:16
Fetch dynamically a component and render it at runtime on React Native
// This DOES NOT work (require is undefined)
import React from 'react';
import { View, Text } from 'react-native';
const Component = () => (
<View>
<Text>Hello world</Text>
</View>
);
import React from 'react';
import BigCalendar from 'react-big-calendar';
import SingleEvent from './SingleEvent';
// THIS WORKS
const Calendar = ({ refreshData }) =>
...
<BigCalendar
components={{
eventWrapper: SingleEvent,
@mtt87
mtt87 / PromiseRecursion.js
Created December 19, 2016 12:03
Promise recursion
function fetchPages(resultsArray, page, end) {
return new Promise((resolve, reject) => {
fetch(`https://my-api.com/?page=${page}`)
.then((res) => {
// res.json
// {
// data: [1,2,3],
// nextPage: 1,
// previousPage: 0,
// }

Keybase proof

I hereby claim:

  • I am mtt87 on github.
  • I am mtt (https://keybase.io/mtt) on keybase.
  • I have a public key whose fingerprint is 335E 77F6 B689 C7B2 51EB 6621 161B 5802 17C8 8908

To claim this, I am signing this object:

gulp.task('publish', function() {
return gulp.src('dist/**/*.*')
.pipe(revAll.revision())
.pipe($.awspublish.gzip())
.pipe(publisher.publish(headers))
.pipe(publisher.cache())
.pipe($.awspublish.reporter())
.pipe($.cloudfront(awsConfig));
});
// Override Bulma Variables
$family-sans-serif: “Roboto”, “Helvetica”, “Arial”, sans-serif;
$techhub: #f9b233;
...
@import “../../node_modules/bulma/sass/utilities/utilities”;
@import “../../node_modules/bulma/sass/base/base”;
@import “../../node_modules/bulma/sass/elements/box”;
@import “../../node_modules/bulma/sass/elements/button”;
@import “../../node_modules/bulma/sass/elements/title”;
@import “../../node_modules/bulma/sass/elements/other”;
gulp.task('serve', ['styles', 'scripts', 'riot', 'fonts'], () => {
browserSync({
routes: {
'/node_modules/': 'node_modules'
}
}
});
gulp.task('riot', ()=> {
gulp.src('app/tags/*.tag')
.pipe($.riot())
.pipe(gulp.dest('.tmp/scripts'));
});
<spinner>
<div class=”has-text-centered”>
<span class=”fa fa-cog fa-spin spinner”></span>
</div>
<script>
this.on(‘data-loaded’, function(){
this.unmount();
});
</script>
</spinner>
var client = contentful.createClient({space: ‘a2b2c3d4e5’, accessToken: ‘not_a_secret’});
// retrieve the data with content_type = job
client.getEntries({'content_type': 'job'})
.then(function (entries) {
// do stuff
});