Skip to content

Instantly share code, notes, and snippets.

@zandev
zandev / bench-extract-first-column.sh
Created April 1, 2011 09:55
benchmarking some ways to extract the first word of a string in bash
#!/bin/bash
iuser="boby me me and me"
pipe_it() {
echo "$iuser" | awk '{print $1}'
}
heredoc_it() {
awk '{print $1}' <<< "$iuser"
@zandev
zandev / functional-php-data.php
Created February 21, 2011 16:26
Functional data structures experiments in php
<?php
interface øList {
function getHead();
function getTail();
}
class øSimpleList implements øList {
function __construct($head, øList $tail)
@zandev
zandev / haskell-palindromes-benchmark.hs
Created February 17, 2011 10:21
Some benchmarks on solutions provided to exercise 5 chapter 3 of Real World Haskell
import Criterion
import Criterion.Main (defaultMain, bench)
-- Chris Forno 2008-09-03
isPalindromeLastInit :: (Eq a) => [a] -> Bool
isPalindromeLastInit [] = False
isPalindromeLastInit (x:[]) = True
isPalindromeLastInit (x:y:[]) = x == y
isPalindromeLastInit (x:xs) = x == last xs && isPalindromeLastInit (init xs)
@zandev
zandev / ubuntu-need-reboot.sh
Created February 4, 2011 12:21
Does the system need to relaod a new kernel
#!/bin/bash
#original idea: http://ubuntuforums.org/archive/index.php/t-1012637.html
installed=$(dpkg --get-selections | grep -e "^linux-image-2\.[0-9]\." | awk '{print $1}' | sort -u | tail -1)
running="linux-image-$(uname -a | awk '{print $3}')"
echo
echo -n 'Reboot needed: '
if [ "$installed" != "$running" ]; then
<div>
<h2>Tests for common HTML elements
</h2>
<hr>
<h5>PARAGRAPHS
<span>&amp;
</span> BOXES
</h5>