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
type 'a tst_t = | |
| E | |
| N of 'a tst_t * 'a tst_t * 'a tst_t * char * 'a option | |
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 | |
if [ "$#" -lt 2 ] | |
then | |
cat<<EOF | |
Usage: $0 N <cmd> | |
Run <cmd> with a timeout of N seconds. | |
return result of <cmd>. | |
(<cmd> run in background process and is killed on timeout). | |
EOF |
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
class MyNumericUpDown : NumericUpDown | |
{ | |
protected override void OnMouseWheel (MouseEventArgs e) | |
{ | |
// remove scrolllines scaling, taking care of case scrolllines is 0 | |
int delta = e.Delta / Math.Max (Math.Abs (SystemInformation.MouseWheelScrollLines), 1); | |
base.OnMouseWheel (new MouseEventArgs (e.Button, e.Clicks, e.X, e.Y, delta)); | |
} | |
} |
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
public static V GetValueOrDefault<K, V>(this Dictionary<K, V> dic, K key, V defaultVal) | |
{ | |
V ret; | |
return dic.TryGetValue (key, out ret) ? ret : defaultVal; | |
} |
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
-- e.g. Find bases for which bday is palindre: findPal YYYYMMDD [2..1000] | |
-- or compile and run: echo YYYYMMDD | bdaypalbase | |
findPal bases n = | |
filter (Nothing /=) [isPal n b | b <- bases] | |
isPal n b = | |
if pal then Just (n, b, digits) else Nothing | |
where | |
digits = toDigits n b |