Skip to content

Instantly share code, notes, and snippets.

View ian2009's full-sized avatar

Ian Feng ian2009

View GitHub Profile
@ian2009
ian2009 / TcpProxy.cs
Created September 24, 2019 15:27 — forked from Mordo95/TcpProxy.cs
Asynchronous TCP proxy in C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
namespace HolePunchTest
{
public class TcpProxy
@ian2009
ian2009 / boolparser.py
Created August 19, 2019 19:15 — forked from leehsueh/boolparser.py
Python Boolean Expression Parser/Evaluator
"""
Grammar:
========
Expression --> AndTerm { OR AndTerm}+
AndTerm --> Condition { AND Condition}+
Condition --> Terminal (>,<,>=,<=,==) Terminal | (Expression)
Terminal --> Number or String or Variable
Usage:
======
from bokeh.core.properties import value
from bokeh.events import Reset
from bokeh.events import SelectionGeometry
from bokeh.layouts import column
from bokeh.models import ColumnDataSource
from bokeh.models import HoverTool
from bokeh.models import NumeralTickFormatter
from bokeh.models.widgets import CheckboxButtonGroup
from bokeh.models.widgets import Div
from bokeh.plotting import figure
def filter_categories(indexes):
categories_filtered = [CATEGORIES[ind] for ind in indexes] if indexes != [] else CATEGORIES
update_num_categories_source(categories_filtered, force_categories=True)
update_usd_vs_date_source(categories_filtered, force_categories=True)
def update_usd_vs_date_source(categories=None, force_categories=False):
# To get the current state of the categories
if categories is None:
categories = source_num_categories.data['categories']
@ian2009
ian2009 / build.sh
Created April 6, 2018 20:50 — forked from Artanis/build.sh
Python C Extension Hello World
gcc -fpic --shared $(python-config --includes) greetmodule.c -o greetmodule.so
#!/usr/bin/env python
'''Crop an image to just the portions containing text.
Usage:
./crop_morphology.py path/to/image.jpg
This will place the cropped image in path/to/image.crop.png.
For details on the methodology, see
@ian2009
ian2009 / README.md
Last active August 29, 2015 14:10 — forked from evandrix/README.md

Here are a list of headless browsers that I know about:

  • [HtmlUnit][1] - Java. Custom browser engine. JavaScript support/DOM emulated. Open source.
  • [Ghost][2] - Python only. WebKit-based. Full JavaScript support. Open source.
  • [Twill][3] - Python/command line. Custom browser engine. No JavaScript. Open source.
  • [PhantomJS][4] - Command line/all platforms. WebKit-based. Full JavaScript support. Open source.
  • [Awesomium][5] - C++/.Net/all platforms. Chromium-based. Full JavaScript support. Commercial/free.
  • [SimpleBrowser][6] - .Net 4/C#. Custom browser engine. No JavaScript support. Open source.
  • [ZombieJS][7] - Node.js. Custom browser engine. JavaScript support/emulated DOM. Open source.
  • [EnvJS][8] - JavaScript via Java/Rhino. Custom browser engine. JavaScript support/emulated DOM. Open source.