Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@fonlang
fonlang / RE_to_NFA_to_DFA.cpp
Last active February 5, 2020 12:13
Convert regex to NFA based on Thomposons Construction Algorithm and Convert NFA to DFA based on Subset Construction Algorithm
#include<iostream>
#include<sstream>
#include<vector>
#include<string>
#include<set>
#include<stack>
#define DEBUG 1
using namespace std;
@fonlang
fonlang / pygments-css-makefile
Created June 6, 2017 04:40
Makefile for generating pygments css files
# make sure you already ran pip install -r requirements.txt
#
# syntax
# pygmentize -S <style> -f <formatter> [-a <arg>] [-O <options>] [-P <option=value>]
# (pygmentize documentation is pretty scattered and confusing, but the "-a" will add other classes
# to the output)
cssfiles:
pygmentize -L styles | grep \* | sed 's/\* //g' | sed 's/://g' | \
awk '{print "pygmentize -S "$$0" -O full,linenos=1 -f html -a .sourceCode > "$$0".css"}' | \
@fonlang
fonlang / demo_inotify.c
Created June 3, 2017 09:27
linux inotify api example
#include <sys/inotify.h>
#include <limits.h>
#include "tlpi_hdr.h"
static void
displayInotifyEvent(struct inotify_event *i)
{
printf(" wd=%2d; ", i->wd);
if (i->cookie > 0)
printf("cookie=%4d; ", i->cookie);
@fonlang
fonlang / flume-ng-agent.sh
Created September 9, 2016 09:28
flume-ng-agent启动脚本(start/status/stop/restat..)
#!/bin/bash
. /lib/lsb/init-functions
FLUME_HOME=/mjs/opt/apache-flume-1.6.0-bin
cd ${FLUME_HOME}
# Name of the agnet
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.annotation.web.servlet.configuration.EnableWebMvcSecurity;
import org.springframework.security.core.GrantedAuthority;
#!/bin/bash
# on centos minimal
yum install gcc
yum install make
yum install ncurses-devel
yum install lua lua-devel
yum install ruby ruby-devel
yum install python python-devel
yum install perl perl-devel
@fonlang
fonlang / postsql.sql
Last active August 29, 2015 14:27 — forked from tobyhede/postsql.sql
PostgreSQL as JSON Document Store
-- PostgreSQL 9.2 beta (for the new JSON datatype)
-- You can actually use an earlier version and a TEXT type too
-- PL/V8 http://code.google.com/p/plv8js/wiki/PLV8
-- Inspired by
-- http://people.planetpostgresql.org/andrew/index.php?/archives/249-Using-PLV8-to-index-JSON.html
-- http://ssql-pgaustin.herokuapp.com/#1
-- JSON Types need to be mapped into corresponding PG types
--
@fonlang
fonlang / gist:b92fcb039406d97f802b
Last active August 29, 2015 14:27 — forked from lxneng/gist:741932
install PostgreSQL 9 in Mac OSX via Homebrew
install PostgreSQL 9 in Mac OSX via Homebrew
Mac OS X Snow Leopard
System Version: Mac OS X 10.6.5
Kernel Version: Darwin 10.5.0
Install notes for PostgreSQL 9.0.1 install using Homebrew:
sh-3.2# brew install postgresql