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
// compile with: gcc -Wall -ansi -pedantic getbg.c -o getbg -lX11 -ljpeg | |
// usage: ./getbg mybg.jpg | |
#include <X11/Xlib.h> | |
#include <X11/Xatom.h> | |
#include <X11/Xutil.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <jpeglib.h> |
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
#!/bin/bash | |
URL=http://www.yr.no/sted/Norge/Sør-Trøndelag/Trondheim/Trondheim/varsel.xml | |
TEMP=$(wget -q -O - $URL | awk -F\" '/<temperature/ {print $4;exit}') | |
if [ $TEMP -gt "20" ]; then | |
echo "<fc=#ee4444>${TEMP}</fc>" | |
elif [ $TEMP -lt "0" ]; then | |
echo "<fc=#3bb9ff>${TEMP}</fc>" | |
else |
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
#!/bin/bash | |
GEOIP_API_KEY="" # http://geoio.com/signup.php | |
WEATHER_API_KEY="" # http://www.worldweatheronline.com/register.aspx | |
IP=$(curl -s "http://whatismyip.org/") | |
GEOIP_URL="http://api.geoio.com/q.php?key=$GEOIP_API_KEY&qt=geoip&d=comma&q=$IP" | |
LAT_LONG=$(curl -s "$GEOIP_URL"|awk -F, '{print $(NF-1)","$NF}') | |
WEATHER_URL="http://www.worldweatheronline.com/feed/weather.ashx?q=${LAT_LONG}&format=csv&num_of_days=2&key=$WEATHER_API_KEY" |
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 Data.Char (ord, chr) | |
import Data.List (elemIndex) | |
import Data.Maybe (fromJust) | |
import Control.Arrow | |
data Card a = Card a | JokerA | JokerB deriving (Show, Eq) | |
type Deck = [Card Int] | |
-- we start with a deck in bridge order | |
startDeck :: Deck |
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
-- lazily produce the binary representation of a number as a list of [0,1] | |
bin ∷ Integer → [Integer] | |
bin n = bin' n ((floor ∘ logBase 2 ∘ fromIntegral) n) | |
where bin' 1 0 = [1] | |
bin' 0 0 = [0] | |
bin' a b = if a ≥ 2^b | |
then 1:bin' (a-2^b) (b-1) | |
else 0:bin' a (b-1) | |
popCount :: Integer -> Integer |
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
{-# Language FlexibleContexts #-} | |
import Data.Packed.Matrix | |
import Numeric.Container | |
normalize :: (Container Vector e) => Matrix e -> Matrix e | |
normalize m = let scaleFactor = sumElements m | |
in (fromLists . map (map (/scaleFactor)) . toLists) m | |
forward :: (Product e, Container Vector e) => |
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
// by alex evans, 2011. released into the public domain. | |
// based on a first ever reading of the png spec, it occurs to me that a minimal png encoder should be quite simple. | |
// this is a first stab - may be buggy! the only external dependency is zlib and some basic typedefs (u32, u8) | |
// | |
// more context at http://altdevblogaday.org/2011/04/06/a-smaller-jpg-encoder/. | |
// | |
// follow me on twitter @mmalex http://twitter.com/mmalex | |
// | |
u32 crc_table[256]={0}; | |
void make_crc_table(void) |
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/perl | |
use MIME::Base64; | |
use Encode 'from_to'; | |
open(MBOX, $ARGV[0]); | |
@mailbox = <MBOX>; | |
$b = join('', @mailbox); | |
@a = split(/\nFrom /, $b); |
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
\usepackage{varioref} | |
\usepackage{prettyref} | |
\usepackage{prettyref} | |
\def\reftextcurrent {} | |
\newrefformat{fig}{Fig.~\ref{#1}\vpageref{#1}} | |
\newrefformat{par}{Section~\ref{#1}\vpageref{#1}} | |
\newrefformat{sec}{Section~\ref{#1}\vpageref{#1}} | |
\newrefformat{sub}{Section~\ref{#1}\vpageref{#1}} | |
\newrefformat{table}{Table~\ref{#1}\vpageref{#1}} |
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 qualified Data.ByteString.Char8 as B | |
import qualified Data.MemoCombinators as Memo | |
findRPI :: Int -> [B.ByteString] -> String | |
findRPI games matches = unlines $ map (\t -> show $ rpi t matches) [0..(games-1)] | |
rpi :: Int -> [B.ByteString] -> Double | |
rpi team matches = 0.25 * wp' + 0.50 * owp' team matches + 0.25 * oowp' team matches | |
where wp' = wp (matches !! team) Nothing | |
owp' = Memo.integral owp |
OlderNewer