Skip to content

Instantly share code, notes, and snippets.

View yangwao's full-sized avatar
🥋
Mastering the code

Matej yangwao yangwao

🥋
Mastering the code
View GitHub Profile
@yangwao
yangwao / gist:3328b61a1c4addb6ab50
Created July 5, 2015 11:29
Slow digitalocean?
I've just created $80/mo droplet at FRA1 ubuntu 15.04 x64 and this happend after I did $ apt-get install htop
Need to get 65.3 kB of archives.
After this operation, 203 kB of additional disk space will be used.
Get:1 http://mirrors.digitalocean.com/ubuntu/ vivid/universe htop amd64 1.0.3-1 [65.3 kB]
Fetched 65.3 kB in 31s (2,059 B/s)
@yangwao
yangwao / nginx.conf
Created March 10, 2016 00:35 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
⫸ cat /Users/wao/.npm/_logs/2017-05-06T09_46_27_579Z-debug.log
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli '/usr/local/bin/npm5',
1 verbose cli 'i',
1 verbose cli '-g',
1 verbose cli 'standard-readme' ]
2 info using npm@5.0.0-beta.43
3 info using node@v7.9.0
4 notice BETA npm5 is beta software. Please see https://github.com/npm/npm/issues/16510 for known issues, and please file a new one if you find something new.
@yangwao
yangwao / gist:5a0a7ad54e668df5a8fca3fe62db2058
Created May 7, 2017 11:21
sudo BLUEBIRD_DEBUG=true npm5 i -g standard-readme
⫸ bash
bash-3.2$ sudo BLUEBIRD_DEBUG=true npm5 i -g standard-readme
npm notice BETA npm5 is beta software. Please see https://github.com/npm/npm/issues/16510 for known issues, and please file a new one if you find something new.
npm ERR! uid must be an unsigned int
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/wao/.npm/_logs/2017-05-07T11_18_31_111Z-debug.log
bash-3.2$ cat /Users/wao/.npm/_logs/2017-05-07T11_18_31_111Z-debug.log
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm5', 'i' ]
2 info using npm@5.0.0-beta.43
3 info using node@v7.9.0
4 notice BETA npm5 is beta software. Please see https://github.com/npm/npm/issues/16510 for known issues, and please file a new one if you find something new.
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 silly install normalizeTree
8 silly install loadIdealTree
9 silly install cloneCurrentTreeToIdealTree
@yangwao
yangwao / gist:5223042dfe17c2267ff433dc515c2d93
Created July 11, 2017 12:50
Date mystery with timezones
Local
⫸ node -v
v0.12.18
> date = new Date(2017, 06, 01)
Sat Jul 01 2017 00:00:00 GMT+0200 (CEST)
> Math.floor(date/(86400*1000)) + 1
17348
> date = new Date(Date.UTC(2017, 06, 01))
Sat Jul 01 2017 02:00:00 GMT+0200 (CEST)
> Math.floor(date/(86400*1000)) + 1
const r2 = require('r2')
const telegramUrl = 'https://api.telegram.org/bot'
const token = '180473239:VHqX8dOnuhGlJXyurVHqX8dO8yhqX8'
/**
* A basic reply bot
* @returns {object}
*/
module.exports = async (context) => {
const m = context.params.message
@yangwao
yangwao / post.json
Created May 17, 2018 18:34
http request
⫸ http -b POST https://api.telegram.org/bot180473239:VHqX8dOnuhGlJXyurVHqX8dO8yhqX8/setWebhook url=https://yangwao.lib.id/replybot@dev/
{
"description": "Webhook was set",
"ok": true,
"result": true
}
"curl - request POST - url https://api.telegram.org/bot575419417:AAEmmflOhwgZnMsut0ibQn1gY6i7Ym7q05Y/setWebhook - header 'content-type: application/json' - data '{"url": "https://JanethL.lib.id/replybot@dev/"}"
@yangwao
yangwao / nginx-and-certbot-config.md
Created August 1, 2018 10:38 — forked from rkaramandi/nginx-and-certbot-config.md
Running NGINX and CertBot Containers on the Same Host

Running NGINX and CertBot Containers on the Same Host

The Problem

A lot of people run into the problem of running Let's Encrypt's CertBot Tool and an NGINX on the same container host. A big part of this has to do with CertBot needing either port 80 or 443 open for the tool to work as intended. This tends to conflict with NGINX as most people usually use port 80 (HTTP) or 443 (HTTPS) for their reverse proxy. Section 1 outlines how to configure NGINX to get this to work, and Section 2 is the Docker command to run CertBot.

1. NGINX Configuration

I use Docker Compose (docker-compose) for my NGINX server. My docker-compose.yml file looks something like this: