Skip to content

Instantly share code, notes, and snippets.

View napolux's full-sized avatar
🇮🇹
Hello from Italy!

Francesco Napoletano napolux

🇮🇹
Hello from Italy!
View GitHub Profile
@napolux
napolux / index.js
Created August 17, 2018 14:53
Scrap a webpage with node.js
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');
@napolux
napolux / docker-compose.yml
Created June 4, 2018 06:21
My WordPress docker-compose.yml configuration
version: '3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: wordpress
@napolux
napolux / napolux.xml
Created January 31, 2017 09:57
Napolux OPML file
<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
<head>
<title>Francesco subscriptions in feedly Cloud</title>
</head>
<body>
<outline text="Apple" title="Apple">
<outline type="rss" text="MacRumors : Mac News and Rumors" title="MacRumors : Mac News and Rumors" xmlUrl="http://www.macrumors.com/macrumors.xml" htmlUrl="http://www.macrumors.com"/>
<outline type="rss" text="Gioxx's Wall" title="Gioxx's Wall" xmlUrl="http://feeds2.feedburner.com/gioxx" htmlUrl="http://gioxx.org"/>

Keybase proof

I hereby claim:

  • I am napolux on github.
  • I am napolux (https://keybase.io/napolux) on keybase.
  • I have a public key whose fingerprint is 546D 114A BE39 4F1A AB54 5D7F 8035 7961 09AE FC24

To claim this, I am signing this object:

@napolux
napolux / time.php
Last active October 21, 2016 14:28
Measure execution time of PHP code
<?php
$start = microtime(true);
// Your code starts here
$i = 0;
while($i < 5000000) {
$i++;
}
// Your cord ends here
@napolux
napolux / speech.js
Last active July 7, 2016 05:35
speechSynthesis API for Google Chrome
var msg = new SpeechSynthesisUtterance();
var voices = window.speechSynthesis.getVoices();
msg.voiceURI = "native";
msg.text = "hello world";
msg.lang = "en-US";
window.speechSynthesis.speak(msg);
@napolux
napolux / google.java
Last active May 18, 2016 16:34
Google VS Oracle: 9 lines of code
private static void rangeCheck(int arrayLen, int fromIndex, int toIndex) {
if (fromIndex > toIndex)
throw new IllegalArgumentException("fromIndex(" + fromIndex +
") > toIndex(" + toIndex+")");
if (fromIndex < 0)
throw new ArrayIndexOutOfBoundsException(fromIndex);
if (toIndex > arrayLen)
throw new ArrayIndexOutOfBoundsException(toIndex);
}
@napolux
napolux / install.sh
Created May 1, 2016 18:25
Come installare Let's Encrypt su un virtualhost apache su una macchina ubuntu hostata da DigitalOcean
# Installa git
sudo apt-get update
sudo apt-get install git
# Clona il repo di letsencrypt.org
sudo git clone https://github.com/letsencrypt/letsencrypt /opt/letsencrypt
# Crea il certificato per il tuo dominio
cd /opt/letsencrypt
./letsencrypt-auto --apache -d tuodominio.it
curl http://w3.org/ -d "hello=world&foo=bar" --trace-ascii /dev/stdout
== Info: Trying 128.30.52.45...
== Info: Connected to w3.org (128.30.52.45) port 80 (#0)
=> Send header, 140 bytes (0x8c)
0000: POST / HTTP/1.1
0011: Host: w3.org
001f: User-Agent: curl/7.43.0
0038: Accept: */*
0045: Content-Length: 19
@napolux
napolux / man.c
Created April 17, 2016 17:59
Sega Saturn example code
/**************************************************************/
/* Trigger jumping if needed, also variable height jump logic */
Man_JumpTrigger()
{
if ( Man.JumpFudge )
{
Man.JumpFudge--;
}