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
# Takes a list of commands with timing information and displays the elapsed | |
# time for each one. | |
# | |
# The input is expected to look like | |
# | |
# +1518804574.3228740692 colors:76> local k | |
# +1518804574.3228929043 colors:77> k=44 | |
# +1518804574.3229091167 colors:77> color[${color[$k]}]=44 | |
# +1518804574.3229229450 colors:77> k=33 | |
# +1518804574.3229279518 colors:77> color[${color[$k]}]=33 |
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
STAT(1) BSD General Commands Manual STAT(1) | |
NAME | |
readlink, stat -- display file status | |
SYNOPSIS | |
stat [-FLnq] [-f format | -l | -r | -s | -x] [-t timefmt] [file ...] | |
readlink [-n] [file ...] |
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 python3 | |
# Takes a sitemap file [1] and submits each URL to the Wayback Machine [2]. | |
# | |
# Usage: python3 submit_urls.py sitemap.xml | |
# | |
# The script will contact the Wayback Machine for each URL in turn and request | |
# that it be saved [3]. The script prints (to standard output) the HTTP status | |
# code received from the Wayback Machine for each URL. The output looks like | |
# this: |
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 flatten-sets | |
"Like flatten, but pulls elements out of sets instead of sequences." | |
[v] | |
(filter (complement set?) | |
(rest (tree-seq set? seq (set v))))) |
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
-- | Creates a new field based on the item's metadata. If the metadata field is not present then no | |
-- field will actually be created. Otherwise, the value will be passed to the given function and the | |
-- result of that function will be used as the field's value. | |
transformedMetadataField :: String -> String -> (String -> String) -> Context a | |
transformedMetadataField key itemName f = field key $ \item -> do | |
fieldValue <- getMetadataField (itemIdentifier item) itemName | |
return $ maybe (fail $ "Value of " ++ itemName ++ " is missing") f fieldValue |
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
<!DOCTYPE html> | |
<head> | |
<title>This is a test</title> | |
<link rel="stylesheet" href="bigfoot-default.css" type="text/css"/> | |
</head> | |
<body> | |
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam iaculis leo ac lacus pretium iaculis. Cras eget eros mauris. Vestibulum ac sapien malesuada, pulvinar odio vel, pellentesque lectus. Duis commodo nibh vel mi commodo consequat. Nam egestas gravida eros et bibendum. Praesent vel suscipit odio. Suspendisse dignissim arcu vitae sapien auctor, vitae auctor libero dapibus.<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup> Pellentesque sagittis, justo vitae mattis tristique, nibh neque convallis metus, a dapibus turpis nisl ut metus. Curabitur consectetur sodales mauris. Donec id vestibulum augue. Aliquam sollicitudin ligula in bibendum malesuada. Praesent tincidunt, purus sed semper vestibulum, purus nulla tempor nisi, vel tincidunt enim lectus et velit. Aenean rhoncus lectus non laoreet laoreet.</p> |
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 | |
# repetition.py | |
# | |
# Usage: python repetition.py input.txt output.svg | |
# | |
# Given a text file containing song lyrics, generates an SVG image showing the | |
# relationships between the lines of text. For more information, read the | |
# article at <http://www.bdesham.info/2013/09/visualizing-repetition>. | |
# |
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 matrix | |
[vectors] | |
(for [i (range (count vectors)) | |
j (range (count vectors))] | |
(distance-between (nth vectors i) (nth vectors j)))) | |
; originally written in Python as | |
; def generate_matrix(vectors): | |
; size = len(vectors) | |
; return [[distance_between(vectors[i], vectors[j]) for i in range(size)] for j in range(size)] |
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
grades = {} | |
for i in range(number_of_students): | |
# using input() can be unsafe; use raw_input() instead | |
name = raw_input("Name: ") | |
first_grade = int(raw_input("First grade: ")) | |
second_grade = int(raw_input("Second grade: ")) | |
grades[name] = (first_grade, second_grade) | |
# after running, grades will be something like |
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
; Replaces each character with an HTML escape code like " ". | |
; This is useful as some lightweight protection against e-mail harvesting; | |
; it probably won't perform correctly with non-ASCII input. | |
; | |
; example: | |
; (obfuscate "example.com") | |
; => "example.com" | |
(defn obfuscate | |
[text] |
NewerOlder