This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1. preparation | |
## 1.1 create cert-webroot | |
sudo mkdir /opt/sites/cert-webroot | |
cd /opt/sites/cert-webroot | |
## 1.2 create demo page | |
sudo touch index.html | |
sudo echo "<!DOCTYPE html>\n<html lang="en">\n<head>\n<meta charset="UTF-8">\n<title>Demo Site</title>\n</head>\n<body>\n<h1>This is a demo site</h1>\n</body>\n</html>" > index.html | |
## 1.3 update nginx default config | |
cd /etc/nginx/sites-enabled | |
vim default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## sitename.com | |
server { | |
listen 80; | |
listen [::]:80; | |
# expires $expires; | |
server_name <site_name>; | |
location ^~ /.well-known/acme-challenge/ { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## demo site | |
server { | |
listen 80; | |
listen [::]:80; | |
server_name <site_name>; | |
return 301 https://$server_name$request_uri; | |
} | |
server { | |
listen 443 ssl http2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
listen [::]:80; | |
server_name <api_server_name>; | |
return 301 https://$server_name$request_uri; | |
} | |
server { | |
listen 443 ssl http2; | |
listen [::]:443 ssl http2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const elem = document.querySelecor('#scollableElement'); | |
// scroll to specific position | |
elem.scrollTop = 100px; | |
elem.scrollLeft = 200px; | |
// scroll to bottom/right | |
elem.scrollTop = elem.scrollHeight; | |
elem.scrollLeft = elem.scrollWidth; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create conversation | |
curl -X POST \ | |
-H "X-LC-Id: JeUOhVkPeBkCbfnRA3mWWe8j-gzGzoHsz" \ | |
-H "X-LC-Key: Sln8zi7RaBvwIvE1ka6DYWf2" \ | |
-H "Content-Type: application/json" \ | |
-d '{"name":"My Private Room","m": ["BillGates", "SteveJobs"]}' \ | |
https://jeuohvkp.api.lncld.net/1.2/rtm/conversations | |
# get conversation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const path = require('path'); | |
const http = require('http'); | |
function createServer(videoRepoPath) { | |
return http.createServer((req, res) => { | |
if (/video\/.*\/view/gi.test(req.url)) { | |
console.log(req.url, req.url.split('/')); | |
const [, , video] = req.url.split('/'); | |
const ext = path.extname(video); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def convert_complement_to_dec(str): | |
if str[0] == '1': | |
reversed_str = '' | |
for bit in str[1:]: | |
reversed_str += '1' if bit == '0' else '0' | |
return -1 * (int('0b' + reversed_str, 2) + 1) | |
return int('0b' + str, 2) | |
def convert_dec_to_complement(val): | |
val_bin = bin(val) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from operator import mul | |
from functools import reduce | |
from itertools import combinations | |
def all_combinations_from(arr, start=2): | |
result = list() | |
for i in range(start, len(arr) + 1): | |
for t in combinations(arr, i): | |
result.append(reduce(mul, t)) | |
print('combinations result: ', result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// usage: node image-viewer <Gallery Root> | |
const fs = require('fs'); | |
const path = require('path'); | |
const http = require('http'); | |
// yarn add global gm & apt install graphicmagic | |
let gm; | |
try { | |
const gm = require('gm'); | |
catch (err) { | |
console.warn('gm not found, run `$npm install gm` in script directory to install'); |
OlderNewer