Skip to content

Instantly share code, notes, and snippets.

View outiy5's full-sized avatar

Antony Wood outiy5

View GitHub Profile
# 0. ON WINDOWS :
# On windows, to check which WSL you use, type ` wsl --list --verbose ` in admin cmd.
# If you are not in WSL2, reinstall the machine with WSL2 : https://docs.microsoft.com/fr-fr/windows/wsl/install-win10
# 1. Make sure you are running with systemd
# sudo systemctl must not say "Failed to connect to bus"
# If so, I recommand you to reinstall the VM. You can try this repo too : https://github.com/DamionGans/ubuntu-wsl2-systemd-script.git
# 2. On WSL2 machine
# /!\ Create an user with A PASSWORD and with sudo access
@outiy5
outiy5 / x11_forwarding_macos_docker.md
Created May 23, 2022 07:27 — forked from sorny/x11_forwarding_macos_docker.md
X11 forwarding with macOS and Docker

X11 forwarding on macOS and docker

A quick guide on how to setup X11 forwarding on macOS when using docker containers requiring a DISPLAY.

This guide was tested on:

  • macOS Catalina 10.15.4
  • docker desktop 2.2.0.5 (43884) - stable release
  • XQuartz 2.7.11 (xorg-server 1.18.4)

Step-By-Step Guide

"""
run python web.rewrite.example.py
and then open a browser to localhost:8080/data/foo/bar
The two segments of the path below /data are transformed into query
arguments using the rewrite function pathToArgs.
The root resource is wrapped with the rewrite resource
The second arg to RewriterResource is the rewrite function.
@outiy5
outiy5 / reverseproxy.md
Last active May 17, 2022 09:45
twisted reverse proxy: one file reverse proxy. No nginx and stunnel.

HTTPS to HTTP

reverse_proxy.py:

import sys
from twisted.internet import ssl, protocol, task, defer
from twisted.python import log
from twisted.internet import reactor
from twisted.web import proxy, server
@outiy5
outiy5 / web-servers.md
Created July 23, 2020 10:47 — 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
@outiy5
outiy5 / create.js
Last active May 3, 2020 16:05
[js create element] #html #javascript
var childNode = document.createElement('p');
childNode.innerHTML = '这里是提示信息〜〜';
//childNode.setAttribute('class', 'alerts');
//childNode.setAttribute('onclick', 'this.style.display = "none"');
childNode.className = 'alerts';
childNode.onclick = function () {
this.style.display = 'none';
}
document.getElementsByTagName('body')[0].appendChild(childNode);
@outiy5
outiy5 / page_initial.vue
Last active March 28, 2020 07:21
[vue script template] 一个vue script中可以做哪些事情? #vue #quasar
export default {
name: 'PageForum',
data() {
return {
}
},
mounted() {
// write initial code here when DOM is loaded
},
@outiy5
outiy5 / exp1.html
Created March 19, 2020 09:24
[vue example 1] #vue
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<title>Vue App</title>
</head>
@outiy5
outiy5 / ps_2js.py
Created March 19, 2020 09:22
[convert python string to javascript string] #python
# https://stackoverflow.com/questions/10395319/python-convert-str-to-javascript-literal-string
import json
jsstring = """
foo "bar"
"""
print 'function dosomething () { return %s.toLowerCase(); }' % json.dumps(jsstring)
@outiy5
outiy5 / image.js
Created March 19, 2020 09:20
[use script to generate image synchronically] 如何在文档流加载的时候自动生成图片? #javascript
// https://stackoverflow.com/questions/22503908/html-is-img-src-scriptsome-javascript-script-allowed
// https://stackoverflow.com/questions/34467135/insert-javascript-code-inside-img-src/34467158
document.write('<img src=' + someVariable + ' alt="">');