Skip to content

Instantly share code, notes, and snippets.

View yeukhon's full-sized avatar

Yeuk Hon Wong yeukhon

  • TikTok USDS / ByteDance
  • New York, NY
  • 19:36 (UTC -04:00)
View GitHub Profile
#
# Wide-open CORS config for nginx
#
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
#
@yeukhon
yeukhon / foo.js
Created August 23, 2014 18:31
browserify question
var Foo = function () {
alert("Hello! You've just called Foo()");
}
module.exports = Foo
@yeukhon
yeukhon / IDEAS.md
Last active August 29, 2015 14:05
Hacker School pair programming interview with Yeuk Hon Wong

Environment: I think we will try the coding on Linux. I use Mac but I can just work from a vagrant machine or from an EC2 instance.

robots-txt-scanner takes in a robots.txt file and outputs a list of (token, lexeme) tuple.

print scanner.scan("User-agent: Google\nDisallow: *")
(('\\USER_AGENT_VALUE/', 'User-agent: Google'), ('\\DISALLOW_VALUE/', 'Disallow: *'))

Features:

@yeukhon
yeukhon / pub.js
Last active August 29, 2015 14:04
Simple example of pub/sub using node.js and redis client
// Usage:
// node pub.js
// then starts typing message (ENTER per message)
// A publisher could be invokved by a background job
// processor or a user triggered action received by
// web app.
var redis = require("redis");
var pub = redis.createClient();
process.stdin.resume();
@yeukhon
yeukhon / myjob.js
Created July 24, 2014 04:08
Parent and child job using kue + node.js + Q.js based on node-job-queue example (https://github.com/prateekbhatt/node-job-queue/blob/master/nested-job-queue.js)
var kue = require('kue'),
jobs = kue.createQueue();
var Q = require('q');
var db = {};
function parentJob(id, done) {
var job = jobs.create('parent', {
type: 'PARENT',
id: id
@yeukhon
yeukhon / bad.html
Last active August 29, 2015 14:04
Basic alert detection using selenium-webdriver.
<html>
<body>
<script>alert("xssssss");</script>
</body>
</html>
@yeukhon
yeukhon / demo.js
Last active August 29, 2015 14:04
Dummy example to show why we write asychronous code LOL (http://jsfiddle.net/T9feW/)
// See your dev console. Don't forget the reason you use promise
// is to write asynchronous code in synchronous way.
// We duplicate two instances of step1-3 whichever comes back first
// gets the counter = 1 and the latter one gets counter = 2.
// The message "end of program let's quit" will print before
// any result comes back.
// Require Q.js (just go to jsfiddle)
var counter = 0;
function step1() {
@yeukhon
yeukhon / 1.html
Last active August 29, 2015 14:03
I tried setting onAlert and nothing.
<html>
<body>
<script>
alert('xss');
</script>
</body>
</html>
@yeukhon
yeukhon / test.html
Last active December 14, 2021 14:08
Simple XSS detector using PhantomJS
<html>
<head></head>
<body>
<a href="javascript: alert('clicked xss link')" id="link">click me</a>
<img src="xx" onerror="alert('xss')" />
</body>
</html>
@yeukhon
yeukhon / .hgrc
Created July 2, 2014 18:01
.hgrc
[ui]
username = Yeuk Hon Wong <yeukhon@acm.org>
[alias]
diff-color = !hg diff --git --color=always | less -r
diff-color-tip = !hg diff -c tip --git --color=always | less -r
diff-color-qtip = !hg diff -c qtip --git --color=always | less -r
pushtry = push -f -rtip try
qlist = qseries -v
latest = log --limit 5