Skip to content

Instantly share code, notes, and snippets.

@lawvs
lawvs / outline.js
Created August 17, 2023 07:32
Outline bookmarklet
javascript: (() => {
/* https://github.com/storybookjs/storybook/blob/next/code/addons/outline/src/withOutline.ts */
function outlineCSS(selector) {
return /* css */ `
${selector} body {
outline: 1px solid #2980b9 !important;
}
${selector} article {
outline: 1px solid #3498db !important;
@lawvs
lawvs / file-recovery.js
Created April 1, 2022 16:01
Recovery file from .CHK
const fs = require("fs");
const { exec } = require("child_process");
const files = fs.readdirSync(__dirname);
files
.filter((i) => i.endsWith(".CHK"))
.forEach((i) => {
exec("file " + i, (err, stdout, stderr) => {
if (stdout.includes("JPEG")) {
@lawvs
lawvs / proxy.js
Created March 15, 2022 13:46
proxy log
const target = {};
globalThis.original = target;
// See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy
const proxyObj = new Proxy(target, {
get(target, prop, receiver) {
console.log("GET", target, prop, receiver);
return Reflect.get(target, prop, receiver);
},
set(target, prop, val, receiver) {
@lawvs
lawvs / antivirus.cmd
Created February 3, 2022 17:04
Get Rid Of Flash Drive Virus
del *.lnk
attrib -s -h /s /d
from pygments import highlight as syntax_highlight
from pygments.formatters import img
from pygments.lexers import guess_lexer
lexer = guess_lexer(message)
formatter = img.JpgImageFormatter(style="colorful")
result = syntax_highlight(message, lexer, formatter, outfile=None)
@lawvs
lawvs / launch.json
Last active October 18, 2020 12:35
vscode c++ config
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "C++",
"type": "cppdbg",
"request": "launch",
@lawvs
lawvs / styles.css
Created September 6, 2020 04:35
glitch animation
# https://psycho-pass.com/
# <p data-text="THEATER">THEATER</p>
# p:before {
# content: attr(data-text);
# color: #24b8c6;
# opacity: .75;
# mix-blend-mode: screen;
# position: absolute;
# top: 7px;
@lawvs
lawvs / supervisor.app.conf
Last active December 19, 2019 17:23
supervisor conf
# http://supervisord.org/
# /etc/supervisor/conf.d/app.conf
[program:app]
command=/opt/app/venv/bin/gunicorn -k gevent -w 8 -b 0.0.0.0:8080 run:app
directory=/opt/app
autostart=true
autorestart=true
user=nobody
redirect_stderr=true
@lawvs
lawvs / .vimrc
Last active May 29, 2019 17:14
vim config
" vim /etc/vimrc
" vim ~/.vimrc
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set showmode
set showcmd
@lawvs
lawvs / install.sh
Last active August 28, 2018 04:20
centos
#!/bin/bash
# set flag fast fail
set -e
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi