Skip to content

Instantly share code, notes, and snippets.

View bdqnghi's full-sized avatar
🧧
Focusing

Nghi D. Q. Bui bdqnghi

🧧
Focusing
View GitHub Profile
#!/usr/bin/python
import socket,sys,time,datetime,argparse,os
flag = 0 # we're gonna use this flag later. Just keep it in mind
os.system('clear') # Clear the console window
line = "+" * 80 # Just a fancy line consisting '+'
desc = line+'''\nA Simple port scanner that works!! (c) digitz.org
Example usage: python port_scanner.py example.com 1 1000
The above example will scan the host \'example.com\' from port 1 to 1000
To scan most common ports, use: python port_scanner.py example.com\n'''+line+"\n"
@bdqnghi
bdqnghi / CFG.java
Created January 17, 2017 09:20
Soot example
package com.software.mining;
import polyglot.visit.DataFlow;
import soot.*;
import soot.jimple.toolkits.callgraph.CallGraph;
import soot.jimple.toolkits.callgraph.Edge;
import soot.jimple.toolkits.callgraph.Targets;
import soot.options.Options;
import soot.toolkits.graph.ExceptionalUnitGraph;
import soot.toolkits.graph.pdg.HashMutablePDG;
@bdqnghi
bdqnghi / App.java
Last active January 18, 2017 19:02
Kth smallest number of multiple sorted arrays
package com.smu.software;
import java.util.Arrays;
/**
* Hello world!
*/
public class App {
public static void main(String[] args) {
@bdqnghi
bdqnghi / llvm create cfg.sh
Created April 17, 2017 17:20
create CFG with llvm
#!/bin/bash
# create .bc file
clang -emit-llvm -c testcfg.c
# create .dot file
opt -dot-cfg testcfg.bc
# cteate png,pdf
dot -Tpng -o main.png cfg.main.dot
@bdqnghi
bdqnghi / README.markdown
Created April 17, 2017 18:07 — forked from alloy/README.markdown
Learn the LLVM C++ API by example.

The easiest way to start using the LLVM C++ API by example is to have LLVM generate the API usage for a given code sample. In this example it will emit the code required to rebuild the test.c sample by using LLVM:

$ clang -c -emit-llvm test.c -o test.ll
$ llc -march=cpp test.ll -o test.cpp
@bdqnghi
bdqnghi / gist:325e4ff7431cc9434d67d580312adcbc
Created April 27, 2017 15:13 — forked from debasishg/gist:8172796
A collection of links for streaming algorithms and data structures
  1. General Background and Overview
@bdqnghi
bdqnghi / autoencoder.py
Created May 29, 2017 19:42 — forked from saliksyed/autoencoder.py
Tensorflow Auto-Encoder Implementation
""" Deep Auto-Encoder implementation
An auto-encoder works as follows:
Data of dimension k is reduced to a lower dimension j using a matrix multiplication:
softmax(W*x + b) = x'
where W is matrix from R^k --> R^j
A reconstruction matrix W' maps back from R^j --> R^k
@bdqnghi
bdqnghi / simple_mlp_tensorflow.py
Created July 2, 2017 19:56 — forked from vinhkhuc/simple_mlp_tensorflow.py
Simple Feedforward Neural Network using TensorFlow
# Implementation of a simple MLP network with one hidden layer. Tested on the iris data set.
# Requires: numpy, sklearn>=0.18.1, tensorflow>=1.0
# NOTE: In order to make the code simple, we rewrite x * W_1 + b_1 = x' * W_1'
# where x' = [x | 1] and W_1' is the matrix W_1 appended with a new row with elements b_1's.
# Similarly, for h * W_2 + b_2
import tensorflow as tf
import numpy as np
from sklearn import datasets
from sklearn.model_selection import train_test_split
@bdqnghi
bdqnghi / subexpr.py
Created September 19, 2017 18:09 — forked from anj1/subexpr.py
import types
import tensorflow as tf
import numpy as np
# Expressions are represented as lists of lists,
# in lisp style -- the symbol name is the head (first element)
# of the list, and the arguments follow.
# add an expression to an expression list, recursively if necessary.
def add_expr_to_list(exprlist, expr):
@bdqnghi
bdqnghi / gist:54b5ffeb22447336bde51f61d9fcedf7
Created September 27, 2017 17:56 — forked from brendano/gist:963c826e7109a5e50d54
papers that do NLP-like stuff with source code
NLP and source code papers, very scattered and partial listing
(collected by Nathan Schneider and Brendan O'Connor)
ICML 2014
Maddison and Tarlow
Structured Generative Models of Natural Source Code
http://jmlr.org/proceedings/papers/v32/maddison14.pdf
ACL 2013