Skip to content

Instantly share code, notes, and snippets.

View CliffordAnderson's full-sized avatar

Clifford Anderson CliffordAnderson

View GitHub Profile
@rohanbk
rohanbk / Knapsack
Created December 6, 2010 21:06
Python implementation of classic Knapsack problem
from sys import stdin
from sys import stdout
'''
Knapsack Problem implementation
Created on Dec 6, 2010
@author: rohanbk
'''
capacity=10;
num_of_items=6;
@nimbupani
nimbupani / index.html
Created December 2, 2011 05:00
Showing latest post on home page with Jekyll
---
layout: default
---
<div class="blog-index">
{% assign post = site.posts.first %}
{% assign content = post.content %}
{% include post_detail.html %}
</div>
@joewiz
joewiz / collection.xconf.xml
Created April 7, 2012 19:33
My XQuery snippets
<collection xmlns="http://exist-db.org/collection-config/1.0">
<index>
<!-- Old full text index configuration. Deprecated. -->
<fulltext default="none" attributes="false"/>
<!-- New full text index based on Lucene -->
<lucene>
<text qname="SPEECH">
<ignore qname="SPEAKER"/>
</text>

#The Functional Programmers Cheat Sheet for NDC Oslo 2014

This year NDC Oslo has a full three-day functional programming track with an amazing lineup. If you agree that the future of programming is FP, use this as your "auto pilot" guide on what sessions to attend.

Cheer for sessions on Twitter using the #ndcoslo and #fptrack hashtags.

[The full agenda (including non-fp sessions) is here].

@joewiz
joewiz / 01-library.xql
Last active June 8, 2018 06:10
Unit testing XQuery with XQSuite in eXist-db: tests for a sample function, how to run tests, and test results
xquery version "3.0";
(: This sample library module contains a single function, iu:analyze-date-string().
: The purpose of the sample is to demonstrate XQSuite tests, a unit test framework that uses
: XQuery 3.0's Annotations facility to embed testing assertions and parameters in XQuery functions.
:
: By writing unit tests and running them after each new change to an application, we can spot new bugs
: right away and prevent regressions.
:
: The XQSuite tests in this example are stored in a separate module, 02-tests-xql.
@fordmadox
fordmadox / stage-directions.xq
Last active August 29, 2015 14:02
updated to output well-formed XML, rather than just an XML fragment; also, the return clause in the previous query output all of the stage elements, not the filtered list
declare namespace tei = "http://www.tei-c.org/ns/1.0";
(:
for each person, show stage directions involving that
person
:)
<people-plus-stage-directions>
{
for $person in //tei:person
(: using a map isn't required here, I don't think :)
xquery version "3.0";
declare namespace mdc = "http://mdc";
declare function mdc:add-check-digit-to-partial-barcode ($partial-barcode as xs:string) as xs:string {
(: the next two variables compute the Codabar barcode sum for 14-digit library barcodes according to the Luhn algorithm:)
let $barcode-sum :=
(: add up the even sequence :)
sum(string-to-codepoints($partial-barcode)[position() mod 2 eq 0] ! xs:integer(codepoints-to-string(.)))
+
(: add up the odd sequence :)
<!-- a schema for my postcard, with some commented-out stuff for other possibilities -->
<!-- ?. *, + act the same as quantiifers in regex -->
<!-- file extension has an extra .xml on the end to get github to color-code properly -->
element postcard {
<!-- attribute example
element date {
attribute iso-date { xsd:gYear }?,
text
},-->
element sender { text },
<postcard>
<unitdate>
<date type="single">Oct. 13</date>
</unitdate>
<location>Küsnacht</location>
<body>
<salutation>My dear Jelliffe,</salutation>
<p>It is nice to hear of you again after many years.</p>
<p>I just want to tell you that I see no point in sending my papers to your journal.
You surely know that I am a mystic according to American standards. So I think it will
@nichtich
nichtich / bibtex.bib
Last active July 30, 2023 19:30
Get CSL-Data for a given DOI
@article{Williams_2010,
doi = {10.1371/journal.pone.0010676},
url = {http://dx.doi.org/10.1371/journal.pone.0010676},
year = 2010,
month = {may},
publisher = {Public Library of Science ({PLoS})},
volume = {5},
number = {5},
pages = {e10676},
author = {Jeffrey T. Williams and Kent E. Carpenter and James L. Van Tassell and Paul Hoetjes and Wes Toller and Peter Etnoyer and Michael Smith},