Skip to content

Instantly share code, notes, and snippets.

View feliperohdee's full-sized avatar
🚀
Going High

Felipe Rohde feliperohdee

🚀
Going High
View GitHub Profile
@feliperohdee
feliperohdee / AWS.js
Created April 27, 2020 01:52
s3 based cache
const _ = require('lodash');
const AWS = require('aws-sdk');
const rx = require('rxjs');
const rxop = require('rxjs/operators');
AWS.config.update({
accessKeyId: process.env.ACCESS_KEY_ID,
secretAccessKey: process.env.SECRET_ACCESS_KEY,
region: process.env.REGION
});
@feliperohdee
feliperohdee / patterns.html
Created April 8, 2020 13:31
svg patterns
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Patterns.html</title>
</head>
<body>
@feliperohdee
feliperohdee / intercept.js
Created February 8, 2020 18:04
chrome.debugger intercept scripts
(async () => {
const scripts = new Map([
['app', chrome.runtime.getURL('static/app.js')],
['app2', chrome.runtime.getURL('static/app2.js')],
['progress', chrome.runtime.getURL('static/progress.js')]
]);
const p = async (fn, ...args) => {
return new Promise((resolve, reject) => {
return fn(...[...args, (...response) => {
@feliperohdee
feliperohdee / cache.js
Created December 11, 2019 18:22
LRU cache
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 July 23, 2019 12:50
on demand script loader
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);
}
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 12:38
AWS Lambda: Reusing database connections
const Redis = require('ioredis');
const redis = new Redis();
exports.handler = (event, context, callback) => {
context.callbackWaitsForEmptyEventLoop = false;
redis.pipeline()
.set('a', 'b')
.get('a')
.exec()
#!/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 15:09 — forked from khelll/install-redis.sh
Installing Redis on Amazon Linux
#!/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"
{
"beautify.config": {
"js": {
"e4x": true
},
"css": {
"selector_separator_newline": true,
"newline_between_rules": true,
"preserve_newlines": true,
"end_with_newline": true