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
// https://developers.google.com/apps-script/reference/properties/properties#deletepropertykey | |
var colMap = PropertiesService.getScriptProperties(); | |
colMap.setProperties({ | |
"ๆ้ๆณ่จ": 0, | |
"่่ๆด้ขไนณ": 4, | |
"่่ๆฐดๆถๅ้ฒ": 5, | |
"ๅๅณ้ญท้ญ็ตฒ": 7, | |
"ๆฐดๆถ้ญ": 8, | |
"็ด ่ฑ็ณ": 9, | |
"ๆณๅฉ้นน้ค ": 11, |
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
{ | |
"Local Debug": { | |
"prefix": "DEBUG", | |
"body": [ | |
"#define FLAG fprintf(stderr,\"\\033[32;1m#FLAG\\033[0m\\n\");", | |
"#define BIN(x) {fprintf(stderr,\" \\033[33;1m#DEBUG:\\033[0m \"#x\" = \"); \\", | |
"\tfor(int i=15;i>=0;--i)fprintf(stderr,\"%c\",((x)&(1<<i))?'1':'0'); \\", | |
"\tfprintf(stderr,\"\\n\");}", | |
"#define INT(x) fprintf(stderr,\" \\033[33;1m#DEBUG:\\033[0m \"#x\" = %d\\n\", x);", | |
"#define CHR(x) fprintf(stderr,\" \\033[33;1m#DEBUG:\\033[0m \"#x\" = %c\\n\", x);", |
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
nub :: [Int] -> [Int] | |
nub [] = [] | |
nub [x] = [x] | |
nub (x:xs) = if x `elem` xs then nub xs else x : nub xs |
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
stat :: [Int] -> [Int] | |
stat [] = replicate 10 0 | |
stat (x:xs) = (take x stats) ++ [stats !! x + 1] ++ tail (drop x stats) | |
where stats = stat xs | |
plot :: [Int] -> [String] | |
plot ys | |
| all (== 0) ys = [] | |
| otherwise = row : plot ys' | |
where row = map (\y -> if y == 0 then ' ' else '*') ys |
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
-- Build prime number table would be much slower than performing prime tests, | |
-- since we check only x and n-x, and in most cases x < 10 (28.7% when n < 20000). | |
goldbach' :: Int -> Int -> Int -> [Int] | |
goldbach' n m1 m2 = filter (\x -> isPrime x && isPrime (n-x)) $ 3:5:[6+m1,12+m1..n-2] | |
where isPrime x = null $ filter (\y -> x `mod` y == 0) [2..fsqrt x] -- expect x > 1 | |
fsqrt = floor.sqrt.fromIntegral | |
goldbach :: Int -> Maybe (Int, Int) | |
goldbach 4 = Just (2, 2) -- the only case 2 would showed up |
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
-- p1 | |
myFst :: (a, b) -> a | |
myFst = fst -- seemed the only way :( | |
-- p2 | |
myOdd :: Int -> Bool | |
myOdd = (==) 1 . flip mod 2 | |
-- p3 | |
{- |
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
encode :: Int -> String -> String | |
encode key plain = [shift key p | p <- plain] | |
where shift n c = ['A'..'Z'] !! mod (fromEnum c - fromEnum 'A' + n) 26 | |
decode :: String -> (String, Int) | |
decode cipher = let key = (snd.maximum) search in (encode (-key) cipher, key) | |
where search = zip (drop 25 $ convolve cipher_stats (letter_freqs ++ letter_freqs)) (0:[25,24..1]) | |
cipher_stats = [fromIntegral.length $ filter (==c) cipher | c <- ['A'..'Z']] | |
-- 1D discrete convolution altered from stackoverflow.com/a/39784716 |
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 bash | |
# https://askubuntu.com/a/562191 | |
usage() { | |
echo Usage: $(basename $0) PATTERN | |
exit 1 | |
} | |
[ $# -ne 1 ] && usage | |
pattern=$1 |
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 python3 | |
import pandas as pd | |
import numpy as np | |
def display(df): | |
options = ['display.max_rows', None] | |
options += ['display.unicode.east_asian_width', True] | |
with pd.option_context(*options): | |
print(df) |
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
#Peak RT Area% Name Quality Odor Odor-encode | |
12 5.88 0.90 Furfural 90 Medium bready 2 #de795f | |
24 8.80 1.65 Benzaldehyde 97 High fruity 3 #de5f83 | |
25 9.09 0.30 Benzaldehyde 94 High fruity 3 #de5f83 | |
27 9.47 0.45 Methyl_heptenone 97 Medium citric 2 #f0c674 | |
29 9.69 0.83 (E,E)-2,4-heptadienal 94 High fatty 3 #b8baac | |
34 10.50 0.36 Dipentene 92 Medium citric 2 #f0c674 | |
35 10.61 2.57 Benzyl_alcohol 98 Medium floral 2 #b283bd | |
43 12.17 2.64 Linalool 97 Medium floral 2 #b283bd | |
45 12.48 3.06 Phenethyl_alcohol 97 Medium floral 2 #b283bd |
OlderNewer