Posted: 20 Feb 2013, 21:15
I've been at PHP Conference over the weekend. (Work paid for me to go.)
Christ what a sausage-fest. ~700 attendees of whom maybe 12 were women.
Twelve brought their mother?markfiend wrote:I've been at PHP Conference over the weekend. (Work paid for me to go.)
Christ what a sausage-fest. ~700 attendees of whom maybe 12 were women.
nowayjose wrote:Twelve brought their mother?markfiend wrote:I've been at PHP Conference over the weekend. (Work paid for me to go.)
Christ what a sausage-fest. ~700 attendees of whom maybe 12 were women.
lazarus corporation wrote:SQL Injection in practice
impressiveQuiff Boy wrote:moshpits.js
A JavaScript implementation of the simulations presented in the paper Collective Motion of Moshers at Heavy Metal Concerts. More details are available at Itai Cohen's group website including videos of mosh pits, full simulations, and a brief description.
http://mattbierbaum.github.com/moshpits.js/
Oh my!Quiff Boy wrote:moshpits.js
A JavaScript implementation of the simulations presented in the paper Collective Motion of Moshers at Heavy Metal Concerts. More details are available at Itai Cohen's group website including videos of mosh pits, full simulations, and a brief description.
http://mattbierbaum.github.com/moshpits.js/
Oh goody. I'm on 2.2.25-1 at the moment. Having said that...lazarus corporation wrote:Upgrading from Apache 2.2 to Apache 2.4 is a bloody pain that involves editing too many vhost files
Arch linux wiki wrote: Note: Even though Apache 2.4 was released over a year ago (Feb 2012), it still isn't available in the official repositories. You can however get it from the AUR as apache24.
Pista wrote:My customised Moto X
I had the Unknown Pleasures cover laser marked on the back at work
Code: Select all
#!/usr/bin/python2
"""
A Brainf_ck interpreter in Python
Copyright (c) 2014 by Mark Wolstenholme
released under GPL v3 or later
I'll assume you know what Brainf_ck is:
> Increment the pointer.
< Decrement the pointer.
+ Increment the byte at the pointer.
- Decrement the byte at the pointer.
. Output the byte at the pointer.
, Input a byte and store it in the byte at the pointer.
[ Jump forward past the matching ] if the byte at the pointer is zero.
] Jump backward to the matching [ unless the byte at the pointer is zero.
"""
from sys import argv
class Brainf_ck:
'Brainf_ck class.'
def __init__(self):
'Set up the internals'
# give it 64k to play with
self.storage = bytearray(65536)
# We also need somewhere to store the locations of the [ and ]
self.loopstarts, self.loopends = {}, {}
# build an output string internally
self.output = ''
# We need an input string
self.inpt = ''
# And we need a storage pointer and a program counter
self.pointer, self.counter = 0, 0
# Instructions dictionary mapped to functions of this class
self.instructions = {
'>': self._inc,
'<': self._dec,
'+': self._p_inc,
'-': self._p_dec,
'.': self._to_out,
',': self._from_in,
'[': self._forward,
']': self._back
}
def _inc(self):
'Increment the pointer. >'
self.pointer = (self.pointer + 1) % len(self.storage)
def _dec(self):
'Decrement the pointer. <'
self.pointer = (self.pointer - 1) % len(self.storage)
def _p_inc(self):
'Increment the byte at the pointer. +'
self.storage[self.pointer] = (self.storage[self.pointer] + 1) % 256
def _p_dec(self):
'Decrement the byte at the pointer. -'
self.storage[self.pointer] = (self.storage[self.pointer] - 1) % 256
def _to_out(self):
'Output the byte at the pointer. .'
self.output += chr(self.storage[self.pointer])
def _from_in(self):
'Input a byte and store it in the byte at the pointer. ,'
if self.inpt == '':
self.storage[self.pointer] = 255 # -1 as EOF
else:
self.storage[self.pointer] = ord(self.inpt[0])
self.inpt = self.inpt[1:]
def _forward(self):
'Jump forward past the matching ] if the byte at the pointer is zero. ['
if self.storage[self.pointer] == 0:
self.counter = self.loopends[self.counter]
def _back(self):
'Jump backward to the matching [ unless the byte at the pointer is zero. ]'
if self.storage[self.pointer] != 0:
self.counter = self.loopstarts[self.counter]
def document(self):
'Output some documentation.'
self.output = 'A Brainf_ck interpreter in Python\n'
self.output += '\n'
self.output += 'Usage:\n'
self.output += 'brainf_ck.py <BRAINF_CKCODE> [<INPUTSTRING>]'
def interpret(self, bfcode, inpt):
'Run the bfcode using inputstring inpt.'
self._find_loops(bfcode)
self.inpt = inpt
while self.counter < len(bfcode):
if bfcode[self.counter] in self.instructions:
self.instructions[bfcode[self.counter]]()
self.counter += 1
def _find_loops(self, bfcode):
'Store the locations of [ and ] for looping'
stack = []
for a in range(len(bfcode)):
if bfcode[a] == '[':
stack.append(a)
if bfcode[a] == ']':
self.loopstarts[a] = stack[-1]
self.loopends[stack[-1]] = a
stack = stack[:-1]
if len(stack) != 0:
raise SyntaxError('Mismatching []')
if __name__ == "__main__":
bf = Brainf_ck()
if len(argv) == 1:
bf.document()
elif len(argv) == 2:
bf.interpret(argv[1], '')
else:
bf.interpret(argv[1], argv[2])
print bf.output
What happened?James Blast wrote:Mavericks broke my iMac