Skip to content

Instantly share code, notes, and snippets.

@JaosnHsieh
JaosnHsieh / nginx.conf
Created April 6, 2022 10:37 — forked from dctrwatson/nginx.conf
Caching NPM proxy using Nginx
user www-data;
worker_processes 4;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
@JaosnHsieh
JaosnHsieh / Youtube Subs to RSS.js
Created August 15, 2021 08:16 — forked from jeb5/Youtube Subs to OPML.js
Youtube Subscriptions to RSS feed
if (window.location.href == "https://www.youtube.com/feed/channels") {
let rssText = [...document.querySelectorAll("#main-link.channel-link")].map((e) => {
const [, a, b] = e.href.match("/((?:user)|(?:channel))/(.*)$");
return "https://www.youtube.com/feeds/videos.xml?" + (a === "user" ? "user=" : "channel_id=") + b;
}).join("\n")
if (rssText) {
navigator.clipboard.writeText(rssText).then(
() => alert("A list of channel RSS feeds has been copied to the clipboard. \nPaste these into rssmix.com to generate a single RSS feed, or opml-gen.ovh to generate an OPML file.")
).catch(
() => {
@JaosnHsieh
JaosnHsieh / GIF-Screencast-OSX.md
Created March 9, 2021 07:45 — forked from dergachev/GIF-Screencast-OSX.md
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@JaosnHsieh
JaosnHsieh / 1-easy.js
Created February 26, 2021 22:33 — forked from nybblr/1-easy.js
3 examples of using Async Generators and Async Iteration in JavaScript!
// Create a Promise that resolves after ms time
var timer = function(ms) {
return new Promise(resolve => {
setTimeout(resolve, ms);
});
};
// Repeatedly generate a number starting
// from 0 after a random amount of time
var source = async function*() {
# get total requests by status code
awk '{print $9}' /var/log/nginx/access.log | sort | uniq -c | sort -rn
# get top requesters by IP
awk '{print $1}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | head | awk -v OFS='\t' '{"host " $2 | getline ip; print $0, ip}'
# get top requesters by user agent
awk -F'"' '{print $6}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | head
# get top requests by URL
@JaosnHsieh
JaosnHsieh / MANUAL.md
Created August 3, 2020 09:02 — forked from kimyvgy/MANUAL.md
Deploy nodejs app with gitlab.com and pm2

Deploy nodejs app with gitlab.com and pm2

This manual is about setting up an automatic deploy workflow using nodejs, PM2, nginx and GitLab CI. It is tested on:

  • Target server: Ubuntu 16.04 x64. This is suitable for Ubuntu 14.x.
  • Windows 10 on my PC to work.
@JaosnHsieh
JaosnHsieh / .gitignore
Created April 28, 2020 10:04 — forked from iffy/.gitignore
Example using electron-updater with `generic` provider.
node_modules
dist/
yarn.lock
wwwroot
@JaosnHsieh
JaosnHsieh / .gitignore
Created April 28, 2020 10:04 — forked from iffy/.gitignore
Example using electron-updater with `generic` provider.
node_modules
dist/
yarn.lock
wwwroot
@JaosnHsieh
JaosnHsieh / graphql.ts
Created July 16, 2019 23:12 — forked from mfellner/graphql.ts
Using Apollo Server in Next.js 9 with API route in pages/api/graphql.ts
import { ApolloServer, gql } from 'apollo-server-micro';
const typeDefs = gql`
type Query {
sayHello: String
}
`;
const resolvers = {
Query: {
@JaosnHsieh
JaosnHsieh / web-servers.md
Created February 22, 2019 06:22 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000