Skip to content

Instantly share code, notes, and snippets.

View lucasbento's full-sized avatar
:shipit:

Lucas Bento lucasbento

:shipit:
View GitHub Profile
@lucasbento
lucasbento / reload.sh
Created May 10, 2019 09:15
Reload react-native on Android from CLI
adb shell input keyevent 82 && adb shell input keyevent 19 && adb shell input keyevent 23
@lucasbento
lucasbento / spoof-mac-address.sh
Created October 17, 2018 07:08
Use more than 15 minutes of free wi-fi :)
#!/bin/bash
newMACAddress=$(openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//')
ifconfig en0 ether $newMACAddress
echo "🔥 new MAC address: $newMACAddress"
@lucasbento
lucasbento / PdfView.js
Last active February 12, 2018 20:04
Pdf zoom
/**
* Copyright (c) 2017-present, Wonday (@wonday.org)
* All rights reserved.
*
* This source code is licensed under the MIT-style license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
import React, {Component} from 'react';
@lucasbento
lucasbento / helper.js
Created April 19, 2017 20:35
Sanitize objects (also from mongoose) for Jest snapshot
/**
* Sanitize a test text removing the mentions of a `ObjectId`
* @param text {string} The text to be sanitized
* @returns {string} The sanitized text
*/
export const sanitizeTestText = (text) => {
const values = text.split(' ');
return values.map((value) => {
// Remove any non-alphanumeric character from value
const cleanValue = value.replace(/[^a-z0-9]/gi, '');
@lucasbento
lucasbento / circle.yml
Created April 19, 2017 14:02
Circle CI config
machine:
node:
version: 6.10.1
services:
- redis
dependencies:
pre:
# Install Yarn
- sudo apt-key adv --fetch-keys http://dl.yarnpkg.com/debian/pubkey.gpg
- echo "deb http://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
@lucasbento
lucasbento / cleanup.sh
Created February 25, 2017 13:41
Remove all `node_modules` folders on Mac
find . -name "node_modules" -exec rm -rf '{}' +
@lucasbento
lucasbento / .babelrc
Created February 9, 2017 20:35
Webpack 2 Tree Shaking
{
"presets": [
["es2015", {
"modules": false
}],
"react",
"stage-0"
],
"compact": "true",
"plugins": [
@lucasbento
lucasbento / IconographyMess.js
Last active January 13, 2017 11:04
Small script to fix a mess with directories and put all the icons `.svg` files on a single directory
import fs from 'fs';
import path from 'path';
const readDir = path => fs.readdirSync(path);
const outputDir = '/Users/Lucas/Downloads/Font';
const rootPath = '/Users/Lucas/Downloads/Icons';
const files = readDir(rootPath);
const getDirectories = (dirFiles, srcPath) => dirFiles.filter(file => fs.statSync(path.join(srcPath, file)).isDirectory());
@lucasbento
lucasbento / SomeInfinityLoadingSearch.js
Last active October 5, 2016 00:12
Easy infinity loading with React
class SomeInfinityLoadingSearch extends Component {
state = {
isLoading: false,
}
handleScroll = () => {
if (((window.innerHeight + window.scrollY) >= document.body.offsetHeight) && !this.state.isLoading) {
this.setState({
isLoading: true,
});
@lucasbento
lucasbento / justgitthings
Created June 4, 2016 12:20
Just GIT things
# Reset to a previous commit ignoring any work done
git reset --hard COMMIT_HASH
# Reset to a previous commit keeping work
git stash
git reset --hard COMMIT_HASH
git stash pop