This file contains hidden or 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 python | |
| from os import system | |
| from sys import argv | |
| BITS = [0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01] | |
| def asciiToBin(ascii, bitSep=' ', byteSep='. '): | |
| return byteSep.join(bitSep.join('1' if bit & ord(char) else '0' | |
| for bit in BITS) |
This file contains hidden or 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
| module Optional | |
| def self.of value | |
| Of.new value | |
| end | |
| def self.absent | |
| Absent.new | |
| end | |
| private |
This file contains hidden or 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.List | |
| import Test.QuickCheck | |
| anagrams :: String -> String -> Bool | |
| anagrams x y = sort x == sort y | |
| main = do | |
| quickCheck (\(x, y) -> length x <= 8 ==> anagrams x y == (y `elem` permutations x)) | |
| -- tests `anagrams` using 100 sets of 2 random strings | |
| -- uses an obvious but painfully slow algorithm |
This file contains hidden or 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
| javascript: (function () { | |
| /* change this for other services */ | |
| const SubscriptionUrlPrefix = "https://www.newsblur.com/?url="; | |
| const FeedQuerySelector = [ | |
| 'link[rel~="alternate"][type="application/atom+xml"]', | |
| 'link[rel~="alternate"][type="application/rss+xml"]', | |
| ].join(", "); | |
| const YouTubeChannel = /^https:\/\/www.youtube.com\/channel\/([A-Za-z0-9_\-]+)$/; |
This file contains hidden or 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
| $if2(%albumartist%,%artist%)/$if2($left(%date%,4),$if2($left(%originaldate%, 4), 0000)) - %album%/$if($gt(%totaldiscs%,1),%discnumber%-,)$num(%tracknumber%,2) - $if(%compilation%,%artist% -,) %title% |
This file contains hidden or 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 final class Lambdas { | |
| public static final Lambda Identity = x -> x; | |
| public static final Lambda True = x -> y -> x; | |
| public static final Lambda False = x -> y -> y; | |
| public static final Lambda Zero = f -> x -> x; | |
| public static final Lambda Succ = n -> f -> x -> f.call(n.call(f).call(x)); | |
| public static final Lambda Pred = n -> f -> x -> n.call(g -> h -> h.call(g.call(f))).call(ignored -> x).call(u -> u); | |
| public static final Lambda IsZero = f -> f.call(x -> False).call(True); |
This file contains hidden or 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
| module FizzBuzz | |
| module Prod = | |
| let fizzBuzz input = | |
| match (input % 3, input % 5) with | |
| | (0, 0) -> "FizzBuzz" | |
| | (0, _) -> "Fizz" | |
| | (_, 0) -> "Buzz" | |
| | (_, _) -> input.ToString() | |
This file contains hidden or 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
| module BankAccount | |
| module Prod = | |
| type Result<'T> = | |
| | Success of 'T | |
| | Failure of string | |
| let (|>>) (result: Result<'T>) (f: 'T -> Result<'U>) = | |
| match result with | |
| | Success(value) -> f value | |
| | Failure(error) -> Failure(error) |
This file contains hidden or 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
| $ foo=$(false); echo $? | |
| 1 | |
| $ export foo=$(false); echo $? | |
| 0 | |
| $ function bar { local foo=$(false); echo $?; }; bar | |
| 0 |
OlderNewer