Skip to content

Instantly share code, notes, and snippets.

🚀
Going High

Felipe Rohde feliperohdee

🚀
Going High
Block or report user

Report or block feliperohdee

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
View cache.js
const _ = require('lodash');
const LRU = require('lru-cache');
class Cache {
constructor(maxSizeInMB = 128) {
this.lru = new LRU({
max: maxSizeInMB * 1e+6,
length: n => Buffer.byteLength(n, 'utf8')
});
}
@feliperohdee
feliperohdee / loader.js
Created Jul 23, 2019
on demand script loader
View loader.js
export const loadScript = (id, url, test) => new Promise(resolve => {
let s = document.getElementById(id);
if (!s) {
s = document.createElement('script');
s.setAttribute('id', id);
s.defer = true;
s.src = url;
document.body.appendChild(s);
}
View classic solution
import React, { Component } from 'react';
import { Image, Button, Icon} from 'semantic-ui-react';
import Style from './card1.module.css';
import Photo from '../food.jpg';
class Card1 extends Component {
constructor(props) {
super(props);
const {
@feliperohdee
feliperohdee / index.js
Created May 30, 2018
AWS Lambda: Reusing database connections
View index.js
const Redis = require('ioredis');
const redis = new Redis();
exports.handler = (event, context, callback) => {
context.callbackWaitsForEmptyEventLoop = false;
redis.pipeline()
.set('a', 'b')
.get('a')
.exec()
View disable-transparent-hugepages
#!/bin/bash
### BEGIN INIT INFO
# Provides: disable-transparent-hugepages
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Disable Linux transparent huge pages
# Description: Disable Linux transparent huge pages, to improve
# database performance.
### END INIT INFO
@feliperohdee
feliperohdee / install-redis.sh
Created May 25, 2018 — forked from khelll/install-redis.sh
Installing Redis on Amazon Linux
View install-redis.sh
#!/bin/bash
###############################################
# To use:
# chmod +x install-redis.sh
# ./install-redis.sh
###############################################
version=3.2.0
echo "*****************************************"
echo " 1. Prerequisites: Install updates, set time zones, install GCC and make"
View shortcuts.json
{
"beautify.config": {
"js": {
"e4x": true
},
"css": {
"selector_separator_newline": true,
"newline_between_rules": true,
"preserve_newlines": true,
"end_with_newline": true
View image_handler.go
package main
import (
"bytes"
"encoding/base64"
"errors"
"github.com/aws/aws-lambda-go/lambda"
"github.com/disintegration/imaging"
"github.com/nickalie/go-webpbin"
"io/ioutil"
@feliperohdee
feliperohdee / GraphQLMux.js
Last active Jan 31, 2018
Multiplex many GraphQL requests
View GraphQLMux.js
/*
Usage:
const http = json => fetch('http://yourGraphQLEndpoint.com', {
method: 'POST',
cache: 'no-store',
headers: {
'content-type': 'application/json'
},
body: JSON.stringify(json)
View Events.js
import filter from 'lodash/filter';
import forEach from 'lodash/forEach';
import isFunction from 'lodash/isFunction';
import isString from 'lodash/isString';
export default class Events {
constructor(persist) {
this._fns = [];
}
You can’t perform that action at this time.