Skip to content

Instantly share code, notes, and snippets.

View waptik's full-sized avatar
💻
Learning JavaScript and ReactJS...

Stephane Mensah waptik

💻
Learning JavaScript and ReactJS...
View GitHub Profile
@waptik
waptik / wuxiaworldsite-OnlyNovels.js
Created October 27, 2019 18:11
Get links of only novels on wuxiaworld.site's search page
[...document.querySelectorAll('.c-image-hover :not(img):not([title$=" Comics"])')].map((el) => el.title).join(',\n')
<div role="tabpanel" class="c-tabs-item">
<div class="row c-tabs-item__content">
<div class="col-4 col-sm-2 col-md-2">
<div class="tab-thumb c-image-hover">
<a href="https://wuxiaworld.site/novel/mu-lians-haunted-metropolis-comics/" title="Mu Lian’s Haunted Metropolis Comics">
<img width="193" height="278" data-src="https://wuxiaworld.site/wp-content/uploads/2019/10/Mu-Lians-Haunted-Metropolis-193x278.jpg" data-srcset="https://wuxiaworld.site/wp-content/uploads/2019/10/Mu-Lians-Haunted-Metropolis-193x278.jpg 193w, https://wuxiaworld.site/wp-content/uploads/2019/10/Mu-Lians-Haunted-Metropolis-125x180.jpg 125w" data-sizes="(max-width: 193px) 100vw, 193px" class="img-responsive effect-fade lazyloaded" src="https://wuxiaworld.site/wp-content/uploads/2019/10/Mu-Lians-Haunted-Metropolis-193x278.jpg" style="padding-top:278px; " alt="Mu-Lians-Haunted-Metropolis" sizes="(max-width: 193px) 100vw, 193px" srcset="https://wuxiaworld.site/wp-content/uploads/2019/10/Mu-Lians-Hau
@waptik
waptik / how-to-strip-all-tags-nodejs.js
Last active October 31, 2019 09:57
Looking for way to strip all tags for this "dirty" html snippet. Testing npm pkgs: striptags, strip_tags, sanitize-html
<div class="cha-words">
<p>He had already used all the tricks in his book to try to break the array but found himself still trapped in Gu Xijiu&#8217;s simple formation.</p>
<p>&#8220;Shuaaa!&#8221; A big stone was suddenly moved, and Gu Xijiu appeared three feet away from the man. She glared at him and said, &#8220;It has been five minutes. What do you have to say?&#8221;</p>
<p>Hua Qianjun remained silent. He looked at Gu Xijiu with some respect. He was willing to own up to his loss, so he said, &#8220;I will listen to your instructions!&#8221;</p>
<p>&#8220;Very good; you have already delayed us for five minutes, so you must pay it back quickly. Please move the big rock over and put it here.&#8221; She pointed at a specific location.</p><div class="kckwz5db9a4201771d" ><script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js" type="7d72dad64abc47b72af0021a-text/javascript"></script>
<ins class="adsbygoogle"
style="display:block; text-align:center;"
data-ad-layout="in-arti
@waptik
waptik / strip_tags.js
Last active October 31, 2019 10:06
This will strip all tags including `script`, `ins`, `style` and `stubborn divs`. It's made as an attempt to solve [this](https://gist.github.com/waptik/184a0c9050bb97871949e7041e4661c1). It was made as attempth to replicate `wp_strip_all_tags()` -> https://core.trac.wordpress.org/browser/tags/5.2.3/src/wp-includes/formatting.php#L5091
function strip_tags(text) {
return text.replace(/<(script|ins|style)[^>]*>([\s\S]*?)<\/(|script|ins|style)[^>]*>/gm, "").replace(/(<([^>]+)>)/ig,"").trim();
}
@waptik
waptik / devlinks.txt
Created March 17, 2020 03:44
Useful links for devs
@waptik
waptik / detectPaymentMethodFromCustomerLocation.ts
Created March 19, 2020 15:36
Select preferred payment method based on user's location
import paymentService, {paymentServiceType} from '@/services/paymentService'
import locationService, {locationServiceType} from '@/services/locationService'
// import paymentService from '@/services/paymentService'
const payWith: paymentServiceType = new paymentService()
export const locate: locationServiceType = new locationService()
// 2 letters country code
@waptik
waptik / coursesLinks.txt
Created April 17, 2020 12:31
Links to courses
@waptik
waptik / packages-projects-toUse.txt
Last active April 19, 2020 08:45
Useful packages or projects to use
https://github.com/dilame/instagram-private-api
https://github.com/social-manager-tools/socialmanagertools-igbot
https://github.com/jlobos/instagram-web-api
https://github.com/tobiaslins/avatar
https://github.com/oktaysenkan/instagram-api
https://github.com/preethamvishy/instalytics
https://github.com/ashalogic/IG-SAnalyzer
https://github.com/moigonzalez/travelmap/pulse
https://github.com/rolspace/instagram-server-side
https://github.com/shameemreza/instagram-widget
...
const tabs = [
'Account',
'Profile',
'Payment',
'Notification',
'Advanced'
]
...
@waptik
waptik / dbUtils.js
Created September 11, 2020 02:29
Export mongodb collection data and import it back using node js
// credit link: @https://stackoverflow.com/questions/63573995/export-mongodb-collection-data-and-import-it-back-using-node-js
const fs = require('fs');
const dbName = 'testDB';
const client = new MongoClient('mongodb://localhost:27017', { useUnifiedTopology:true });
// function to export db document
function exportDbCollection(){