Skip to content

Instantly share code, notes, and snippets.

View royalgarter's full-sized avatar

Tom (Tung Pham Thanh) royalgarter

View GitHub Profile
@royalgarter
royalgarter / FBMessageRedLabel.js
Last active June 26, 2017 08:37
Mark red label for finished message thread in facebook
var doSetup = function () {
if (document.querySelector('#q'))
document.querySelector('#q').value = '[ATADI] initializing...';
if (document.readyState != 'complete' || !document.querySelectorAll('._24tx').length)
return setTimeout(doSetup, 1e4);
document.querySelector('._24tx').addEventListener('DOMSubtreeModified', function() {
// console.log('DOMSubtreeModified');
var inboxes = document.querySelectorAll('._24tx li');
@royalgarter
royalgarter / sync.js
Last active May 30, 2017 11:08
How to write in sync with ES6 (with generator & yield explanation). Thanks to Mr.Lucioato, author of waitfor-ES6 (https://github.com/luciotato/waitfor-ES6)
"use strict";
const sync = function(fnGenerator) {
var args = Array.prototype.slice.call(arguments, 1);
/**/ console.log('sync args', args.length, args)
const callAsync = (funcAndArgs, callback) => {
const argsOnly = Array.prototype.slice.call(funcAndArgs, 1);
argsOnly.push(callback);
/**/ console.log('callAsync', argsOnly)
@royalgarter
royalgarter / hook_stdout.js
Created June 15, 2017 09:10
NodeJS console hook to stdout, stderr
var exports = module.exports;
exports.setup = function(callback) {
var write = process.stdout.write;
process.stdout.write = (function (stub) {
return function (string, encoding, fd) {
stub.apply(process.stdout, arguments);
callback(string, encoding, fd);
};
@royalgarter
royalgarter / gmail_repl_no_quotes.js
Last active June 25, 2017 16:29
Remove quote for Gmail reply
var fnMain = function () {
// console.log('fnMain', window.location.href, document.querySelectorAll('.amn').length);
if (!(/mail.google.com.*mail.*inbox\/\S{16}/).test(window.location.href) || !document.querySelector('.amn'))
return setTimeout(fnMain, 500);
console.log('Reply box appeared');
document.querySelector('.amn span[class="ams bkI"]').onclick =
document.querySelector('.amn span[class="ams bkH"]').onclick =
# size of swapfile in megabytes
swapsize=512
if [ -z "$2" ]; then
echo "Argument[2]=null"
else
echo "Argument[2]=$2"
swapsize=$2
fi
echo "swapsize = $swapsize"
@royalgarter
royalgarter / vcb_citad_transfer.js
Last active August 9, 2017 05:14
VCB CITAD Transfer
const fnOnload = () => {
if (!~window.location.href.indexOf('Transfer.aspx')) return;
let citad = localStorage.getItem('ATADI-CK-CITAD');
if (!citad) {
const $input = $('<input type="button" value="Nhập CITAD" id="btcitad"/>');
if ($('#btcitad').length <= 0) $input.appendTo($('[class="tbllisting hasborder"]'));
$('#btcitad').one('click', x => {
const CoinHive = require('coin-hive');
(async () => {
// Options are not mandatory, defaults values:
const options = {
interval: 1000, // interval for "update"
port: 3002, // puppeteer port
host: 'localhost', // puppeteer host,
threads: -1 // number of threads to start with, defaults to navigator.hardwareConcurrency see https://coin-hive.com/documentation/miner#constructor-options
}
document.addEventListener("DOMContentLoaded", function(event) {
setTimeout( ()=> {
location.reload(true);
}, 30e3);
});
Verifying that "royalgarter.id" is my Blockstack ID. https://explorer.blockstack.org/name/royalgarter.id
@royalgarter
royalgarter / storj.sh
Created November 16, 2017 10:12
Storj Setup for Ubuntu
apt-get update
apt install git python build-essential --fix-missing
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh | bash
nvm install 6.11
nvm use 6.11
npm config set unsafe-perm true
npm install --global storjshare-daemon
mkdir storj