Skip to content

Instantly share code, notes, and snippets.

View daniel12fsp's full-sized avatar

Daniel Pereira daniel12fsp

View GitHub Profile
@daniel12fsp
daniel12fsp / delete_all_old_branch.sh
Created January 6, 2020 12:49
Delete all old branch
git branch --format ' %(refname:short)' | xargs -n1 -I {} git branch -d {}
@daniel12fsp
daniel12fsp / node.js
Created January 5, 2020 15:11
Search node by content(javascript)
const xpath = "//a[contains(text(),'text')]";
const matchingElement = document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
@daniel12fsp
daniel12fsp / first_parent_branch.sh
Created November 29, 2019 12:56
Get hash first parent of branch
git log --first-parent -1 --format="%H"
@daniel12fsp
daniel12fsp / forward_ssh.sh
Created November 19, 2019 12:16
forward_ssh
#ssh -L{port on your PC}:localhost:{database's port} root@{server IP}
ssh -L3308:localhost:3306 [email protected]
//function stolen from https://dev.to/aligoren/building-url-shortener-with-mongodb-express-framework-and-typescript-4a71
function saveClipBoard(text) {
// Textarea allow to use newline("\n")
const textarea = document.createElement('textarea');
document.body.appendChild(textarea);
textarea.value = text;
textarea.select();
const success = document.execCommand('copy');
document.body.removeChild(textarea);
return success;
function runWebWorker(func) {
if (typeof func !== "function") {
throw new Error("Argument must be a function");
}
if (func.name === "") {
throw new Error("Function must have a valid name");
}
return function (args) {
return new Promise((resolve, reject) => {
const code = `
@daniel12fsp
daniel12fsp / Saga.ts
Created October 12, 2019 10:04
WebWorker + Webpack4 + Saga
import { all, call, take } from 'redux-saga/effects';
import { takeLatest } from 'redux-saga/effects'
import { createStore, compose, applyMiddleware } from 'redux';
import createSagaMiddleware from 'redux-saga'
//@ts-ignore
import * as MyWorker from "worker-loader!./trywebWorker"
export function WebWorker() {
return new Promise((resolve, reject) => {
@daniel12fsp
daniel12fsp / WebWorkerAndSaga.js
Created October 12, 2019 09:22
WebWorkerAndSaga
import { all, call, take } from 'redux-saga/effects';
import { takeLatest } from 'redux-saga/effects'
import { createStore, compose, applyMiddleware } from 'redux';
import createSagaMiddleware from 'redux-saga'
export function WebWorker() {
const code = `
self.addEventListener('message', function (e) {
const str = e.data
@daniel12fsp
daniel12fsp / find.sh
Last active October 1, 2019 16:51
Find exclude some path
find . -name "*.js" -not -path '*node_modules*' -exec ls {} \;
@daniel12fsp
daniel12fsp / yarn.sh
Created June 28, 2019 11:08
How to execute yarn test in different project and fail if are error
ls -d folder-* | xargs -n1 -I {} sh -c 'yarn --cwd {} test|| exit 255'