Skip to content

Instantly share code, notes, and snippets.

@manhtai
manhtai / jekyll_it.R
Last active August 29, 2015 14:07
R Markdown to Markdown on Jekyll
# Copied from <http://jason.bryer.org/posts/2012-12-10/Markdown_Jekyll_R_for_Blogging.html>
jekyll_it <- function(dir=getwd(), images.dir=dir, images.url='../', out_ext='.md', in_ext='.rmd', recursive=FALSE) {
require(knitr, quietly=TRUE, warn.conflicts=FALSE)
files <- list.files(path=dir, pattern=in_ext, ignore.case=TRUE, recursive=recursive)
for(f in files) {
message(paste("Processing ", f, sep=''))
content <- readLines(f)
frontMatter <- which(substr(content, 1, 3) == '---')
if(length(frontMatter) >= 2 & 1 %in% frontMatter) {

To use Windows 8 boot manager

Unlock partition

diskpart
list disk
select disk 0
list partition
select partition 0
@manhtai
manhtai / pagerank.py
Last active August 29, 2015 14:15 — forked from diogojc/pagerank.py
import numpy as np
from scipy.sparse import csc_matrix
def pageRank(G, s = .85, maxerr = .001):
"""
Computes the pagerank for each of the n states.
Used in webpage ranking and text summarization using unweighted
or weighted transitions respectively.
@manhtai
manhtai / cloudSettings
Last active June 25, 2017 14:56 — forked from spencercarli/bd3d4befe38185704bf0fc875e9deed6|configuration.json
Visual Studio Code Settings Sync Gist
{"lastUpload":"2017-06-25T14:56:20.512Z","extensionVersion":"v2.8.1"}
@manhtai
manhtai / amazon.sh
Created October 3, 2017 04:27 — forked from fredriks/amazon.sh
postgresql with postgis on amazon linux, debian jessie and ubuntu trusty
# http://stackoverflow.com/questions/27177327/setting-up-django-with-geodjango-support-in-aws-beanstalk-or-ec2-instance
# http://rpmfind.net/linux/rpm2html/search.php?query=lib64jpeg8
# http://rpmfind.net/linux/rpm2html/search.php?query=lib64poppler5
# install postgresql repo
sudo yum install https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-6-x86_64/pgdg-ami201503-95-9.5-3.noarch.rpm
# add priority=1 to perfer this repo over amzn-main
vim /etc/yum.repos.d/pgdg-95-ami201503.repo
@manhtai
manhtai / install.sh
Created October 3, 2017 09:52 — forked from ihor/install-rabbitmq-on-amazon-linux.sh
Install RabbitMQ on Amazon Linux
# Modify /etc/yum.repos.d/epel.repo. Under the section marked [epel], change enabled=0 to enabled=1.
sudo yum install erlang --enablerepo=epel
wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.1.1/rabbitmq-server-3.1.1-1.noarch.rpm
sudo rpm -Uvh rabbitmq-server-3.1.1-1.noarch.rpm
# Enable managament plugin
sudo rabbitmq-plugins enable rabbitmq_management

Keybase proof

I hereby claim:

  • I am manhtai on github.
  • I am manhtai (https://keybase.io/manhtai) on keybase.
  • I have a public key ASAGaIx-aeYCP7eija_x4KxghP4CvhKrvvIMACWFJ2npQwo

To claim this, I am signing this object:

@manhtai
manhtai / infosec_newbie.md
Created May 13, 2018 03:33 — forked from mubix/infosec_newbie.md
How to start in Infosec
@manhtai
manhtai / lambda_function.py
Created May 21, 2018 13:45
Lambda function for draining ECS instances before terminating it
from __future__ import print_function
import boto3
import base64
import json
import logging
logging.basicConfig()
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)