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 python | |
import socket | |
import subprocess | |
import sys | |
from datetime import datetime | |
# Clear the screen | |
subprocess.call('clear', shell=True) | |
# Ask for input |
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
### Keybase proof | |
I hereby claim: | |
* I am ochronus on github. | |
* I am ochronus (https://keybase.io/ochronus) on keybase. | |
* I have a public key whose fingerprint is 72AE 03B4 9D2A A667 2AF4 64DE CFB8 486E DED3 A6FE | |
To claim this, I am signing this object: |
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
$("a").each(function() { | |
var $elem = $(this); | |
var url = $elem.attr("href"); | |
if (url.indexOf("https://news.ycombinator.com") === 0 || url.indexOf("http") === -1) { | |
return; | |
} | |
if ($elem.attr("target") === undefined) { | |
$elem.attr("target", "_blank"); |
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
(defn bf-interpreter [program-code] | |
(let [ | |
find-bracket (fn [opening-bracket closing-bracket instruction-pointer direction] | |
(loop [i (direction instruction-pointer) opened 0] | |
(condp = (nth program-code i) | |
opening-bracket (recur (direction i) (inc opened)) | |
closing-bracket (if (zero? opened) i (recur (direction i) (dec opened))) | |
(recur (direction i) opened))))] | |
(loop [cells [0N], current-cell 0, instruction-pointer 0] |
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
\[ (recur cells current-cell (inc (if (zero? (nth cells current-cell)) | |
(find-bracket \[ \] instruction-pointer inc) | |
instruction-pointer))) | |
\] (recur cells current-cell (find-bracket \] \[ instruction-pointer dec)) |
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
find-bracket (fn [opening-bracket closing-bracket instruction-pointer direction] | |
(loop [i (direction instruction-pointer) opened 0] | |
(condp = (nth program-code i) | |
opening-bracket (recur (direction i) (inc opened)) | |
closing-bracket (if (zero? opened) i (recur (direction i) (dec opened))) | |
(recur (direction i) opened)))) |
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
\< (recur cells (dec current-cell) (inc instruction-pointer)) | |
\> (let [ | |
next-ptr (inc current-cell) | |
next-cells (if (= next-ptr (count cells)) | |
(conj cells 0N) | |
cells)] | |
(recur next-cells next-ptr (inc instruction-pointer))) |
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
(defn bf-interpreter [program-code] | |
(loop [cells [0N], current-cell 0, instruction-pointer 0] | |
(condp = (get program-code instruction-pointer) | |
\+ (recur (update-in cells [current-cell] inc) current-cell (inc instruction-pointer)) | |
\- (recur (update-in cells [current-cell] dec) current-cell (inc instruction-pointer)) | |
\. (do | |
(print (char (nth cells current-cell))) | |
(recur cells current-cell (inc instruction-pointer))) | |
\, (let [ch (.read System/in)] | |
(recur (assoc cells current-cell ch) current-cell (inc instruction-pointer))) |
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
(defn bf-interpreter [program-code] | |
(loop [cells [0N], current-cell 0, instruction-pointer 0] | |
(condp = (get program-code instruction-pointer) | |
\+ (recur (update-in cells [current-cell] inc) current-cell (inc instruction-pointer)) | |
\- (recur (update-in cells [current-cell] dec) current-cell (inc instruction-pointer)) | |
(recur cells current-cell (inc instruction-pointer))))) |
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
(defn bf-interpreter [program-code] | |
(loop instruction-pointer 0] | |
(recur (inc instruction-pointer)))) |
NewerOlder