Skip to content

Instantly share code, notes, and snippets.

View ezirmusitua's full-sized avatar
🎯
Focusing

ezirmusitua ezirmusitua

🎯
Focusing
View GitHub Profile
@ezirmusitua
ezirmusitua / install-332.sh
Last active January 17, 2019 15:37
[Install 332] install 332 in linux server #linux #bash
#!/usr/bin/env bash
# copy from: https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocksR.sh
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
#=================================================================#
# System Required: CentOS 6,7, Debian, Ubuntu #
# Description: One click Install ShadowsocksR Server #
# Author: Teddysun <[email protected]> #
# Thanks: @breakwa11 <https://twitter.com/breakwa11> #
# Intro: https://shadowsocks.be/9.html #
@ezirmusitua
ezirmusitua / video-player.js
Last active January 17, 2019 15:19
[Local video server] Simplest node video player running in localhost #node #javascript #tools #video
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);
@ezirmusitua
ezirmusitua / image-serve.ts
Last active September 10, 2019 21:41
[Nestjs(fastify) serve image] Image serve using nestjs with fastify adapter #node #nestjs #fastify
import {
Controller,
Get,
Response
} from '@nestjs/common';
import {ImageService} from './image.service';
export class GalleryController {
constructor(private readonly imageService: ImageService) {
}
@ezirmusitua
ezirmusitua / parse-int-query.ts
Created December 31, 2018 02:45
[Parse integer query params] parse integer query parameters in nestjs #node #nestjs
import {
Controller,
Get,
ParseIntPipe,
Query,
} from '@nestjs/common';
export class GalleryController {
constructor() {
}
@ezirmusitua
ezirmusitua / escape-regex-characters.js
Last active September 10, 2019 21:41
[Escape regex special characters] escape regex special characters with /, using in search #regex #javascript #node
function escapeRegExp(text) {
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
}
@ezirmusitua
ezirmusitua / leancloud-realtime.sh
Last active January 17, 2019 15:18
[Leancloud realtime REST api] curl demo of using leancloud realtime REST API #leancloud #curl
# 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
@ezirmusitua
ezirmusitua / apply-and-use-letsencrypt-cert.sh
Last active January 9, 2019 06:34
[Use let's encrypt cert with certbot] renew let's encrypt cert using certbot via nginx webroot, #nginx #https #certbot #bash #deploy
# 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
@ezirmusitua
ezirmusitua / nginx_static_site.conf
Created January 9, 2019 06:37
[Nginx static site config] use nginx to serve static site(use letsencrypt cert & mantain with certbot) #deploy #nginx
## sitename.com
server {
listen 80;
listen [::]:80;
# expires $expires;
server_name <site_name>;
location ^~ /.well-known/acme-challenge/ {
@ezirmusitua
ezirmusitua / nginx_proxy_pass.conf
Created January 9, 2019 06:41
[Nginx proxy pass config] use nginx proxy pass (use letsencrypt cert & mantain with certbot) #deploy #nginx
## demo site
server {
listen 80;
listen [::]:80;
server_name <site_name>;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
@ezirmusitua
ezirmusitua / nginx_wmp_verification.config
Created January 9, 2019 06:45
[Weixin mini-program api server verification nginx config] weixin mini program api server verification, #nginx #deploy #weixin
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;