Skip to content

Instantly share code, notes, and snippets.

View image72's full-sized avatar

image72 image72

View GitHub Profile
@aerobounce
aerobounce / macOS System Preference Pane Links.md
Last active August 23, 2024 20:54
macOS System Preference Pane Links
@shisama
shisama / proxy_server.js
Last active July 29, 2024 18:25
Node.js Proxy Server with Basic Auth Sample
const http = require("http");
const { parse } = require("basic-auth");
const { PROXY_USERNAME, PROXY_PASSWORD } = process.env;
const PROXY_PORT = process.env.PROXY_PORT || 8000;
const check = (credentials) => {
return (
credentials &&
credentials.username === PROXY_USERNAME &&
credentials.pass === PROXY_PASSWORD
@ephys
ephys / useLocalStorage.ts
Last active February 15, 2022 02:21
React-hook like useState but synchronized with localStorage & sessionStorage (and the others)
/**
* Source: https://gist.github.com/Ephys/79974c286e92665dcaae9c8f5344afaf
*/
import { useState, useEffect, useCallback, useRef } from 'react';
const eventTargets = new WeakMap();
function getEventTarget(storage: Storage) {
if (eventTargets.has(storage)) {
@nvbn
nvbn / App.js
Last active August 29, 2023 13:39
Hooks with classes
import React from "react";
import Counter from "./Counter";
const App = () => {
return (
<div className="App">
<Counter initialCount={100} />
</div>
);
};
@y0ngb1n
y0ngb1n / docker-registry-mirrors.md
Last active April 19, 2025 05:12
国内的 Docker Hub 镜像加速器,由国内教育机构与各大云服务商提供的镜像加速服务 | Dockerized 实践 https://github.com/y0ngb1n/dockerized
#!/usr/bin/env node
const PPT = require('puppeteer');
const PDD = require('puppeteer/DeviceDescriptors');
const PuppeteerHar = require('puppeteer-har');
(async () => {
const ua = await PPT.launch({
headless: true,
args: ['--no-sandbox', '--disable-gpu'],
@v1shwa
v1shwa / dynamic_subdomains
Created March 21, 2019 13:54
Dynamically map subdomains to different ports on the server - using Nginx
server {
listen 80;
# maps p8080.example.com -> localhost:8080
server_name ~^p(?<port>[^.]+)\.example\.com$;
location / {
proxy_pass http://localhost:$port;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
@lhorie
lhorie / longest-keyword-sequence.md
Last active November 13, 2024 04:15
What's the longest keyword sequence in Javascript?
@miguelmota
miguelmota / stdin_async.js
Created January 27, 2019 00:28
Node.js read stdin synchronous
async function readStdinSync() {
return new Promise(resolve => {
let data = ''
process.stdin.setEncoding('utf8')
process.stdin.resume()
const t = setTimeout(() => {
process.stdin.pause()
resolve(data)
}, 1e3)
process.stdin.on('readable', () => {
<!DOCTYPE html>
<html>
<head>
<title>OCR Sample</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
function processImage() {