Skip to content

Instantly share code, notes, and snippets.

View brianray's full-sized avatar
🐍

Brian Ray brianray

🐍
  • Maven Wave Partners
  • Los Angeles | Chicago
View GitHub Profile
@brianray
brianray / example.py
Last active July 5, 2016 17:02
Example of using Pipelines
from __future__ import print_function
import logging as log
log.basicConfig(level=log.DEBUG)
######## The Base stuff
######## This is code we don't want to change
######## for example only
@brianray
brianray / resize.sh
Created August 24, 2016 17:11
resize docker vbox
$ docker-machine stop
$ VBoxManage list -l vms | grep CPU
CPU exec cap: 100%
Number of CPUs: 1
CPUID Portability Level: 0
CPUID overrides: None
CPU exec cap: 100%
Number of CPUs: 1
CPUID Portability Level: 0
CPUID overrides: None
cd /tmp
wget http://launchpadlibrarian.net/137699828/libc6_2.17-0ubuntu5_amd64.deb
wget http://launchpadlibrarian.net/137699829/libc6-dev_2.17-0ubuntu5_amd64.deb
mkdir libc6_2.17
cd libc6_2.17
ar p ../libc6_2.17-0ubuntu5_amd64.deb data.tar.gz | tar zx
ar p ../libc6-dev_2.17-0ubuntu5_amd64.deb data.tar.gz | tar zx
cd -
LD_LIBRARY_PATH=/tmp/libc6_2.17/lib/x86_64-linux-gnu/ /tmp/libc6_2.17/lib/x86_64-linux-gnu/ld-2.17.so bin/python local/lib/python2.7/site-packages/tensorflow/models/image/mnist/convolutional.py
data = open("C:\Users\tdoucet\Desktop\Test.csv")
dict = {}
for line in data:
x = line.split(",")
a = x[0]
b = x[1]
dict[a] = b
level0 = []
level1 = []
from stat_parser import Parser
parser = Parser()
parser.parse(sent)
tree = parser.parse(sent) # returns nltk Tree instance
tree
@brianray
brianray / parser.py
Last active November 2, 2025 18:26
example language parser
# Brian Ray <brianhray@gmail.com>
# @brianray
# https://medium.com/@brianray_7981/
# parser for POSH Syntax http://brianray.github.io/posh-syntax/
import re
def transition_skip(fsm_obj):
pass
class Rule:
def __init__(self):
self.prefix = ""
self.subject = ""
self.op = None
def __repr__(self):
op = self.op
if not op:
op = ''
FSM_MAP = (
# {'src':, 'dst':, 'condition':, 'callback': },
{'src': S_NEW_GROUP,
'dst': S_PRE,
'condition': "[A-Za-z|+|-|\d]",
'callback': T_APPEND_CHAR_PRE}, # 1
{'src': S_PRE,
'dst': S_PRE,
'condition': "[A-Za-z|+|-|\d]",
'callback': T_APPEND_CHAR_PRE}, # 2
class RuleGroup:
def __init__(self, parent, level, op):
self.op = op
self.parent = parent
self.level = level
self.rule_count = 1
self.rules = [Rule(), ]
def __repr__(self):
return "<RuleGroup: {}>".format(self.__dict__)
class Rule_Parse_FSM:
def __init__(self, input_str):
self.input_str = input_str
self.current_state = S_NEW_GROUP
self.group_current_level = 0
self.current_group = RuleGroup(None, self.group_current_level, None)
self.current_char = ''