Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Breno Polanski brenopolanski

🏠
Working from home
Block or report user

Report or block brenopolanski

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@brenopolanski
brenopolanski / sample.md
Created Feb 15, 2019
Getting previous month first day and future month last day using moment.js
View sample.md
const prevMonthFirstDay = moment().subtract(1, 'months').date(1);

const nextMonthLastDay = moment().add(2, 'months').date(0);

or

const prevMonthFirstDay = moment().subtract(1, 'months').startOf('month');
@brenopolanski
brenopolanski / wget-jdk-oracle-install-example.txt
Created Feb 14, 2019 — forked from sr75/wget-jdk-oracle-install-example.txt
wget command to install Oracle JAVA JDK from stupid oracle website for centos and ubuntu
View wget-jdk-oracle-install-example.txt
http://d.stavrovski.net/blog/post/how-to-install-and-setup-oracle-java-jdk-in-centos-6
# rpm
wget --no-cookies \
--no-check-certificate \
--header "Cookie: oraclelicense=accept-securebackup-cookie" \
"http://download.oracle.com/otn-pub/java/jdk/7u55-b13/jdk-7u55-linux-x64.rpm" \
-O jdk-7-linux-x64.rpm
# ubuntu
@brenopolanski
brenopolanski / nextcloud-cors-with-php-headers.md
Last active Feb 7, 2019
Nextcloud Cors with PHP Headers
View nextcloud-cors-with-php-headers.md

Update nextcloud/remote.php:

try {
        require_once __DIR__ . '/lib/base.php';

        // All resources served via the DAV endpoint should have the strictest possible
        // policy. Exempted from this is the SabreDAV browser plugin which overwrites
        // this policy with a softer one if debug mode is enabled.
        header("Content-Security-Policy: default-src 'none';");
@brenopolanski
brenopolanski / Iframe.js
Created Jan 15, 2019 — forked from msmfsd/Iframe.js
React iframe component
View Iframe.js
/*
INIT: ensure Babel/Eslint/Flow is configured for ES Class Fields & Static Properties
JSX USAGE: <Iframe src='http://web.site' onLoad={myOnloadFunction}/>
*/
import React, { Component, PropTypes } from 'react'
import ReactDOM from 'react-dom'
class Iframe extends Component {
static propTypes: Object = {
@brenopolanski
brenopolanski / Sortable.jsx
Created Jan 10, 2019 — forked from superKalo/ Sortable.jsx
How to use jQuery UI with React JS? You can use this approach to integrate almost any jQuery plugin! Full details and explanation here: http://stackoverflow.com/a/40350880/1333836
View Sortable.jsx
class Sortable extends React.Component {
componentDidMount() {
// Every React component has a function that exposes the
// underlying DOM node that it is wrapping. We can use that
// DOM node, pass it to jQuery and initialize the plugin.
// You'll find that many jQuery plugins follow this same pattern
// and you'll be able to pass the component DOM node to jQuery
// and call the plugin function.
@brenopolanski
brenopolanski / rootReducer.js
Created Jan 7, 2019 — forked from frankchang0125/rootReducer.js
Reset all reducers back to their initial states when user logout
View rootReducer.js
import {combineReducers} from 'redux';
import { LOGOUT } from '../common/constants';
import { UnauthorizedErrorReducer } from '../common/commonReducers';
import FirstReducer from './FirstReducer';
import SecondReducer from './SecondReducer';
import ThirdReducer from './ThirdReducer';
/* In order to reset all reducers back to their initial states when user logout,
* rewrite rootReducer to assign 'undefined' to state when logout
*
@brenopolanski
brenopolanski / recurssive.tree.js
Created Jan 2, 2019 — forked from alonronin/recurssive.tree.js
Create recursive tree from json using lodash transform without recursion. Can have unlimited nesting.
View recurssive.tree.js
var _ = require('lodash');
var arr = [
{"name":"my2child1","title":"My 2 Child 1","parent":"my2"},
{"name":"my2child2","title":"My 2 Child 2","parent":"my2"},
{"name":"parent","title":"A single parent"},
{"name":"child-parent","title":"A child parent","parent":"child1"},
{"name":"my","title":"My"},
{"name":"my2","title":"My2"},
{"name":"child1","title":"Child 1","parent":"my"},
@brenopolanski
brenopolanski / expired.js
Created Dec 19, 2018 — forked from srph/expired.js
axios + react-router: handling invalid tokens through axios interceptors
View expired.js
import axios from 'axios';
import cookie from 'cookie-machine';
import {hashHistory} from 'react-router';
axios.interceptors.response.use(null, function(err) {
if ( err.status === 401 ) {
cookie.remove('my-token-key');
hashHistory.push('/login');
}
@brenopolanski
brenopolanski / oauth.js
Created Dec 19, 2018 — forked from srph/oauth.js
axios: interceptor which includes your oauth token in every request as an Authorization header
View oauth.js
import axios from 'axios';
// You can use any cookie library or whatever
// library to access your client storage.
import cookie from 'cookie-machine';
axios.interceptors.request.use(function(config) {
const token = cookie.get(__TOKEN_KEY__);
if ( token != null ) {
config.headers.Authorization = `Bearer ${token}`;
View react-file-upload.js
import React from 'react'
import axios, { post } from 'axios';
class SimpleReactFileUpload extends React.Component {
constructor(props) {
super(props);
this.state ={
file:null
}
You can’t perform that action at this time.