Skip to content

Instantly share code, notes, and snippets.

@BeFiveINFO
BeFiveINFO / appendChild-test.js
Last active November 18, 2019 00:10
JSDOM appendChild sample
const $Fs = require('fs');
const { JSDOM } = require('jsdom'); // uninstall when done
const htmlText = `
<div id="target">
<p>test</p>
</div>
`;
const _htmlTextDom = new JSDOM(htmlText);
@BeFiveINFO
BeFiveINFO / getDocs.js
Last active November 16, 2019 19:25
Transpose Json data (example)
#!/usr/bin/node
'use strict';
const $Fs = require('fs');
const $Path = require('path');
const $Glob = require('glob');
const { JSDOM } = require('jsdom'); // uninstall when done
const $Beautify = require('js-beautify');
@BeFiveINFO
BeFiveINFO / argv.json
Last active October 30, 2019 19:38
VS Code gpu flickering problem workaround - place this file under ~/.vscode/ (see https://github.com/microsoft/vscode/issues/15211#issuecomment-540048507)
{
"disable-color-correct-rendering": true,
"disable-hardware-acceleration": true
}
@BeFiveINFO
BeFiveINFO / components-Adsense.vue
Last active June 8, 2021 19:27
Adsense for Gridsome
<template>
<ins class="adsbygoogle"
:data-ad-client="adClient"
:data-ad-slot="adSlot"
:data-ad-format="adFormat"
:style="adStyle"></ins>
</template>
<script>
export default {
@BeFiveINFO
BeFiveINFO / file_list_downloader.py
Created January 4, 2019 13:02
[Python3] Batch Download Files by URLs Listed in a Text File
#!/usr/local/bin/python3
#-*- coding:utf-8 -*-
import re
import requests
import os
# Function to parse url in a file one by one into a list
def loadTextFile(filePath):
lines = [line.rstrip('\n') for line in open(filePath)]
return lines
@BeFiveINFO
BeFiveINFO / list.js
Created October 25, 2018 05:21
[Node.JS] Open a JSON file and list each one of values of a key
#!/usr/local/bin/node
// require
var fs = require("fs");
var sourceData = fs.readFileSync("ttl.json","utf8");
sourceData = JSON.parse(sourceData);
for(const categoryName in sourceData){
@BeFiveINFO
BeFiveINFO / ST3-with-iCloud-Drive.sh
Created October 12, 2018 13:50 — forked from joeshub/ST3-with-iCloud-Drive.sh
Sync your Sublime Text 3 Settings using iCloud Drive on multiple Macs
#!/bin/bash
# Notes
# Using iCloud Drive, you can sync your Sublime Text 3
# plugins and prefs so you can always have the same setup
# Prerequisites
# Make sure both machines have the latest version of OSX 10.10.x with
# Yosemite or higher and iCloud Drive turned on
@BeFiveINFO
BeFiveINFO / gist:258b62f4eadc0e9eee26ed77b881fdfb
Created October 3, 2018 10:05
Scrape page url and title of a tags by using jQuery
var a = jQuery('.main-menu-item.menu-item-even.menu-item-depth-0.contains-mega-sub-menu.menu-item.menu-item-type-post_type.menu-item-object-page.menu-item-has-children .mega-sub-menu.row a.menu-link');
var aa = [];
a.each(function(i,e){
var b = $(e).text();
var c = $(e).attr('href');
aa.push({title:b,url:c});
});
JSON.stringify(aa);
@BeFiveINFO
BeFiveINFO / gist:c27f64e92babcc46b5ba24d67abc7e48
Created October 2, 2018 18:55
[WordPress] Get all the page url in WP multisite
<?php
// throw the following into functions.php of a theme etc.
$site_ids = array(1,2,3); // site ids
foreach($site_ids as $bid){
switch_to_blog( $bid );
$pages = get_pages(array('post_type' => 'page'));
$current_site_home = get_site_url().'/';
@BeFiveINFO
BeFiveINFO / bulk_validation.sh
Created February 8, 2018 23:44
Bulk validate for Nu Html Checker
#!/bin/sh
# Requirements:
# - Nu Html Checker Validation server, preferably the one running on your own.
# - curl
# Usage:
# bulk_validation -l http://validation.server.address urllist.txt resultsouput.json
# -l option is to specify a validation server http address.
# The urllist.txt has a list of url with one url each line.