Skip to content

Instantly share code, notes, and snippets.

@klzns
klzns / javascript.json
Created October 5, 2017 21:31
React Component Snippet
{
"React Component": {
"prefix": "reactComp",
"body": [
"import React, { Component } from 'react'",
"import PropTypes from 'prop-types'",
"",
"class ${1:${TM_FILENAME/(.*)\\.js/${1:/capitalize}/}} extends Component {",
" render() {",
" return (",
@klzns
klzns / index.js
Created August 15, 2017 17:13
How to add hot module replacement (react-hot-loader) in Create React App
import { AppContainer } from 'react-hot-loader' // Install `npm install react-hot-loader@next`
import React from 'react'
import App from './App'
const renderApp = (Root) => {
React.render(
<AppContainer>
<Root />
</AppContainer>,
document.getElementById('app-root')
@klzns
klzns / Links.md
Last active April 26, 2018 20:01
Links para aprender Javascript e React

Keybase proof

I hereby claim:

  • I am brenoc on github.
  • I am brenoc (https://keybase.io/brenoc) on keybase.
  • I have a public key whose fingerprint is AE0E 5CD3 D144 983C 2FF8 8C31 B6BC FD1C 4D98 43DD

To claim this, I am signing this object:

@klzns
klzns / transformToActionNames.js
Created August 15, 2016 22:25
Transform camelCase to ACTION_NAMES
function transformToActionNames(actions) {
return _.map(actions, (action) => {
let newActionName = ''
for (var index = 0; index < action.length; index++) {
var char = action[index]
if (index === 0) {
newActionName += char.toUpperCase()
continue
}
if (char == char.toUpperCase()) {
@klzns
klzns / iFramePayment.js
Created August 15, 2016 20:07
Fechamento de compra com iFrame
function handleEvents(event) {
switch(event) {
// ...
case 'sendPayments.vtex':
let checkoutPayments = event.data.arguments[0];
let transactionResponse = event.data.arguments[1];
let deviceFingerprint = event.data.arguments[2];
sendPayments(checkoutPayments, transactionResponse, deviceFingerprint);
break;
}
System.config({defaultJSExtensions: true});
System.config({
baseUrl: '/',
packages: {
'[email protected]': {
map: {
'vtex.sdk': '[email protected]',
'n1.shelf': '[email protected]',
'vtex.banner': '[email protected]',
@klzns
klzns / iso-alpha-2-to-3.json
Last active March 16, 2016 20:16
Country Code ISO Alpha 2 to Country Code ISO Alpha 3
{
"AF": "AFG",
"AX": "ALA",
"AL": "ALB",
"DZ": "DZA",
"AS": "ASM",
"AD": "AND",
"AO": "AGO",
"AI": "AIA",
"AQ": "ATA",
@klzns
klzns / _index.js
Created December 21, 2015 20:52
ISO Alpha 3 to country name localized. Translated country names in Portuguese, spanish, french and english.
var fs = require('fs');
// Files
var files = [
'es',
'fr',
'pt-br',
'us'
];
@klzns
klzns / server.js
Last active January 31, 2016 20:58
How to proxy index.html with react-transform
var express = require('express');
var webpack = require('webpack');
var httpProxy = require('http-proxy');
var proxy = new httpProxy.createProxyServer();
var config = require('./webpack.config');
var app = express();
var compiler = webpack(config);
app.use(require('webpack-dev-middleware')(compiler, {