This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python2.7 | |
import parsley | |
import ometa.runtime as runtime | |
SIPGrammar = """ | |
msg = firstline headers crlf body | |
firstline = ('\r' | '\n')* nospace:a ' ' nospace:b ' ' remaining:c | |
-> parser.doFirstLine(a, b, c) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class NoCSRFLoginView(View): | |
def get(self, request): | |
return HttpResponse("Please post your info.") | |
@never_cache | |
def post(self, request, authentication_form=AuthenticationForm): | |
form = authentication_form(data=request.POST) | |
if form.is_valid(): | |
# Okay, security check complete. Log the user in. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
useradd -d /dir_for_backup -m databackup | |
su - databackup | |
ssh-keygen -t rsa | |
content: | |
host A_Backup | |
hostname Server_A_Address | |
user root |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Last login: Thu Jun 20 18:27:30 on ttys000 | |
➜ ~ kz | |
zsh: command not found: kz | |
➜ ~ ls | |
Applications Desktop GradProj Movies Pictures README.md Transient | |
Audiu Documents ImpBack Music Projects Temp Twisted | |
Books Downloads Library Persistent Public Tools | |
➜ ~ | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this one works, I can repeat the expr in query {times} | |
byte = anything:b -> ord(b) | |
query = byte:times expr{times} | |
# however, if the byte CANNOT return ord(b), how can I refer to the value of 'ord(anything:b)' when I am in query? | |
# one workaround is to store it in a temporary place. | |
# for example | |
byte = anything:b -> temp.update(b) | |
query = byte expr{temp.b} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Message: | |
pass | |
class Query: | |
pass | |
class Name: | |
pass | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from parsley import makeGrammar | |
data = b'\x01\x013' | |
grammarSource = r""" | |
byte = anything:b1 anything:b2 -> ord(b1), ord(b2) | |
start = byte:b anything{b[0]} | |
""" | |
parser = makeGrammar(grammarSource, {}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
byte, short and other C types are serialized in network/big endian | |
""" | |
grammarSource = r""" | |
byte = anything:b -> ord(b) | |
short = byte:high byte:low -> high << 8 | low | |
int = short:high short:low -> high << 16 | low |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://gist.github.com/anonymous/5864002#comment-851824 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
comment = '#' (~'\n' anything)* | |
hspace = ' ' | '\t' | comment | |
vspace = '\r\n' | '\r' | '\n' | |
ws = (hspace | vspace | comment)* | |
emptyline = hspace* vspace | |
indentation = emptyline* hspace+ | |
noindentation = emptyline* ~~~hspace | |
number = ws |
OlderNewer