Skip to content

Instantly share code, notes, and snippets.

View slaveofcode's full-sized avatar
🎯
Debugging

Aditya Kresna Permana slaveofcode

🎯
Debugging
View GitHub Profile
@slaveofcode
slaveofcode / puppeteer_scarpper.js
Created October 31, 2018 02:56
Simple Puppeteer Scrapper
const puppeteer = require('puppeteer');
const URL = 'https://coding.napolux.com';
puppeteer.launch({ headless: true, args: ['--no-sandbox', '--disable-setuid-sandbox'] }).then(async browser => {
const page = await browser.newPage();
await page.setViewport({width: 320, height: 600})
await page.setUserAgent('Mozilla/5.0 (iPhone; CPU iPhone OS 9_0_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13A404 Safari/601.1')
await page.goto(URL, {waitUntil: 'networkidle0'});
await page.waitForSelector('body.blog');
<!DOCTYPE html>
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
body {
background: repeat url('data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/7QCIUGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAGscAVoAAxslRxwCAAACAAAcAnQAV8KpIENoYWV5b3VuZ1dpbGxOZXZlckNoYWVvbGQgLSBodHRwOi8vd3d3LnJlZGJ1YmJsZS5jb20vcGVvcGxlL0NoYWV5b3VuZ1dpbGxOZXZlckNoYWVvbAD/4gxYSUNDX1BST0ZJTEUAAQEAAAxITGlubwIQAABtbnRyUkdCIFhZWiAHzgACAAkABgAxAABhY3NwTVNGVAAAAABJRUMgc1JHQgAAAAAAAAAAAAAAAAAA9tYAAQAAAADTLUhQICAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABFjcHJ0AAABUAAAADNkZXNjAAABhAAAAGx3dHB0AAAB8AAAABRia3B0AAACBAAAABRyWFlaAAACGAAAABRnWFlaAAACLAAAABRiWFlaAAACQAAAABRkbW5kAAACVAAAAHBkbWRkAAACxAAAAIh2dWVkAAADTAAAAIZ2aWV3AAAD1AAAACRsdW1pAAAD+AAAABRtZWFzAAAEDAAAACR0ZWNoAAAEMAAAAAxyVFJDAAAEPAAACAxnVFJDAAAEPAAACAxiVFJDAAAEPAAACAx0ZXh0AAAAAENvcHlyaWdodCAoYykgMTk5OCBIZXdsZXR0LVBhY2thcmQgQ29tcGFueQAAZGVzYwAAAAAAAAASc1JHQiBJRUM2MTk2Ni0yLjEAAAAAAAAAAAAAABJzUkdCIElFQzYxOTY2LTIuMQAAAAAAAA
@slaveofcode
slaveofcode / podeng-extend.js
Created July 26, 2018 07:46
Podeng extend object
const { blueprint, types, validator } = require('podeng');
const Car = blueprint.object({
wheels: types.integer({ default: 4 }),
color: types.options(['Red', 'Green', 'Blue']),
brand: types.string
})
const Truck = blueprint.extend(Car, {
wheels: types.integer({ default: 6 })
@slaveofcode
slaveofcode / locales.json
Created July 25, 2018 09:13
Locales in JSON format
{
"af": "Afrikaans",
"sq": "Albanian",
"am": "Amharic",
"ar_DZ": "Arabic - Algeria",
"ar_BH": "Arabic - Bahrain",
"ar_EG": "Arabic - Egypt",
"ar_IQ": "Arabic - Iraq",
"ar_JO": "Arabic - Jordan",
"ar_KW": "Arabic - Kuwait",
@slaveofcode
slaveofcode / podeng-in-express.js
Last active July 25, 2018 03:01
Podeng Example to Use in ExpressJs
const { blueprint, types, validator } = require('podeng');
async function handler(req, res, next) {
const UserShema = blueprint.object({
name: types.string({ serialize: { to: 'username' }}),
age: types.integer
});
const params = req.params;
@slaveofcode
slaveofcode / example-express-joi.js
Last active July 24, 2018 11:12
Example RESTful API on Express with Joi
async function handler(req, res, next) {
const userSchema = Joi.object().keys({
name: Joi.string().required(),
age: Joi.number().integer()
});
const params = req.params;
const {error, validValues} = Joi.validate(params, userSchema);
let result = null;
@slaveofcode
slaveofcode / meta-tags.md
Created July 5, 2018 04:02 — forked from lancejpollard/meta-tags.md
Complete List of HTML Meta Tags

Copied from http://code.lancepollard.com/complete-list-of-html-meta-tags/

Basic HTML Meta Tags

<meta name="keywords" content="your, tags"/>
<meta name="description" content="150 words"/>
<meta name="subject" content="your website's subject">
<meta name="copyright"content="company name">
<meta name="language" content="ES">
@slaveofcode
slaveofcode / social-snippet.html
Created July 5, 2018 04:02 — forked from tgdev/social-snippet.html
Social media sharing snippet for facebook, twitter and pinterest. Place in <head> of your pages More info below: Facebook Open Graph tags - http://davidwalsh.name/facebook-meta-tags Twitter Cards - https://dev.twitter.com/docs/cards Pinterest Rich Pins - http://developers.pinterest.com/rich_pins/
<!-- Facebook Open Graph tags -->
<meta property="og:image" content="" />
<meta property="og:site_name" content="" />
<meta property="og:type" content="" />
<meta property="og:url" content="" />
<meta property="og:title" content="" />
<!-- Twitter Card -->
<meta name="twitter:card" content="summary" />
<meta name="twitter:creator" content="">
@slaveofcode
slaveofcode / README.md
Created July 5, 2018 04:02 — forked from magnetikonline/README.md
Minimum Open Graph tags required for a webpage - for use with Facebook.

Open Graph tags for page <head>.

<meta property="og:title" content="title" />
<meta property="og:description" content="desc" />
<meta property="og:type" content="website" />
<meta property="og:url" content="http://url.com/" />
<meta property="og:image" content="http://url.com/image.jpg" />
@slaveofcode
slaveofcode / ID.js
Created April 20, 2018 17:07
ID - a unique ID/name generator for JavaScript
// Generate unique IDs for use as pseudo-private/protected names.
// Similar in concept to
// <http://wiki.ecmascript.org/doku.php?id=strawman:names>.
//
// The goals of this function are twofold:
//
// * Provide a way to generate a string guaranteed to be unique when compared
// to other strings generated by this function.
// * Make the string complex enough that it is highly unlikely to be
// accidentally duplicated by hand (this is key if you're using `ID`