Skip to content

Instantly share code, notes, and snippets.

View brenopolanski's full-sized avatar
🦙
Llama Llama

Breno Polanski brenopolanski

🦙
Llama Llama
View GitHub Profile
@brenopolanski
brenopolanski / oauth.js
Created December 19, 2018 01:33 — forked from srph/oauth.js
axios: interceptor which includes your oauth token in every request as an Authorization header
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}`;
@brenopolanski
brenopolanski / react-file-upload.js
Created December 12, 2018 13:14 — forked from AshikNesin/react-file-upload.js
Simple React File Upload
import React from 'react'
import axios, { post } from 'axios';
class SimpleReactFileUpload extends React.Component {
constructor(props) {
super(props);
this.state ={
file:null
}
@brenopolanski
brenopolanski / solving-cors-pentaho-cde.md
Last active February 23, 2021 17:40
Solving CORS problem on embedding Pentaho CDE dashboard in web application

Solving CORS problem on embedding Pentaho CDE dashboard in web application

Cross-Origin Resource Sharing (CORS) is a W3C spec that allows cross-domain communication from the browser. By building on top of the XMLHttpRequest object, CORS allows developers to work with the same idioms as same-domain requests.

Enable Cross Origin Resource Sharing (CORS) in the Community Dashboard Framework (CDF), Community Dashboard Editor (CDE), and Community Data Access (CDA). While you need CDE to embed the dashboard, you will access it from a different server other than the Pentaho Server, so CORS must be enabled in CDF, CDE and CDA. Open the following CDF, CDE, and CDA settings.xml files in a text editor:

  • For CDF: server/pentaho-server/pentaho-solutions/system/pentaho-cdf/settings.xml.
  • For CDE: server/pentaho-server/pentaho-solutions/system/pentaho-cdf-dd/settings.xml.
  • For CDA: server/pentaho-server/pentaho-solutions/system/cda/settings.xml.
@brenopolanski
brenopolanski / example.md
Last active August 5, 2022 05:32
Convert HTML to a PDF in React.JS

The idea is to convert : HTML -> Canvas -> PNG (or JPEG) -> PDF

To achieve the above, you'll need :

  1. html2canvas
  2. jsPDF
import React, { Component } from 'react';
@brenopolanski
brenopolanski / twitterAvatar.js
Created November 4, 2018 22:51
Get Twitter Avatar
const cheerio = require('cheerio');
const request = require('request');
const twitterAvatar = username => {
const cache = {};
const url = `https://mobile.twitter.com/${username}`;
return new Promise((resolve, reject) => {
if (cache[username]) {
resolve(cache[username]);
@brenopolanski
brenopolanski / gnome-terminal-not-start.md
Created October 29, 2018 18:50
Gnome terminal will not start

Probably the symlink /usr/bin/python3 points to python3.6, which it should not. Fix it by running these commands:

sudo rm /usr/bin/python3
sudo ln -s python3.5 /usr/bin/python3
@brenopolanski
brenopolanski / format-usb.md
Created October 28, 2018 13:53
Format USB in Ubuntu

Command Line Method

First try to see your volumes by writing:

fdisk -l

This will show your volumes. When you see /dev/sdb (and its partition sdb1), run the following commands to format your drive:

// recieve message
// event object contains:
// - data: message sent
// - origin (host from which the message was sent, e.g. http://blah.example.com)
// - source (reference to a Window object from which message was sent)
function postMessageHandler( event ) {
console.log("We've got a message!");
console.log("* Message:", event.data);
console.log("* Origin:", event.origin);
console.log("* Source:", event.source);
@brenopolanski
brenopolanski / vue-axios-cors.md
Last active August 14, 2023 10:10
Vue.js + Axios + CORS

Proxy requests using Webpack dev server to avoid cors in development mode.

In your webpack.config file add:

"devServer":{
  "proxy": {
    "/api": {
    "target": 'https://my-target.com',
    "pathRewrite": { '^/api': '' },
@brenopolanski
brenopolanski / convert-vob-mp4.md
Created September 18, 2018 20:52
Convert VOB to MP4, MKV, or MOV

Place all VOBs in a folder then:

sudo apt install mediainfo
mediainfo   *VOB*