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 bash | |
maxwidth=800 | |
resize () { | |
convert "$1" -resize $maxwidth "$2" | |
} | |
for image in large/*; do | |
width=$(identify -format '%w' "$image") |
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
capitalize <- | |
p(fapply, toupper %.% p(substring, 1, 1), p(substring, 2)) %|>% | |
p(lapply, p(paste, collapse = '')) %|>% unlist | |
# versus | |
capitalize <- function (str) paste(toupper(substring(str, 1, 1)), | |
substring(str, 2), sep = '') | |
# Usage (in both cases): |
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
#include <fstream> | |
#include <iostream> | |
#include <memory> | |
#include <string> | |
#include <vector> | |
// This class is a container, hence a value type (akin to vector) | |
class row { /* ... */ }; | |
// This class is a container (collection of rows), hence a value type. |
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
$ time g++-4.8 -std=c++0x -pedantic -Wall -Wextra -Werror -fvisibility=hidden -fvisibility-inlines-hidden -O0 -o test test.cpp | |
real 2m2.243s | |
user 1m59.593s | |
sys 0m2.444s | |
$ ll test | |
-rwxr-xr-x 1 rudolph staff 8678736 28 Jun 14:19 test | |
$ time g++-4.8 -std=c++0x -isystem/usr/local/include -pedantic -Wall -Wextra -Werror -O0 -o test test.cpp | |
real 2m1.174s | |
user 1m58.565s | |
sys 0m2.448s |
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
rxmatches <- function (pattern, text) { | |
result <- | |
mapply(function (positions, t) | |
mapply(function (p, l) | |
if (p == -1) NULL else substr(t, p, p + l - 1), | |
positions, | |
attr(positions, 'match.length')), | |
gregexpr(pattern, text), | |
text) | |
# Sanitise to get rid of redundant singleton lists of NULL |
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
source('functional.R') | |
# Composing functions for fun and profit: | |
hsv2col <- function (col) | |
apply(col, 2, lpartial(do.call, hsv) %.% as.list) | |
# In non-functional style: | |
hsv2col <- function (col) | |
apply(col, 2, function (c) do.call(hsv, as.list(x))) |
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
struct CProfiler { | |
struct CScopeProfiler { }; | |
struct CScopeRun { }; | |
typedef std::unordered_set< const CScopeProfiler*, | |
std::hash< const CScopeProfiler* >, | |
std::equal_to< const CScopeProfiler* >, | |
CAllocator< const CScopeProfiler* > > CScopeProfilersSet; |
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
template <typename Source> | |
struct auto_cast_helper { | |
Source const& value; | |
explicit auto_cast_helper(Source const& value) : value(value) { } | |
template <typename Target> | |
operator Target() const { | |
return static_cast<Target>(value); | |
} |
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
import <- function (module) { | |
module <- as.character(substitute(module)) | |
# Search path handling omitted for simplicity. | |
filename <- paste(module, 'R', sep = '.') | |
includeGuard <- paste('.INCLUDE', toupper(module), 'R', sep = '_') | |
if (exists(includeGuard)) | |
return() | |
assign(includeGuard, TRUE, envir = topenv()) |
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
<div id="sessionLocked"> | |
<div id="p-en"> | |
<h1>Error - Your session has been locked</h1> | |
<p><b>We are experiencing some difficulties with the website. Please wait 10 seconds and if you are not redirected back <a href="#" id="A1">click here</a>.</b></p> | |
<p><b>If you have already submitted payment your new reservation or flight change MAY have been confirmed.</b></p> | |
<p><b>Before starting again please firstly check your email account to see if you have received an email travel itinerary or alternatively you can check to see if your transaction processed by going to <a href="https://www.bookryanair.com/SkySales/FRManageBooking.aspx">Manage Booking</a> section of our website and completing the information required in Option 2.</b></p> | |
<br/> | |
</div> | |
<div id="l-de"> | |
<h1>Fehler – Ihre Sitzung wurde gesperrt</h1> |