Skip to content

Instantly share code, notes, and snippets.

View 8bu's full-sized avatar
🏠
Working from home

Long Nguyen 8bu

🏠
Working from home
View GitHub Profile
@8bu
8bu / vite.config.js
Created April 20, 2022 04:27 — forked from FbN/vite.config.js
vite.config.js node built-in polyfills
// yarn add --dev @esbuild-plugins/node-globals-polyfill
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill'
// yarn add --dev @esbuild-plugins/node-modules-polyfill
import { NodeModulesPolyfillPlugin } from '@esbuild-plugins/node-modules-polyfill'
// You don't need to add this to deps, it's included by @esbuild-plugins/node-modules-polyfill
import rollupNodePolyFill from 'rollup-plugin-node-polyfills'
export default {
resolve: {
alias: {
@8bu
8bu / gist:2731e8bdaae48373ebc8ccbfc3e2fa23
Created March 2, 2021 16:31 — forked from thgiang/gist:e222f036806f126f51a0b75a81956c20
Control real chrome browser without notice: "Chrome is being controlled by automated test software"
Random rd = new Random();
string remote_port = rd.Next(9000, 9999).ToString();
// Open real Chrome
Process process = new Process();
process.StartInfo.UseShellExecute = true;
process.StartInfo.FileName = "chrome";
process.StartInfo.Arguments = "https://thgiang.com --load-extension=\"C:\\Users\\Admin\\Desktop\\my_extension\" --disable-gpu --new-window --remote-debugging-port=" + remote_port + " --user-data-dir=\"C:\\Profile\" --proxy-server=\""+proxy+"\" --disable-infobars --disable-notifications --window-size=1366,768"; //--window-position=0,0 --window-size=1200,800 --disable-images
process.Start();
Thread.Sleep(1000);
@8bu
8bu / provider.ts
Created February 5, 2021 04:27
0x/subprovider replace Ledger default transport factory to WebUSB
import { LedgerEthereumClient, Web3ProviderEngine as ProviderEngine } from '@0x/subproviders/lib/src'; // https://github.com/0xProject/0x-monorepo/issues/1400
import { LedgerSubprovider } from '@0x/subproviders/lib/src/subproviders/ledger'; // https://github.com/0xProject/0x-monorepo/issues/1400
import CacheSubprovider from 'web3-provider-engine/subproviders/cache';
import Eth from '@ledgerhq/hw-app-eth';
import TransportWebUSB from '@ledgerhq/hw-transport-webusb';
export enum LedgerDerivationPath {
'Legacy' = "44'/60'/0'",
'LedgerLive' = "44'/60'/0'/0",
}
@8bu
8bu / README.md
Created February 17, 2020 08:42 — forked from pbojinov/README.md
Two way iframe communication- Check out working example here: http://pbojinov.github.io/iframe-communication/

Two way iframe communication

The main difference between the two pages is the method of sending messages. Recieving messages is the same in both.

Parent

Send messages to iframe using iframeEl.contentWindow.postMessage Recieve messages using window.addEventListener('message')

iframe

@8bu
8bu / autoloadComponents.js
Created May 9, 2019 19:02 — forked from Gkiokan/autoloadComponents.js
Autoload *.vue files as Component and register them
/*
Autoload all current vue files as component and register them by their name.
---
Author: Gkiokan Sali
Date: 2019-05-09
*/
import Vue from 'vue'
const requireContext = require.context('./', false, /.*\.vue$/)
@8bu
8bu / custom-component with v-model
Created January 23, 2019 09:33
V-model Custom Component usage
v-model uses the @input event by default, so if you want to use v-model on a custom component you need to emit the input event to the parent. So, in your component, you simply do:
<input class="product_name form-control" @input="$emit('input', $event.target.value)" />
Now in your parent you can do:
<products-list v-model="product.name"></products-list>
You can see the full example on this JSFiddle: https://jsfiddle.net/7s2ugt11/
@8bu
8bu / time-travel.git
Created January 15, 2019 03:24
delete a commit you accidentally pushed into github
git reset --hard <prev_commit_id>
git push --force
@8bu
8bu / axios-catch-error.js
Created October 1, 2018 13:38 — forked from fgilio/axios-catch-error.js
Catch request errors with Axios
axios.put(this.apiBaseEndpoint + '/' + id, input)
.then((response) => {
// Success
})
.catch((error) => {
// Error
if (error.response) {
// The request was made and the server responded with a status code
// that falls out of the range of 2xx
// console.log(error.response.data);
/* styles for '...' */
.block-with-text {
/* hide text if it more than N lines */
overflow: hidden;
/* for set '...' in absolute position */
position: relative;
/* use this value to count block height */
line-height: 1.2em;
/* max-height = line-height (1.2) * lines max number (3) */
max-height: 3.6em;
@8bu
8bu / jqueryGetText.js
Last active August 24, 2018 15:05
Inject Jquery to website through console
$("p, h1, h2, h3, h4, h5, span").each(function() {
$(this).on("mouseenter", function() {
$(this).css("background-color", "#F1A9A2");
$(this).on("mouseleave", function() {
$(this).css("background-color", "");
});
});
$(this).on("click", function() {
console.log($(this).text());
});