Skip to content

Instantly share code, notes, and snippets.

View OMGZui's full-sized avatar
:octocat:
Focusing

omgzui OMGZui

:octocat:
Focusing
  • DXY
  • HangZhou, China
View GitHub Profile
@OMGZui
OMGZui / 4.js
Created October 26, 2022 11:25
class SandboxGlobalProxy {
constructor(sharedState) {
const iframe = document.createElement("iframe", { url: "about:blank" });
iframe.style.display = "none";
document.body.appendChild(iframe);
const sandboxGlobal = iframe.contentWindow;
return new Proxy(sandboxGlobal, {
has: (target, prop) => {
@OMGZui
OMGZui / 3.js
Created October 26, 2022 11:23
var foo = "foo1";
const ctx = {
func: variable => {
console.log(variable);
}
};
function withedYourCode(code) {
code = "with(shadow) {" + code + "}";
@OMGZui
OMGZui / 2.js
Created October 26, 2022 11:22
var foo = "foo1";
const ctx = {
func: variable => {
console.log(variable);
},
foo: "f1"
};
function veryPoorSandbox(code, ctx) {
@OMGZui
OMGZui / 1.js
Created October 26, 2022 11:11
window.document = null;
console.log(window.document);
delete window.document
console.log(window.document);
ReflectDemo reflectDemo = new ReflectDemo();
(1)Class<ReflectDemo> reflectDemoClass = ReflectDemo.class;
(2)Class<?> aClass = Class.forName ("com.omgzui.springtransaction.transactiondemo.reflectdemo.ReflectDemo");
(3)Class<? extends Class> aClass = reflectDemoClass.getClass ();
@OMGZui
OMGZui / 2.java
Last active October 22, 2022 10:41
public class ReflectDemo {
public static void main (String[] args) throws IllegalAccessException, InstantiationException {
proxyObject();
newObject();
}
public static void newObject(){
long startTime = System.currentTimeMillis ();
int i;
for (i = 0; i < 100000000; i++) {
ReflectDemo reflectDemo = new ReflectDemo();
(1)Class<ReflectDemo> reflectDemoClass = ReflectDemo.class;
(2)Class<?> aClass = Class.forName ("com.omgzui.springtransaction.transactiondemo.reflectdemo.ReflectDemo");
(3)Class<? extends Class> aClass = reflectDemoClass.getClass ();
@OMGZui
OMGZui / 6.js
Last active October 21, 2022 13:01
const idol = {
name: 'Tom',
phone: 10086,
price: 1000000
}
const agent = new Proxy(idol, {
get: function(target) {
return 'phone:10010';
},
@OMGZui
OMGZui / 5.js
Created October 21, 2022 12:59
class Adapter {
test() {
return 'old';
}
}
class Target {
constructor() {
this.adapter = new Adapter();
}
@OMGZui
OMGZui / 4.js
Created October 21, 2022 12:58
function info(target) {
target.prototype.name = 'Tom';
target.prototype.age = 10;
}
@info
class Man {}
let man = new Man();
man.name;