Skip to content

Instantly share code, notes, and snippets.

@morido
morido / MetadataDeterminerTest.java
Last active August 29, 2015 14:14
subset026 requirement metadata attribution
/**
* Test for correct heading attribution based on textual contents and style name
* <p><em>Note:</em> Formatting is not tested here since mocking would add quite a bit of bloat.</p>
*/
@Test
@DomainSpecific
public void testHeading() {
// Step 0: Setup fixture
final class TestDatum {
public final String text;
@morido
morido / gist:9877322
Created March 30, 2014 18:23
Sum up number of PDF pages in a directory
#!/bin/bash
# This sums up the number of pages of all pdfs in a given directory
counter=0
hash pdfinfo 2>/dev/null || { echo >&2 "pdfinfo is required, but not installed. Aborting."; exit 1; }
if [ -n "$1" ]; then dir=$1; else dir="."; fi
for file in $dir/*.pdf; do
currentcount=$(pdfinfo "$file" | sed -n 's/^Pages:\s*\([0-9]\+\)/\1/p')
@morido
morido / lazy_users.py
Last active April 11, 2024 19:32
detect non-contributors in an organization
#!/usr/bin/env python
# you will need http://github3py.readthedocs.org/en/latest/#installation
# I'm not sure if this works on Windows due to the use of strptime()
from github3 import login
import datetime
import json
# Amend the following two lines as necessary
@morido
morido / gist:8678906
Last active January 4, 2016 21:09
Count boolean functions in EFS
all=`awk '{s+=$1} END {print s}' <(find subset-026/ -type f -exec xmlstarlet sel -t -v 'count(//Function)' {} \;)`
boolean=`awk '{s+=$1} END {print s}' <(find subset-026/ -type f -exec xmlstarlet sel -t -v 'count(//Function[@Type="Boolean"])' {} \;)`
echo "$boolean / $all" | bc -l
@morido
morido / gist:8637535
Last active March 4, 2022 07:51
Example of weakness of -Werror=return-type in gcc
#include <stdio.h>
#include <stdbool.h>
bool f(char achar) {
switch (achar)
{
case 'q':
return true;
break;
case 'w':