Skip to content

Instantly share code, notes, and snippets.

View 8bu's full-sized avatar
🪵
Sending logs

Long Nguyen 8bu

🪵
Sending logs
View GitHub Profile
@8bu
8bu / neo-blessed.d.ts
Last active April 6, 2025 13:53
neo-blessed.d.ts
declare module 'neo-blessed' {
// Base event types
export type BlessedEventHandler = (args?: any) => void;
export type KeyEventHandler = (ch?: string, key?: { name: string; full: string; sequence: string; ctrl: boolean; meta: boolean; shift: boolean }) => void;
export type MouseEventHandler = (data: { x: number; y: number; action: string }) => void;
// Base node options
export interface NodeOptions {
screen?: Screen;
parent?: Node;
@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());
});
function onEdit() {
// Re: https://productforums.google.com/d/topic/docs/gnrD6_XtZT0/discussion
//
// This script prevents cells from being updated. When a user edits a cell on any sheet,
// it is checked against the same cell on a helper sheet, and:
//
// - if the value on the helper sheet is empty, the new value is stored on both sheets
// - if the value on the helper sheet is not empty, it is copied back to the cell on
// the source sheet, undoing the change
//