Skip to content

Instantly share code, notes, and snippets.

View mauriciord's full-sized avatar

Maurício R Duarte mauriciord

View GitHub Profile
@mauriciord
mauriciord / gist:dbf2f45bce44af8aa218
Last active August 29, 2015 14:12
Código retirado do livro que está com erro
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let row = indexPath.row
let meal = meals[row]
var cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: nil)
cell?.textLabel?.text = meal.name
return cell!
@mauriciord
mauriciord / app.js
Last active January 26, 2017 12:56
Facebook request
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
//requestify
var requestify = require('requestify');
@mauriciord
mauriciord / gulpfile.js
Last active May 19, 2017 17:51
SASS Watch
/*
Gulpfile de exemplo para algumas ações clássicas de otimização.
*/
const gulp = require('gulp');
const RevAll = require('gulp-rev-all');
const gulpsync = require('gulp-sync')(gulp);
const $ = require('gulp-load-plugins')({ rename: {
'gulp-rev-delete-original': 'revdel',
'gulp-if': 'if',
#add 'node_modules' to .gitignore file
git rm -r --cached node_modules
git commit -m 'Remove the now ignored directory node_modules'
git push origin master
@mauriciord
mauriciord / gh-pages-deploy.md
Last active May 29, 2017 19:45 — forked from cobyism/gh-pages-deploy.md
Deploy to `gh-pages` from a `dist` folder on the master branch. Useful for use with [yeoman](http://yeoman.io).

Deploying a subfolder to GitHub Pages

Sometimes you want to have a subdirectory on the master branch be the root directory of a repository’s gh-pages branch. This is useful for things like sites developed with Yeoman, or if you have a Jekyll site contained in the master branch alongside the rest of your code.

For the sake of this example, let’s pretend the subfolder containing your site is named dist.

Step 1

Remove the public directory from the project’s .gitignore file (it’s ignored by default by Yeoman).

@mauriciord
mauriciord / .eslintrc
Created February 28, 2018 14:12 — forked from radiovisual/.eslintrc
React Native AirBnB ESLint Config
{
"parser": "babel-eslint",
"plugins": [
"react",
"react-native"
],
"parserOptions": {
"ecmaFeatures": {
"jsx": true,
"modules": true
@mauriciord
mauriciord / fix.js
Created July 16, 2018 13:05
window.postMessage on React Native Webview - bug fix
const patchPostMessageFunction = function () {
const originalPostMessage = window.postMessage;
const patchedPostMessage = function (message, targetOrigin, transfer) {
originalPostMessage(message, targetOrigin, transfer);
};
patchedPostMessage.toString = function () {
return String(Object.hasOwnProperty).replace('hasOwnProperty', 'postMessage');
};
@mauriciord
mauriciord / MaskedInput.jsx
Created September 25, 2018 21:05
Masked Input React Native
import React from 'react';
import phone from 'shared/masks/phone';
import cep from 'shared/masks/cep';
const masks = {
phone,
cep,
};
const getMask = (mask) => {
@mauriciord
mauriciord / Swipleable.jsx
Created October 15, 2018 13:05
Swipeable
import React from 'react';
import {
View,
Text,
Button,
StyleSheet,
TouchableOpacity,
Image,
Platform,
Animated,
export default ((functionToCall, url, options, timeout, attempt, maxRetries) => functionToCall(functionToCall, url, options, timeout, attempt, maxRetries))(
(functionToCall, url, options, timeout = 7000, attempt = 1, maxRetries = 3) => {
return Promise.race([
fetch(url, options),
new Promise((_, reject) =>
setTimeout(() => {
if (maxRetries > attempt) {
attempt++;
return functionToCall(functionToCall, url, options, (timeout * attempt), attempt, maxRetries)
}