commit
2ae8dfb5c2
|
@ -31,7 +31,7 @@ triggers query_nowhitespace => qr<
|
|||
[\( \) x X * % + / \^ 0-9 \. , _ \$ -]*
|
||||
|
||||
(?(1) (?: -? [0-9 \. , _ ]+ |) |)
|
||||
(?: [\( \) x X * % + / \^ \$ -] | times | divided by | plus | minus | cos | sin | tan | cotan | log | ln | log[_]?\d{1,3} | exp | tanh | sec | csc | squared | sqrt )+
|
||||
(?: [\( \) x X * % + / \^ \$ -] | times | divided by | plus | minus | cos | sin | tan | cotan | log | ln | log[_]?\d{1,3} | exp | tanh | sec | csc | squared | sqrt | pi | e )+
|
||||
|
||||
(?: [0-9 \. ,]* )
|
||||
(?: gross | dozen | pi | e | c | squared | score |)
|
||||
|
@ -94,7 +94,7 @@ handle query_nowhitespace => sub {
|
|||
$tmp_expr =~ s/ (\d+?)E(-?\d+)([^\d]|\b) /\($1 * 10**$2\)$3/xg; # E == *10^n
|
||||
$tmp_expr =~ s/\$//g; # Remove $s.
|
||||
$tmp_expr =~ s/=$//; # Drop =.
|
||||
|
||||
$tmp_expr =~ s/([0-9])\s*([a-zA-Z])([^0-9])/$1*$2$3/g; # Support 0.5e or 0.5pi; but don't break 1e8
|
||||
# Now sub in constants
|
||||
while (my ($name, $constant) = each %named_constants) {
|
||||
$tmp_expr =~ s# (\d+?)\s+$name # $1 * $constant #xig;
|
||||
|
@ -109,7 +109,6 @@ handle query_nowhitespace => sub {
|
|||
$tmp_expr = $style->for_computation($tmp_expr);
|
||||
# Using functions makes us want answers with more precision than our inputs indicate.
|
||||
my $precision = ($query =~ $funcy) ? undef : ($query =~ /^\$/) ? 2 : max(map { $style->precision_of($_) } @numbers);
|
||||
|
||||
my $tmp_result;
|
||||
eval {
|
||||
# e.g. sin(100000)/100000 completely makes this go haywire.
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
package DDG::Goodie::CheatSheets;
|
||||
# ABSTRACT: Load basic cheat sheets from JSON files
|
||||
|
||||
use JSON::XS;
|
||||
use DDG::Goodie;
|
||||
use DDP;
|
||||
|
||||
zci answer_type => 'cheat_sheet';
|
||||
zci is_cached => 1;
|
||||
|
||||
name 'CheatSheets';
|
||||
description 'Cheat sheets';
|
||||
primary_example_queries 'universal help', 'universal cheat sheet', 'universal example';
|
||||
code_url 'https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/CheatSheets.pm';
|
||||
category 'cheat_sheets';
|
||||
topics qw'computing geek programming sysadmin';
|
||||
attribution github => [zachthompson => 'Zach Thompson'],
|
||||
github => [moollaza => 'Zaahir Moolla'];
|
||||
|
||||
triggers startend => (
|
||||
'char', 'chars',
|
||||
'character', 'characters',
|
||||
'cheat sheet', 'cheatsheet',
|
||||
'command', 'commands',
|
||||
'example', 'examples',
|
||||
'guide', 'help',
|
||||
'quick reference', 'reference',
|
||||
'shortcut', 'shortcuts',
|
||||
'symbol', 'symbols',
|
||||
);
|
||||
|
||||
handle remainder => sub {
|
||||
# If needed we could jump through a few more hoops to check
|
||||
# terms against file names.
|
||||
my $json_path = share(join('-', split /\s+/o, lc($_) . '.json'));
|
||||
open my $fh, $json_path or return;
|
||||
my $json = do { local $/; <$fh> };
|
||||
my $data = decode_json($json);
|
||||
|
||||
return 'Cheat Sheet', structured_answer => {
|
||||
id => 'cheat_sheets',
|
||||
name => 'Cheat Sheet',
|
||||
data => $data,
|
||||
meta => \%{$data->{meta}},
|
||||
templates => {
|
||||
group => 'base',
|
||||
item => 0,
|
||||
options => {
|
||||
content => 'DDH.cheat_sheets.detail',
|
||||
moreAt => 0
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
1;
|
|
@ -0,0 +1,161 @@
|
|||
package DDG::Goodie::FenViewer;
|
||||
# ABSTRACT: This instant answer parses a chess position in the Forsyth-Edwards notation,
|
||||
# and draws a chessboard on screen representing that position. The current version only
|
||||
# parses the current board position (the first field in the FEN format) and does not check
|
||||
# that the given position is actually legal.
|
||||
|
||||
use DDG::Goodie;
|
||||
use strict;
|
||||
use Scalar::Util qw(looks_like_number);
|
||||
use Try::Tiny;
|
||||
|
||||
zci answer_type => "fen_viewer";
|
||||
zci is_cached => 1;
|
||||
|
||||
name "FenViewer";
|
||||
description "This instant answer parses a chess position in the Forsyth-Edwards notation, and draws a chessboard on screen representing that position.";
|
||||
primary_example_queries "FEN rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1", "fen rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1";
|
||||
|
||||
category "entertainment";
|
||||
topics "gaming";
|
||||
code_url "https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/FENViewer.pm";
|
||||
attribution github => ["rouzbeh", "Ali Neishabouri"],
|
||||
twitter => "Rou7_beh";
|
||||
|
||||
triggers start => "fen";
|
||||
|
||||
# Parse the FEN string into an array of length 64.
|
||||
sub parse_position {
|
||||
my ($i) = 0;
|
||||
my ($position) = @_;
|
||||
$position =~ s/^\s+|\s+$//g;
|
||||
my (@cases) = ();
|
||||
for (my $char = 0 ; $char < length($position) ; $char++ ) {
|
||||
my $fenchar = substr($position, $char, 1);
|
||||
if ($fenchar eq ' ') {
|
||||
return @cases;
|
||||
}
|
||||
if (looks_like_number($fenchar)) {
|
||||
for ($i = 0; $i < $fenchar; $i++){
|
||||
push(@cases, 'e');
|
||||
}
|
||||
}
|
||||
elsif ($fenchar ne '/') {
|
||||
push(@cases, $fenchar);
|
||||
}
|
||||
}
|
||||
return @cases;
|
||||
}
|
||||
|
||||
# Generate a chessboard as a HTML table.
|
||||
sub draw_chessboard_html {
|
||||
my (@position) = @_;
|
||||
my ($i) = 0;
|
||||
my ($j) = 0;
|
||||
my ($counter) = 0;
|
||||
my (@arr) = ("A".."Z");
|
||||
my (%class_dict) = (
|
||||
'r' => 'black rook',
|
||||
'n' => 'black knight',
|
||||
'b' => 'black bishop',
|
||||
'q' => 'black queen',
|
||||
'k' => 'black king',
|
||||
'p' => 'black pawn',
|
||||
'e' => 'empty',
|
||||
'R' => 'white rook',
|
||||
'N' => 'white knight',
|
||||
'B' => 'white bishop',
|
||||
'Q' => 'white queen',
|
||||
'K' => 'white king',
|
||||
'P' => 'white pawn',
|
||||
);
|
||||
|
||||
my (%unicode_dict) = (
|
||||
'r' => '♜',
|
||||
'n' => '♞',
|
||||
'b' => '♝',
|
||||
'q' => '♛',
|
||||
'k' => '♚',
|
||||
'p' => '♟',
|
||||
'e' => '',
|
||||
'R' => '♖',
|
||||
'N' => '♘',
|
||||
'B' => '♗',
|
||||
'Q' => '♕',
|
||||
'K' => '♔',
|
||||
'P' => '♙',
|
||||
);
|
||||
|
||||
my ($html_chessboard) = '<div class="zci--fenviewer"><table class="chess_board" cellpadding="0" cellspacing="0">';
|
||||
for ($i = 0; $i < 8; $i++){
|
||||
# Rows
|
||||
$html_chessboard .= '<tr>';
|
||||
for ($j = 0; $j < 8; $j++){
|
||||
# Columns
|
||||
$html_chessboard .= '<td id="'.$arr[$j].(8-$i).'">';
|
||||
$html_chessboard .= '<a href="#" class="'.$class_dict{$position[$counter]};
|
||||
$html_chessboard .= '">'.$unicode_dict{$position[$counter]}.'</a>';
|
||||
$html_chessboard .= '</td>';
|
||||
$counter++;
|
||||
}
|
||||
$html_chessboard .= '</tr>';
|
||||
}
|
||||
$html_chessboard .= '</table></div>';
|
||||
return $html_chessboard;
|
||||
}
|
||||
|
||||
# Generate a chessboard in ASCII, with the same format as
|
||||
# 'text output from Chess::PGN::EPD
|
||||
sub draw_chessboard_ascii {
|
||||
my (@position) = @_;
|
||||
my ($i) = 0;
|
||||
my ($j) = 0;
|
||||
my ($counter) = 0;
|
||||
my ($ascii_chessboard) = "";
|
||||
for ($i = 0; $i < 8; $i++){
|
||||
# Rows
|
||||
for ($j = 0; $j < 8; $j++){
|
||||
# Columns
|
||||
if ($position[$counter] ne 'e') {
|
||||
# Occupied square
|
||||
$ascii_chessboard .= $position[$counter];
|
||||
}
|
||||
elsif ($j % 2 != $i % 2) {
|
||||
# Black square
|
||||
$ascii_chessboard .= '-';
|
||||
}
|
||||
else {
|
||||
# White square
|
||||
$ascii_chessboard .= ' ';
|
||||
}
|
||||
$counter++;
|
||||
}
|
||||
if($counter < 63) {
|
||||
$ascii_chessboard .= "\n";
|
||||
}
|
||||
}
|
||||
return $ascii_chessboard;
|
||||
}
|
||||
|
||||
handle remainder => sub {
|
||||
my ($query) = $_;
|
||||
return unless $query;
|
||||
my (@pos) = parse_position($query);
|
||||
if ($#pos != 63) {
|
||||
# The format is wrong, e.g. space in the middle
|
||||
return;
|
||||
}
|
||||
my ($html_out) = '';
|
||||
my ($ascii_out) = '';
|
||||
try {
|
||||
$html_out = draw_chessboard_html(@pos);
|
||||
$ascii_out = draw_chessboard_ascii(@pos);
|
||||
}
|
||||
catch {
|
||||
# The format is wrong, e.g. non-existent piece
|
||||
return;
|
||||
};
|
||||
return $ascii_out, html => $html_out;
|
||||
};
|
||||
|
||||
1;
|
|
@ -0,0 +1,28 @@
|
|||
package DDG::Goodie::IsAwesome::kleinjoshuaa;
|
||||
# ABSTRACT: kleinjoshuaa's first goodie
|
||||
|
||||
|
||||
use DDG::Goodie;
|
||||
use strict;
|
||||
|
||||
zci answer_type => "is_awesome_kleinjoshuaa";
|
||||
zci is_cached => 1;
|
||||
|
||||
name "IsAwesome kleinjoshuaa";
|
||||
description "My first Goodie, it lets the world know that kleinjoshuaa is awesome";
|
||||
primary_example_queries "duckduckhack kleinjoshuaa";
|
||||
category "special";
|
||||
topics "special_interest", "geek";
|
||||
code_url "https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/IsAwesome/kleinjoshuaa.pm";
|
||||
attribution github => ["https://github.com/kleinjoshuaa", "kleinjoshuaa"];
|
||||
|
||||
# Triggers
|
||||
triggers start => "duckduckhack kleinjoshuaa";
|
||||
|
||||
# Handle statement
|
||||
handle remainder => sub {
|
||||
return if $_;
|
||||
return "kleinjoshuaa is awesome and has successfully completed the duckduckhack goodie tutorial!";
|
||||
};
|
||||
|
||||
1;
|
|
@ -0,0 +1,25 @@
|
|||
package DDG::Goodie::IsAwesome::ngzhian;
|
||||
# ABSTRACT: ngzhian's first Goodie
|
||||
|
||||
use DDG::Goodie;
|
||||
|
||||
zci answer_type => "is_awesome_ngzhian";
|
||||
zci is_cached => 1;
|
||||
|
||||
name "IsAwesome ngzhian";
|
||||
description "My first Goodie, it lets the world know that ngzhian is awesome";
|
||||
primary_example_queries "duckduckhack ngzhian";
|
||||
category "special";
|
||||
topics "special_interest", "geek";
|
||||
code_url "https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/IsAwesome/ngzhian.pm";
|
||||
attribution github => ["https://github.com/ngzhian", "ngzhian"],
|
||||
twitter => "ngzhian";
|
||||
|
||||
triggers start => "duckduckhack ngzhian";
|
||||
|
||||
handle remainder => sub {
|
||||
return if $_;
|
||||
return "ngzhian is awesome and has successfully completed the DuckDuckHack Goodie tutorial!";
|
||||
};
|
||||
|
||||
1;
|
|
@ -0,0 +1,25 @@
|
|||
package DDG::Goodie::IsAwesome::organiker;
|
||||
# ABSTRACT: organiker's first Goodie
|
||||
|
||||
use DDG::Goodie;
|
||||
|
||||
zci answer_type => "is_awesome_organiker";
|
||||
zci is_cached => 1;
|
||||
|
||||
name "IsAwesome organiker";
|
||||
description "My first Goodie, it lets the world know that organiker is awesome";
|
||||
primary_example_queries "duckduckhack organiker";
|
||||
category "special";
|
||||
topics "special_interest", "geek";
|
||||
code_url "https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/IsAwesome/GitHubUsername.pm";
|
||||
attribution github => ["https://github.com/organiker", "organiker"],
|
||||
twitter => "jiyeonorganiker";
|
||||
|
||||
triggers start => "duckduckhack organiker";
|
||||
|
||||
handle remainder => sub {
|
||||
return if $_;
|
||||
return "organiker is awesome and has successfully completed the DuckDuckHack Goodie tutorial!";
|
||||
};
|
||||
|
||||
1;
|
|
@ -0,0 +1,25 @@
|
|||
package DDG::Goodie::IsAwesome::rramyr;
|
||||
# ABSTRACT: GitHubrramyr's first Goodie
|
||||
|
||||
use DDG::Goodie;
|
||||
|
||||
zci answer_type => "is_awesome_rramyr";
|
||||
zci is_cached => 1;
|
||||
|
||||
name "IsAwesome rramyr";
|
||||
description "My first Goodie, it lets the world know that rramyr is awesome";
|
||||
primary_example_queries "duckduckhack rramyr";
|
||||
category "special";
|
||||
topics "special_interest", "geek";
|
||||
code_url "https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/IsAwesome/rramyr.pm";
|
||||
attribution github => ["https://github.com/rramyr", "rramyr"];
|
||||
|
||||
|
||||
triggers any => "duckduckhack rramyr";
|
||||
|
||||
handle remainder => sub {
|
||||
return if $_;
|
||||
return "rramyr is awesome and has successfully completed the DuckDuckHack Goodie tutorial!";
|
||||
};
|
||||
|
||||
1;
|
|
@ -0,0 +1,65 @@
|
|||
package DDG::Goodie::Rc4;
|
||||
# ABSTRACT: This goddie provides a simple encription/decryption service
|
||||
# using RC4 algorithm and a key provided by the user.
|
||||
|
||||
use DDG::Goodie;
|
||||
use strict;
|
||||
use warnings;
|
||||
use Crypt::RC4;
|
||||
use MIME::Base64;
|
||||
|
||||
zci answer_type => "rc4";
|
||||
zci is_cached => 1;
|
||||
|
||||
name "RC4.pm";
|
||||
description "Encrypt or decrypt a text using a key provided by the user";
|
||||
primary_example_queries "rc4 en mysecretkey hello", "rc4 de duck yWrJniG/nNg=";
|
||||
category "computing_tools";
|
||||
topics "cryptography";
|
||||
code_url "https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/Rc4.pm";
|
||||
attribution github => ["https://github.com/puskin94", "puskin94"],
|
||||
github => ["diegojuan", "JD"],
|
||||
web => "sysadminjd.com";
|
||||
|
||||
# Triggers
|
||||
triggers startend => "rc4";
|
||||
|
||||
# Handle statement
|
||||
|
||||
handle remainder => sub {
|
||||
|
||||
(my $type, my $key, my $plaintext) = split / /;
|
||||
my $operation;
|
||||
my $result;
|
||||
|
||||
return unless $type && $key && $plaintext;
|
||||
|
||||
if ($type =~ m/^en(c|crypt)?$/) {
|
||||
# To encrypt we receive the plaintext as is and pass it to the RC4 function.
|
||||
my $encrypted = RC4($key, $plaintext);
|
||||
# To avoid problems with non printable characters, we transform the result using encode_base64()
|
||||
$result = encode_base64($encrypted);
|
||||
chomp $result;
|
||||
$operation = "RC4 Encrypt";
|
||||
|
||||
} elsif ($type =~ m/^de(c|crypt)?$/) {
|
||||
#To decrypt we do the reverse process, we take the plaintext, transform it using decode_base64()
|
||||
my $decoded = decode_base64($plaintext);
|
||||
# Then we pass it to the RC4 funcion to be decrypted.
|
||||
$result = RC4($key, $decoded);
|
||||
# No need to encode again, this result is show as is.
|
||||
$operation = "RC4 Decrypt";
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
return "$operation: $plaintext, with key: $key is $result",
|
||||
structured_answer => {
|
||||
operation => $operation,
|
||||
input => [html_enc($plaintext) . ", Key: $key"],
|
||||
result => $result
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
1;
|
|
@ -0,0 +1,49 @@
|
|||
.zci--cheat_sheets .cheatsheet__container.compressed {
|
||||
max-height: 20em;
|
||||
}
|
||||
|
||||
.zci--cheat_sheets .cheatsheet__container.compressed .cheatsheet__section,
|
||||
.zci--cheat_sheets .cheatsheet__container.compressed .cheatsheet__section .g {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.zci--cheat_sheets .cheatsheet__section,
|
||||
.zci--cheat_sheets .cheatsheet__section .g {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.zci--cheat_sheets .cheatsheet__container .cheatsheet__section:nth-child(-n+2) {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.zci--cheat_sheets .cheatsheet__container .cheatsheet__section:nth-child(-n+2) .g:nth-child(-n+6) {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.zci--cheat_sheets .cheatsheet__container {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.zci--cheat_sheets .cheatsheet__title {
|
||||
font-weight: bold;
|
||||
font-size: 1em;
|
||||
color: #444;
|
||||
}
|
||||
|
||||
.zci--cheat_sheets .cheatsheet__section {
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
|
||||
.zci--cheat_sheets .cheatsheet__data {
|
||||
display: block;
|
||||
margin-bottom: 0.4em;
|
||||
color: #444
|
||||
}
|
||||
|
||||
.zci--cheat_sheets .cheatsheet__data code {
|
||||
background-color: #e0e0e0;
|
||||
border-radius: 2px;
|
||||
padding: 2px;
|
||||
font-weight: bold;
|
||||
line-height: 1;
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
DDH.cheat_sheets = DDH.cheat_sheets || {};
|
||||
|
||||
DDH.cheat_sheets.build = function(ops) {
|
||||
|
||||
Handlebars.registerHelper('ordered_cheatsheet', function(sections, section_order, options) {
|
||||
var result ="";
|
||||
$.each(section_order, function(i, section) {
|
||||
if (sections[section]){
|
||||
result += options.fn({ name: section, items: sections[section] });
|
||||
}
|
||||
});
|
||||
return result;
|
||||
});
|
||||
|
||||
return {
|
||||
onShow: function() {
|
||||
var $dom = $("#zci-cheat_sheets"),
|
||||
$container = $dom.find(".cheatsheet__container"),
|
||||
$more_btn = $dom.find(".chomp--link"),
|
||||
$icon = $more_btn.find(".chomp--link__icn"),
|
||||
$more = $more_btn.find(".chomp--link__mr"),
|
||||
$less = $more_btn.find(".chomp--link__ls");
|
||||
|
||||
$more_btn.click(function() {
|
||||
$dom.toggleClass("has-chomp-expanded");
|
||||
$container.toggleClass("compressed");
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
|
@ -0,0 +1,31 @@
|
|||
<h3 class="c-base__title">{{name}}</h3>
|
||||
<h4 class="c-base__sub">{{description}}</h4>
|
||||
|
||||
<div class="gw cheatsheet__container compressed">
|
||||
|
||||
{{#ordered_cheatsheet sections section_order}}
|
||||
<div class="g half cheatsheet__section">
|
||||
<h6 class="cheatsheet__title">{{name}}</h6>
|
||||
<div class="gw">
|
||||
{{#each items}}
|
||||
<div class="g forty">
|
||||
<span class="cheatsheet__data"><code>{{key}}</code></span>
|
||||
</div>
|
||||
<div class="g sixty">
|
||||
<span class="cheatsheet__data">{{val}}</span>
|
||||
</div>
|
||||
{{/each}}
|
||||
</div>
|
||||
</div>
|
||||
{{/ordered_cheatsheet}}
|
||||
</div>
|
||||
|
||||
<div class="cheatsheet__footer">
|
||||
<hr>
|
||||
<a class="c-text__link c-text__link--chomp chomp--link sep--after can-expand">
|
||||
<i class="chomp--link__icn"></i>
|
||||
<span class="chomp--link__mr">Show More</span>
|
||||
<span class="chomp--link__ls">Show Less</span>
|
||||
</a>
|
||||
<span class="pull-right">{{{moreAt meta 'none' className="c-base__link"}}}</span>
|
||||
</div>
|
|
@ -0,0 +1,252 @@
|
|||
{
|
||||
"name": "Regex Cheat Sheet",
|
||||
"section_order": ["Anchors", "Character Classes", "POSIX Classes", "Pattern Modifiers", "Escape Sequences", "Quantifiers", "Groups and Ranges", "Assertions", "Special Characters", "String Replacement"],
|
||||
"sections": {
|
||||
"Assertions": [{
|
||||
"val": "Lookahead assertion",
|
||||
"key": "?="
|
||||
}, {
|
||||
"val": "Negative lookahead",
|
||||
"key": "?!"
|
||||
}, {
|
||||
"val": "Lookbehind assertion",
|
||||
"key": "?<="
|
||||
}, {
|
||||
"val": "Negative lookbehind",
|
||||
"key": "?!= or ?<!"
|
||||
}, {
|
||||
"val": "Once-only Subexpression",
|
||||
"key": "?>"
|
||||
}, {
|
||||
"val": "Condition [if then]",
|
||||
"key": "?()"
|
||||
}, {
|
||||
"val": "Condition [if then else]",
|
||||
"key": "?()|"
|
||||
}, {
|
||||
"val": "Comment",
|
||||
"key": "?#"
|
||||
}],
|
||||
"POSIX Classes": [{
|
||||
"val": "Uppercase letters [A-Z]",
|
||||
"key": "[:upper:]"
|
||||
}, {
|
||||
"val": "Lowercase letters [a-z]",
|
||||
"key": "[:lower:]"
|
||||
}, {
|
||||
"val": "All letters [A-Za-z]",
|
||||
"key": "[:alpha:]"
|
||||
}, {
|
||||
"val": "Digits and letters [A-Za-z0-9]",
|
||||
"key": "[:alnum:]"
|
||||
}, {
|
||||
"val": "Digits [0-9]",
|
||||
"key": "[:digit:]"
|
||||
}, {
|
||||
"val": "Hexadecimal digits [0-9a-f]",
|
||||
"key": "[:xdigit:]"
|
||||
}, {
|
||||
"val": "Punctuation",
|
||||
"key": "[:punct:]"
|
||||
}, {
|
||||
"val": "Space and tab [ \\t]",
|
||||
"key": "[:blank:]"
|
||||
}, {
|
||||
"val": "Blank characters [ \\t\\r\\n\\v\\f]",
|
||||
"key": "[:space:]"
|
||||
}, {
|
||||
"val": "Control characters [\\x00-\\x1F\\x7F]",
|
||||
"key": "[:cntrl:]"
|
||||
}, {
|
||||
"val": "Printed characters [\\x21-\\x7E]",
|
||||
"key": "[:graph:]"
|
||||
}, {
|
||||
"val": "Printed characters and spaces [\\x20-\\x7E]",
|
||||
"key": "[:print:]"
|
||||
}, {
|
||||
"val": "Digits, letters and underscore [A-Za-z0-9_]",
|
||||
"key": "[:word:]"
|
||||
}],
|
||||
"Groups and Ranges": [{
|
||||
"val": "Any character except newline (\\n)",
|
||||
"key": "."
|
||||
}, {
|
||||
"val": "a or b",
|
||||
"key": "(a|b)"
|
||||
}, {
|
||||
"val": "Group",
|
||||
"key": "(...)"
|
||||
}, {
|
||||
"val": "Passive (non-capturing) group",
|
||||
"key": "(?:...)"
|
||||
}, {
|
||||
"val": "Single character (a or b or c)",
|
||||
"key": "[abc]"
|
||||
}, {
|
||||
"val": "Single character (not a or b or c)",
|
||||
"key": "[^abc]"
|
||||
}, {
|
||||
"val": "Single character range (a or b ... or q)",
|
||||
"key": "[a-q]"
|
||||
}, {
|
||||
"val": "Single character range (A or B ... or Z)",
|
||||
"key": "[A-Z]"
|
||||
}, {
|
||||
"val": "Single digit from 0 to 9",
|
||||
"key": "[0-9]"
|
||||
}],
|
||||
"Special Characters": [{
|
||||
"val": "New line",
|
||||
"key": "\\n"
|
||||
}, {
|
||||
"val": "Carriage return",
|
||||
"key": "\\r"
|
||||
}, {
|
||||
"val": "Tab",
|
||||
"key": "\\t"
|
||||
}, {
|
||||
"val": "Vertical tab",
|
||||
"key": "\\v"
|
||||
}, {
|
||||
"val": "Form feed",
|
||||
"key": "\\f"
|
||||
}, {
|
||||
"val": "Octal character ooo",
|
||||
"key": "\\ooo"
|
||||
}, {
|
||||
"val": "Hex character hh",
|
||||
"key": "\\xhh"
|
||||
}],
|
||||
"Escape Sequences": [{
|
||||
"val": "Escape following character",
|
||||
"key": "\\"
|
||||
}, {
|
||||
"val": "Begin literal sequence",
|
||||
"key": "\\Q"
|
||||
}, {
|
||||
"val": "End literal sequence",
|
||||
"key": "\\E"
|
||||
}],
|
||||
"Pattern Modifiers": [{
|
||||
"val": "Global Match (all occurrences)",
|
||||
"key": "//g"
|
||||
}, {
|
||||
"val": "Case-insensitive",
|
||||
"key": "//i"
|
||||
}, {
|
||||
"val": "Multiple line",
|
||||
"key": "//m"
|
||||
}, {
|
||||
"val": "Treat string as single line",
|
||||
"key": "//s"
|
||||
}, {
|
||||
"val": "Allow comments and whitespace",
|
||||
"key": "//x"
|
||||
}, {
|
||||
"val": "Evaluate replacement",
|
||||
"key": "//e"
|
||||
}, {
|
||||
"val": "Ungreedy pattern",
|
||||
"key": "//U"
|
||||
}],
|
||||
"Quantifiers": [{
|
||||
"val": "0 or more",
|
||||
"key": "*"
|
||||
}, {
|
||||
"val": "1 or more",
|
||||
"key": "+"
|
||||
}, {
|
||||
"val": "0 or 1 (optional)",
|
||||
"key": "?"
|
||||
}, {
|
||||
"val": "Exactly 3",
|
||||
"key": "{3}"
|
||||
}, {
|
||||
"val": "3 or more",
|
||||
"key": "{3,}"
|
||||
}, {
|
||||
"val": "2, 3, 4 or 5",
|
||||
"key": "{2,5}"
|
||||
}],
|
||||
"String Replacement": [{
|
||||
"val": "n-th non-passive group",
|
||||
"key": "$n"
|
||||
}, {
|
||||
"val": "\"xyz\" in /^(abc(xyz))$/",
|
||||
"key": "$2"
|
||||
}, {
|
||||
"val": "\"xyz\" in /^(?:abc)(xyz)$/",
|
||||
"key": "$1"
|
||||
}, {
|
||||
"val": "Before matched string",
|
||||
"key": "$`"
|
||||
}, {
|
||||
"val": "After matched string",
|
||||
"key": "$'"
|
||||
}, {
|
||||
"val": "Last matched string",
|
||||
"key": "$+"
|
||||
}, {
|
||||
"val": "Entire matched string",
|
||||
"key": "$&"
|
||||
}],
|
||||
"Character Classes": [{
|
||||
"val": "Control character",
|
||||
"key": "\\c"
|
||||
}, {
|
||||
"val": "Whitespace",
|
||||
"key": "\\s"
|
||||
}, {
|
||||
"val": "Not Whitespace",
|
||||
"key": "\\S"
|
||||
}, {
|
||||
"val": "Digit",
|
||||
"key": "\\d"
|
||||
}, {
|
||||
"val": "Not digit",
|
||||
"key": "\\D"
|
||||
}, {
|
||||
"val": "Word",
|
||||
"key": "\\w"
|
||||
}, {
|
||||
"val": "Not Word",
|
||||
"key": "\\W"
|
||||
}, {
|
||||
"val": "Hexadecimal digit",
|
||||
"key": "\\x"
|
||||
}, {
|
||||
"val": "Octal Digit",
|
||||
"key": "\\O"
|
||||
}],
|
||||
"Anchors": [{
|
||||
"val": "Start of string or line",
|
||||
"key": "^"
|
||||
}, {
|
||||
"val": "Start of string",
|
||||
"key": "\\A"
|
||||
}, {
|
||||
"val": "End of string or line",
|
||||
"key": "$"
|
||||
}, {
|
||||
"val": "End of string",
|
||||
"key": "\\Z"
|
||||
}, {
|
||||
"val": "Word boundary",
|
||||
"key": "\\b"
|
||||
}, {
|
||||
"val": "Not word boundary",
|
||||
"key": "\\B"
|
||||
}, {
|
||||
"val": "Start of word",
|
||||
"key": "\\<"
|
||||
}, {
|
||||
"val": "End of word",
|
||||
"key": "\\>"
|
||||
}]
|
||||
},
|
||||
"description": "Regular expression syntax",
|
||||
"meta": {
|
||||
"sourceName": "?",
|
||||
"sourceURL": ""
|
||||
}
|
||||
}
|
|
@ -0,0 +1,118 @@
|
|||
{
|
||||
"name": "tmux",
|
||||
"description": "Terminal multiplexer",
|
||||
"meta": {
|
||||
"sourceName": "OpenBSD",
|
||||
"sourceURL": "http://www.openbsd.org/cgi-bin/man.cgi?query=tmux&sektion=1"
|
||||
},
|
||||
"section_order": ["Session Control (from the command line)", "Pane Control", "Window Control", "Copy-Mode (Emacs)", "Copy-Mode (vi)"],
|
||||
"sections": {
|
||||
"Copy-Mode (Emacs)": [{
|
||||
"val": "Enter copy mode",
|
||||
"key": "Ctrl-B ["
|
||||
}, {
|
||||
"val": "Bottom of history",
|
||||
"key": "Ctrl-B M-<"
|
||||
}, {
|
||||
"val": "Top of histroy",
|
||||
"key": "Ctrl-B M->"
|
||||
}, {
|
||||
"val": "Copy selection",
|
||||
"key": "Ctrl-B M-w"
|
||||
}, {
|
||||
"val": "Paste selection",
|
||||
"key": "Ctrl-B M-y"
|
||||
}, {
|
||||
"val": "Cursor Up",
|
||||
"key": "Ctrl-B Up"
|
||||
}, {
|
||||
"val": "Cursor Down",
|
||||
"key": "Ctrl-B Down"
|
||||
}, {
|
||||
"val": "Cursor Left",
|
||||
"key": "Ctrl-B Left"
|
||||
}, {
|
||||
"val": "Cursor Right",
|
||||
"key": "Ctrl-B Right"
|
||||
}],
|
||||
"Window Control": [{
|
||||
"val": "Create new window",
|
||||
"key": "Ctrl-B c"
|
||||
}, {
|
||||
"val": "Detach from session",
|
||||
"key": "Ctrl-B d"
|
||||
}, {
|
||||
"val": "Rename a window",
|
||||
"key": "Ctrl-B ,"
|
||||
}, {
|
||||
"val": "List windows",
|
||||
"key": "Ctrl-B w"
|
||||
}],
|
||||
"Pane Control": [{
|
||||
"val": "Split pane horizontally",
|
||||
"key": "Ctrl-B \""
|
||||
}, {
|
||||
"val": "Split pane vertically",
|
||||
"key": "Ctrl-B %"
|
||||
}, {
|
||||
"val": "Next pane",
|
||||
"key": "Ctrl-B o"
|
||||
}, {
|
||||
"val": "Previous pane",
|
||||
"key": "Ctrl-B ;"
|
||||
}, {
|
||||
"val": "Kill current pane",
|
||||
"key": "Ctrl-B x"
|
||||
}, {
|
||||
"val": "Kill all panes but the current one",
|
||||
"key": "Ctrl-B !"
|
||||
}, {
|
||||
"val": "Swap panes",
|
||||
"key": "Ctrl-B Ctrl-O"
|
||||
}, {
|
||||
"val": "Display clock",
|
||||
"key": "Ctrl-B t"
|
||||
}, {
|
||||
"val": "Transpose two letters (delete and paste)",
|
||||
"key": "Ctrl-B q"
|
||||
}],
|
||||
"Copy-Mode (vi)": [{
|
||||
"val": "Enter copy mode",
|
||||
"key": "Ctrl-B ["
|
||||
}, {
|
||||
"val": "Bottom of history",
|
||||
"key": "Ctrl-B G"
|
||||
}, {
|
||||
"val": "Top of histroy",
|
||||
"key": "Ctrl-B g"
|
||||
}, {
|
||||
"val": "Copy selection",
|
||||
"key": "Ctrl-B Enter"
|
||||
}, {
|
||||
"val": "Paste selection",
|
||||
"key": "Ctrl-B p"
|
||||
}, {
|
||||
"val": "Cursor Up",
|
||||
"key": "Ctrl-B k"
|
||||
}, {
|
||||
"val": "Cursor Down",
|
||||
"key": "Ctrl-B j"
|
||||
}, {
|
||||
"val": "Cursor Left",
|
||||
"key": "Ctrl-B h"
|
||||
}, {
|
||||
"val": "Cursor Right",
|
||||
"key": "Ctrl-B l"
|
||||
}],
|
||||
"Session Control (from the command line)": [{
|
||||
"val": "Start a new session",
|
||||
"key": "tmux"
|
||||
}, {
|
||||
"val": "Re-attach a detached session",
|
||||
"key": "tmux attach"
|
||||
}, {
|
||||
"val": "Re-attach a detached session (and detach it from elsewhere)",
|
||||
"key": "tmux attach -d"
|
||||
}]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,314 @@
|
|||
{
|
||||
"name": "Vim",
|
||||
"description": "Text Editor",
|
||||
"meta": {
|
||||
"sourceName": "VimCheatSheet",
|
||||
"sourceUrl": "https://duckduckgo.com"
|
||||
},
|
||||
"section_order": [
|
||||
"Cursor movement",
|
||||
"Insert mode - inserting/appending text",
|
||||
"Editing",
|
||||
"Marking text (visual mode)",
|
||||
"Visual commands",
|
||||
"Cut and paste",
|
||||
"Exiting",
|
||||
"Search and replace",
|
||||
"Working with multiple files",
|
||||
"Tabs"
|
||||
],
|
||||
"sections": {
|
||||
"Tabs": [{
|
||||
"val": "open a file in a new tab",
|
||||
"key": ":tabnew filename, :tabn filename"
|
||||
}, {
|
||||
"val": "move the current split window into its own tab",
|
||||
"key": "Ctrl+wt"
|
||||
}, {
|
||||
"val": "move to the next tab",
|
||||
"key": "gt, :tabnext, :tabn"
|
||||
}, {
|
||||
"val": "move to the previous tab",
|
||||
"key": "gT, :tabprev, :tabp"
|
||||
}, {
|
||||
"val": "move to tab number #",
|
||||
"key": "#gt"
|
||||
}, {
|
||||
"val": "move current tab to the #th position (indexed from 0)",
|
||||
"key": ":tabmove #"
|
||||
}, {
|
||||
"val": "close the current tab and all its windows",
|
||||
"key": ":tabclose/:tabc"
|
||||
}, {
|
||||
"val": "close all tabs except for the current one",
|
||||
"key": ":tabonly/:tabo"
|
||||
}],
|
||||
"Editing": [{
|
||||
"val": "replace a single character",
|
||||
"key": "r"
|
||||
}, {
|
||||
"val": "join line below to the current one",
|
||||
"key": "J"
|
||||
}, {
|
||||
"val": "change (replace) entire line",
|
||||
"key": "cc"
|
||||
}, {
|
||||
"val": "change (replace) to the end of the word",
|
||||
"key": "cw"
|
||||
}, {
|
||||
"val": "change (replace) to the end of the line",
|
||||
"key": "c$"
|
||||
}, {
|
||||
"val": "delete character and substitute text",
|
||||
"key": "s"
|
||||
}, {
|
||||
"val": "delete line and substitute text (same as cc)",
|
||||
"key": "S"
|
||||
}, {
|
||||
"val": "transpose two letters (delete and paste)",
|
||||
"key": "xp"
|
||||
}, {
|
||||
"val": "undo",
|
||||
"key": "u"
|
||||
}, {
|
||||
"val": "redo",
|
||||
"key": "Ctrl+r"
|
||||
}, {
|
||||
"val": "repeat last command",
|
||||
"key": "."
|
||||
}],
|
||||
"Exiting": [{
|
||||
"val": "write (save) the file, but don't exit",
|
||||
"key": ":w"
|
||||
}, {
|
||||
"val": "write (save) and quit",
|
||||
"key": ":wq"
|
||||
}, {
|
||||
"val": "write (save) and quit",
|
||||
"key": ":x"
|
||||
}, {
|
||||
"val": "quit (fails if there are unsaved changes)",
|
||||
"key": ":q"
|
||||
}, {
|
||||
"val": "quit and throw away unsaved changes",
|
||||
"key": ":q!"
|
||||
}],
|
||||
"Insert mode - inserting/appending text": [{
|
||||
"val": "insert before the cursor",
|
||||
"key": "i"
|
||||
}, {
|
||||
"val": "insert at the beginning of the line",
|
||||
"key": "I"
|
||||
}, {
|
||||
"val": "insert (append) after the cursor",
|
||||
"key": "a"
|
||||
}, {
|
||||
"val": "insert (append) at the end of the line",
|
||||
"key": "A"
|
||||
}, {
|
||||
"val": "append (open) a new line below the current line",
|
||||
"key": "o"
|
||||
}, {
|
||||
"val": "append (open) a new line above the current line",
|
||||
"key": "O"
|
||||
}, {
|
||||
"val": "insert (append) at the end of the word",
|
||||
"key": "ea"
|
||||
}, {
|
||||
"val": "exit insert mode",
|
||||
"key": "Esc"
|
||||
}],
|
||||
"Cut and paste": [{
|
||||
"val": "yank (copy) a line",
|
||||
"key": "yy"
|
||||
}, {
|
||||
"val": "yank (copy) 2 lines",
|
||||
"key": "2yy"
|
||||
}, {
|
||||
"val": "yank (copy) word",
|
||||
"key": "yw"
|
||||
}, {
|
||||
"val": "yank (copy) to end of line",
|
||||
"key": "y$"
|
||||
}, {
|
||||
"val": "put (paste) the clipboard after cursor",
|
||||
"key": "p"
|
||||
}, {
|
||||
"val": "put (paste) before cursor",
|
||||
"key": "P"
|
||||
}, {
|
||||
"val": "delete (cut) a line",
|
||||
"key": "dd"
|
||||
}, {
|
||||
"val": "delete (cut) 2 lines",
|
||||
"key": "2dd"
|
||||
}, {
|
||||
"val": "delete (cut) word",
|
||||
"key": "dw"
|
||||
}, {
|
||||
"val": "delete (cut) to the end of the line",
|
||||
"key": "D"
|
||||
}, {
|
||||
"val": "delete (cut) to the end of the line",
|
||||
"key": "d$"
|
||||
}, {
|
||||
"val": "delete (cut) character",
|
||||
"key": "x"
|
||||
}],
|
||||
"Marking text (visual mode)": [{
|
||||
"val": "start visual mode, mark lines, then do a command (like y-yank)",
|
||||
"key": "v"
|
||||
}, {
|
||||
"val": "start linewise visual mode",
|
||||
"key": "V"
|
||||
}, {
|
||||
"val": "move to other end of marked area",
|
||||
"key": "o"
|
||||
}, {
|
||||
"val": "start visual block mode",
|
||||
"key": "Ctrl+v"
|
||||
}, {
|
||||
"val": "move to other corner of block",
|
||||
"key": "O"
|
||||
}, {
|
||||
"val": "mark a word",
|
||||
"key": "aw"
|
||||
}, {
|
||||
"val": "a block with ()",
|
||||
"key": "ab"
|
||||
}, {
|
||||
"val": "a block with {}",
|
||||
"key": "aB"
|
||||
}, {
|
||||
"val": "inner block with ()",
|
||||
"key": "ib"
|
||||
}, {
|
||||
"val": "inner block with {}",
|
||||
"key": "iB"
|
||||
}, {
|
||||
"val": "exit visual mode",
|
||||
"key": "Esc"
|
||||
}],
|
||||
"Working with multiple files": [{
|
||||
"val": "edit a file in a new buffer",
|
||||
"key": ":e filename"
|
||||
}, {
|
||||
"val": "go to the next buffer",
|
||||
"key": ":bnext/:bn"
|
||||
}, {
|
||||
"val": "go to the previous buffer",
|
||||
"key": ":bprev/:bp"
|
||||
}, {
|
||||
"val": "delete a buffer (close a file)",
|
||||
"key": ":bd"
|
||||
}, {
|
||||
"val": "open a file in a new buffer and split window",
|
||||
"key": ":sp filename"
|
||||
}, {
|
||||
"val": "open a file in a new buffer and vertically split window",
|
||||
"key": ":vsp filename"
|
||||
}, {
|
||||
"val": "split window",
|
||||
"key": "Ctrl+ws"
|
||||
}, {
|
||||
"val": "switch windows",
|
||||
"key": "Ctrl+ww"
|
||||
}, {
|
||||
"val": "quit a window",
|
||||
"key": "Ctrl+wq"
|
||||
}, {
|
||||
"val": "split window vertically",
|
||||
"key": "Ctrl+wv"
|
||||
}, {
|
||||
"val": "move cursor to next buffer (right)",
|
||||
"key": "Ctrl+wh"
|
||||
}, {
|
||||
"val": "move cursor to previous buffer (left)",
|
||||
"key": "Ctrl+wl"
|
||||
}],
|
||||
"Cursor movement": [{
|
||||
"val": "move cursor left",
|
||||
"key": "h"
|
||||
}, {
|
||||
"val": "move cursor down",
|
||||
"key": "j"
|
||||
}, {
|
||||
"val": "move cursor up",
|
||||
"key": "k"
|
||||
}, {
|
||||
"val": "move cursor right",
|
||||
"key": "l"
|
||||
}, {
|
||||
"val": "jump forwards to the start of a word",
|
||||
"key": "w"
|
||||
}, {
|
||||
"val": "jump forwards to the start of a word (words can contain punctuation)",
|
||||
"key": "W"
|
||||
}, {
|
||||
"val": "jump forwards to the end of a word",
|
||||
"key": "e"
|
||||
}, {
|
||||
"val": "jump forwards to the end of a word (words can contain punctuation)",
|
||||
"key": "E"
|
||||
}, {
|
||||
"val": "jump backwards to the start of a word",
|
||||
"key": "b"
|
||||
}, {
|
||||
"val": "jump backwards to the start of a word (words can contain punctuation)",
|
||||
"key": "B"
|
||||
}, {
|
||||
"val": "jump to the start of the line",
|
||||
"key": "0"
|
||||
}, {
|
||||
"val": "jump to the first non-blank character of the line",
|
||||
"key": "^"
|
||||
}, {
|
||||
"val": "jump to the end of the line",
|
||||
"key": "$"
|
||||
}, {
|
||||
"val": "go to the last line of the document",
|
||||
"key": "G"
|
||||
}, {
|
||||
"val": "go to line 5",
|
||||
"key": "5G"
|
||||
}, {
|
||||
"val": "To the position before the latest jump, or where the last \"m'\" or \"m`\" command was given.",
|
||||
"key": "''"
|
||||
}],
|
||||
"Visual commands": [{
|
||||
"val": "shift text right",
|
||||
"key": ">"
|
||||
}, {
|
||||
"val": "shift text left",
|
||||
"key": "<"
|
||||
}, {
|
||||
"val": "yank (copy) marked text",
|
||||
"key": "y"
|
||||
}, {
|
||||
"val": "delete marked text",
|
||||
"key": "d"
|
||||
}, {
|
||||
"val": "switch case",
|
||||
"key": "~"
|
||||
}],
|
||||
"Search and replace": [{
|
||||
"val": "search for pattern",
|
||||
"key": "/pattern"
|
||||
}, {
|
||||
"val": "search backward for pattern",
|
||||
"key": "?pattern"
|
||||
}, {
|
||||
"val": "repeat search in same direction",
|
||||
"key": "n"
|
||||
}, {
|
||||
"val": "repeat search in opposite direction",
|
||||
"key": "N"
|
||||
}, {
|
||||
"val": "replace all old with new throughout file",
|
||||
"key": ":%s/old/new/g"
|
||||
}, {
|
||||
"val": "replace all old with new throughout file with confirmations",
|
||||
"key": ":%s/old/new/gc"
|
||||
}]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
.zci--answer .zci--fenviewer a {
|
||||
color:#333;
|
||||
display:block;
|
||||
font-size:27px;
|
||||
height:40px;
|
||||
position:relative;
|
||||
text-decoration:none;
|
||||
width:40px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.zci--answer .zci--fenviewer .chess_board { border: 2px solid #333; }
|
||||
.zci--answer .zci--fenviewer .chess_board td {
|
||||
background:#fff;
|
||||
height:40px;
|
||||
text-align:center;
|
||||
vertical-align:middle;
|
||||
width:40px;
|
||||
}
|
||||
|
||||
.zci--answer .zci--fenviewer .chess_board tr:nth-child(odd) td:nth-child(even),
|
||||
.zci--answer .zci--fenviewer .chess_board tr:nth-child(even) td:nth-child(odd) {
|
||||
background-color: #ddd;
|
||||
}
|
|
@ -30,4 +30,6 @@ OpenDNS:
|
|||
ip4:
|
||||
- 208.67.222.222
|
||||
- 208.67.220.220
|
||||
ip6: []
|
||||
ip6:
|
||||
- 2620:0:ccc::2
|
||||
- 2620:0:ccd::2
|
||||
|
|
|
@ -704,6 +704,24 @@ ddg_goodie_test(
|
|||
result => qr/6,666/
|
||||
}
|
||||
),
|
||||
'(0.4e^(0))*cos(0)' => test_zci(
|
||||
'(0.4e ^ (0)) * cos(0) = 0.4',
|
||||
heading => 'Calculator',
|
||||
structured_answer => {
|
||||
input => ['(0.4e ^ (0)) * cos(0)'],
|
||||
operation => 'Calculate',
|
||||
result => qr'0.4'
|
||||
}
|
||||
),
|
||||
'2pi' => test_zci(
|
||||
'2 pi = 6.28318530717958',
|
||||
heading => 'Calculator',
|
||||
structured_answer => {
|
||||
input => ['2 pi'],
|
||||
operation => 'Calculate',
|
||||
result => qr"6.28318530717958"
|
||||
}
|
||||
),
|
||||
'123.123.123.123/255.255.255.255' => undef,
|
||||
'83.166.167.160/27' => undef,
|
||||
'9 + 0 x 07' => undef,
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More;
|
||||
use DDG::Test::Goodie;
|
||||
|
||||
zci answer_type => "fen_viewer";
|
||||
zci is_cached => 1;
|
||||
|
||||
ddg_goodie_test(
|
||||
[qw( DDG::Goodie::FenViewer )],
|
||||
'FEN rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1' => test_zci("rnbqkbnr\npppppppp\n - - - -\n- - - - \n - - - -\n- - - - \nPPPPPPPP\nRNBQKBNR", html => '<div class="zci--fenviewer"><table class="chess_board" cellpadding="0" cellspacing="0"><tr><td id="A8"><a href="#" class="black rook">♜</a></td><td id="B8"><a href="#" class="black knight">♞</a></td><td id="C8"><a href="#" class="black bishop">♝</a></td><td id="D8"><a href="#" class="black queen">♛</a></td><td id="E8"><a href="#" class="black king">♚</a></td><td id="F8"><a href="#" class="black bishop">♝</a></td><td id="G8"><a href="#" class="black knight">♞</a></td><td id="H8"><a href="#" class="black rook">♜</a></td></tr><tr><td id="A7"><a href="#" class="black pawn">♟</a></td><td id="B7"><a href="#" class="black pawn">♟</a></td><td id="C7"><a href="#" class="black pawn">♟</a></td><td id="D7"><a href="#" class="black pawn">♟</a></td><td id="E7"><a href="#" class="black pawn">♟</a></td><td id="F7"><a href="#" class="black pawn">♟</a></td><td id="G7"><a href="#" class="black pawn">♟</a></td><td id="H7"><a href="#" class="black pawn">♟</a></td></tr><tr><td id="A6"><a href="#" class="empty"></a></td><td id="B6"><a href="#" class="empty"></a></td><td id="C6"><a href="#" class="empty"></a></td><td id="D6"><a href="#" class="empty"></a></td><td id="E6"><a href="#" class="empty"></a></td><td id="F6"><a href="#" class="empty"></a></td><td id="G6"><a href="#" class="empty"></a></td><td id="H6"><a href="#" class="empty"></a></td></tr><tr><td id="A5"><a href="#" class="empty"></a></td><td id="B5"><a href="#" class="empty"></a></td><td id="C5"><a href="#" class="empty"></a></td><td id="D5"><a href="#" class="empty"></a></td><td id="E5"><a href="#" class="empty"></a></td><td id="F5"><a href="#" class="empty"></a></td><td id="G5"><a href="#" class="empty"></a></td><td id="H5"><a href="#" class="empty"></a></td></tr><tr><td id="A4"><a href="#" class="empty"></a></td><td id="B4"><a href="#" class="empty"></a></td><td id="C4"><a href="#" class="empty"></a></td><td id="D4"><a href="#" class="empty"></a></td><td id="E4"><a href="#" class="empty"></a></td><td id="F4"><a href="#" class="empty"></a></td><td id="G4"><a href="#" class="empty"></a></td><td id="H4"><a href="#" class="empty"></a></td></tr><tr><td id="A3"><a href="#" class="empty"></a></td><td id="B3"><a href="#" class="empty"></a></td><td id="C3"><a href="#" class="empty"></a></td><td id="D3"><a href="#" class="empty"></a></td><td id="E3"><a href="#" class="empty"></a></td><td id="F3"><a href="#" class="empty"></a></td><td id="G3"><a href="#" class="empty"></a></td><td id="H3"><a href="#" class="empty"></a></td></tr><tr><td id="A2"><a href="#" class="white pawn">♙</a></td><td id="B2"><a href="#" class="white pawn">♙</a></td><td id="C2"><a href="#" class="white pawn">♙</a></td><td id="D2"><a href="#" class="white pawn">♙</a></td><td id="E2"><a href="#" class="white pawn">♙</a></td><td id="F2"><a href="#" class="white pawn">♙</a></td><td id="G2"><a href="#" class="white pawn">♙</a></td><td id="H2"><a href="#" class="white pawn">♙</a></td></tr><tr><td id="A1"><a href="#" class="white rook">♖</a></td><td id="B1"><a href="#" class="white knight">♘</a></td><td id="C1"><a href="#" class="white bishop">♗</a></td><td id="D1"><a href="#" class="white queen">♕</a></td><td id="E1"><a href="#" class="white king">♔</a></td><td id="F1"><a href="#" class="white bishop">♗</a></td><td id="G1"><a href="#" class="white knight">♘</a></td><td id="H1"><a href="#" class="white rook">♖</a></td></tr></table></div>'),
|
||||
'fen rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1 ' => test_zci("rnbqkbnr\npppppppp\n - - - -\n- - - - \n - -P- -\n- - - - \nPPPP PPP\nRNBQKBNR", html => '<div class="zci--fenviewer"><table class="chess_board" cellpadding="0" cellspacing="0"><tr><td id="A8"><a href="#" class="black rook">♜</a></td><td id="B8"><a href="#" class="black knight">♞</a></td><td id="C8"><a href="#" class="black bishop">♝</a></td><td id="D8"><a href="#" class="black queen">♛</a></td><td id="E8"><a href="#" class="black king">♚</a></td><td id="F8"><a href="#" class="black bishop">♝</a></td><td id="G8"><a href="#" class="black knight">♞</a></td><td id="H8"><a href="#" class="black rook">♜</a></td></tr><tr><td id="A7"><a href="#" class="black pawn">♟</a></td><td id="B7"><a href="#" class="black pawn">♟</a></td><td id="C7"><a href="#" class="black pawn">♟</a></td><td id="D7"><a href="#" class="black pawn">♟</a></td><td id="E7"><a href="#" class="black pawn">♟</a></td><td id="F7"><a href="#" class="black pawn">♟</a></td><td id="G7"><a href="#" class="black pawn">♟</a></td><td id="H7"><a href="#" class="black pawn">♟</a></td></tr><tr><td id="A6"><a href="#" class="empty"></a></td><td id="B6"><a href="#" class="empty"></a></td><td id="C6"><a href="#" class="empty"></a></td><td id="D6"><a href="#" class="empty"></a></td><td id="E6"><a href="#" class="empty"></a></td><td id="F6"><a href="#" class="empty"></a></td><td id="G6"><a href="#" class="empty"></a></td><td id="H6"><a href="#" class="empty"></a></td></tr><tr><td id="A5"><a href="#" class="empty"></a></td><td id="B5"><a href="#" class="empty"></a></td><td id="C5"><a href="#" class="empty"></a></td><td id="D5"><a href="#" class="empty"></a></td><td id="E5"><a href="#" class="empty"></a></td><td id="F5"><a href="#" class="empty"></a></td><td id="G5"><a href="#" class="empty"></a></td><td id="H5"><a href="#" class="empty"></a></td></tr><tr><td id="A4"><a href="#" class="empty"></a></td><td id="B4"><a href="#" class="empty"></a></td><td id="C4"><a href="#" class="empty"></a></td><td id="D4"><a href="#" class="empty"></a></td><td id="E4"><a href="#" class="white pawn">♙</a></td><td id="F4"><a href="#" class="empty"></a></td><td id="G4"><a href="#" class="empty"></a></td><td id="H4"><a href="#" class="empty"></a></td></tr><tr><td id="A3"><a href="#" class="empty"></a></td><td id="B3"><a href="#" class="empty"></a></td><td id="C3"><a href="#" class="empty"></a></td><td id="D3"><a href="#" class="empty"></a></td><td id="E3"><a href="#" class="empty"></a></td><td id="F3"><a href="#" class="empty"></a></td><td id="G3"><a href="#" class="empty"></a></td><td id="H3"><a href="#" class="empty"></a></td></tr><tr><td id="A2"><a href="#" class="white pawn">♙</a></td><td id="B2"><a href="#" class="white pawn">♙</a></td><td id="C2"><a href="#" class="white pawn">♙</a></td><td id="D2"><a href="#" class="white pawn">♙</a></td><td id="E2"><a href="#" class="empty"></a></td><td id="F2"><a href="#" class="white pawn">♙</a></td><td id="G2"><a href="#" class="white pawn">♙</a></td><td id="H2"><a href="#" class="white pawn">♙</a></td></tr><tr><td id="A1"><a href="#" class="white rook">♖</a></td><td id="B1"><a href="#" class="white knight">♘</a></td><td id="C1"><a href="#" class="white bishop">♗</a></td><td id="D1"><a href="#" class="white queen">♕</a></td><td id="E1"><a href="#" class="white king">♔</a></td><td id="F1"><a href="#" class="white bishop">♗</a></td><td id="G1"><a href="#" class="white knight">♘</a></td><td id="H1"><a href="#" class="white rook">♖</a></td></tr></table></div>'),
|
||||
# Two examples from the last world championship
|
||||
'fen r1b1r1k1/2qn1ppp/1ppp4/p3p3/P2PP3/R4N1P/1PP2PP1/2BQR1K1 b - - 0 14 ' => test_zci("r-b-r-k-\n- qn-ppp\n ppp - -\np - p - \nP- PP- -\nR - -N-P\n PP- PP-\n- BQR K ", html => '<div class="zci--fenviewer"><table class="chess_board" cellpadding="0" cellspacing="0"><tr><td id="A8"><a href="#" class="black rook">♜</a></td><td id="B8"><a href="#" class="empty"></a></td><td id="C8"><a href="#" class="black bishop">♝</a></td><td id="D8"><a href="#" class="empty"></a></td><td id="E8"><a href="#" class="black rook">♜</a></td><td id="F8"><a href="#" class="empty"></a></td><td id="G8"><a href="#" class="black king">♚</a></td><td id="H8"><a href="#" class="empty"></a></td></tr><tr><td id="A7"><a href="#" class="empty"></a></td><td id="B7"><a href="#" class="empty"></a></td><td id="C7"><a href="#" class="black queen">♛</a></td><td id="D7"><a href="#" class="black knight">♞</a></td><td id="E7"><a href="#" class="empty"></a></td><td id="F7"><a href="#" class="black pawn">♟</a></td><td id="G7"><a href="#" class="black pawn">♟</a></td><td id="H7"><a href="#" class="black pawn">♟</a></td></tr><tr><td id="A6"><a href="#" class="empty"></a></td><td id="B6"><a href="#" class="black pawn">♟</a></td><td id="C6"><a href="#" class="black pawn">♟</a></td><td id="D6"><a href="#" class="black pawn">♟</a></td><td id="E6"><a href="#" class="empty"></a></td><td id="F6"><a href="#" class="empty"></a></td><td id="G6"><a href="#" class="empty"></a></td><td id="H6"><a href="#" class="empty"></a></td></tr><tr><td id="A5"><a href="#" class="black pawn">♟</a></td><td id="B5"><a href="#" class="empty"></a></td><td id="C5"><a href="#" class="empty"></a></td><td id="D5"><a href="#" class="empty"></a></td><td id="E5"><a href="#" class="black pawn">♟</a></td><td id="F5"><a href="#" class="empty"></a></td><td id="G5"><a href="#" class="empty"></a></td><td id="H5"><a href="#" class="empty"></a></td></tr><tr><td id="A4"><a href="#" class="white pawn">♙</a></td><td id="B4"><a href="#" class="empty"></a></td><td id="C4"><a href="#" class="empty"></a></td><td id="D4"><a href="#" class="white pawn">♙</a></td><td id="E4"><a href="#" class="white pawn">♙</a></td><td id="F4"><a href="#" class="empty"></a></td><td id="G4"><a href="#" class="empty"></a></td><td id="H4"><a href="#" class="empty"></a></td></tr><tr><td id="A3"><a href="#" class="white rook">♖</a></td><td id="B3"><a href="#" class="empty"></a></td><td id="C3"><a href="#" class="empty"></a></td><td id="D3"><a href="#" class="empty"></a></td><td id="E3"><a href="#" class="empty"></a></td><td id="F3"><a href="#" class="white knight">♘</a></td><td id="G3"><a href="#" class="empty"></a></td><td id="H3"><a href="#" class="white pawn">♙</a></td></tr><tr><td id="A2"><a href="#" class="empty"></a></td><td id="B2"><a href="#" class="white pawn">♙</a></td><td id="C2"><a href="#" class="white pawn">♙</a></td><td id="D2"><a href="#" class="empty"></a></td><td id="E2"><a href="#" class="empty"></a></td><td id="F2"><a href="#" class="white pawn">♙</a></td><td id="G2"><a href="#" class="white pawn">♙</a></td><td id="H2"><a href="#" class="empty"></a></td></tr><tr><td id="A1"><a href="#" class="empty"></a></td><td id="B1"><a href="#" class="empty"></a></td><td id="C1"><a href="#" class="white bishop">♗</a></td><td id="D1"><a href="#" class="white queen">♕</a></td><td id="E1"><a href="#" class="white rook">♖</a></td><td id="F1"><a href="#" class="empty"></a></td><td id="G1"><a href="#" class="white king">♔</a></td><td id="H1"><a href="#" class="empty"></a></td></tr></table></div>'),
|
||||
'fen 5rk1/4R1p1/3q1p2/p1p2P1p/P3Q2P/5pP1/2P2P1K/8 w - - 0 35' => test_zci(" - - rk-\n- - R p \n - q p -\np p -P-p\nP- -Q- P\n- - -pP \n -P- P K\n- - - - ", html => '<div class="zci--fenviewer"><table class="chess_board" cellpadding="0" cellspacing="0"><tr><td id="A8"><a href="#" class="empty"></a></td><td id="B8"><a href="#" class="empty"></a></td><td id="C8"><a href="#" class="empty"></a></td><td id="D8"><a href="#" class="empty"></a></td><td id="E8"><a href="#" class="empty"></a></td><td id="F8"><a href="#" class="black rook">♜</a></td><td id="G8"><a href="#" class="black king">♚</a></td><td id="H8"><a href="#" class="empty"></a></td></tr><tr><td id="A7"><a href="#" class="empty"></a></td><td id="B7"><a href="#" class="empty"></a></td><td id="C7"><a href="#" class="empty"></a></td><td id="D7"><a href="#" class="empty"></a></td><td id="E7"><a href="#" class="white rook">♖</a></td><td id="F7"><a href="#" class="empty"></a></td><td id="G7"><a href="#" class="black pawn">♟</a></td><td id="H7"><a href="#" class="empty"></a></td></tr><tr><td id="A6"><a href="#" class="empty"></a></td><td id="B6"><a href="#" class="empty"></a></td><td id="C6"><a href="#" class="empty"></a></td><td id="D6"><a href="#" class="black queen">♛</a></td><td id="E6"><a href="#" class="empty"></a></td><td id="F6"><a href="#" class="black pawn">♟</a></td><td id="G6"><a href="#" class="empty"></a></td><td id="H6"><a href="#" class="empty"></a></td></tr><tr><td id="A5"><a href="#" class="black pawn">♟</a></td><td id="B5"><a href="#" class="empty"></a></td><td id="C5"><a href="#" class="black pawn">♟</a></td><td id="D5"><a href="#" class="empty"></a></td><td id="E5"><a href="#" class="empty"></a></td><td id="F5"><a href="#" class="white pawn">♙</a></td><td id="G5"><a href="#" class="empty"></a></td><td id="H5"><a href="#" class="black pawn">♟</a></td></tr><tr><td id="A4"><a href="#" class="white pawn">♙</a></td><td id="B4"><a href="#" class="empty"></a></td><td id="C4"><a href="#" class="empty"></a></td><td id="D4"><a href="#" class="empty"></a></td><td id="E4"><a href="#" class="white queen">♕</a></td><td id="F4"><a href="#" class="empty"></a></td><td id="G4"><a href="#" class="empty"></a></td><td id="H4"><a href="#" class="white pawn">♙</a></td></tr><tr><td id="A3"><a href="#" class="empty"></a></td><td id="B3"><a href="#" class="empty"></a></td><td id="C3"><a href="#" class="empty"></a></td><td id="D3"><a href="#" class="empty"></a></td><td id="E3"><a href="#" class="empty"></a></td><td id="F3"><a href="#" class="black pawn">♟</a></td><td id="G3"><a href="#" class="white pawn">♙</a></td><td id="H3"><a href="#" class="empty"></a></td></tr><tr><td id="A2"><a href="#" class="empty"></a></td><td id="B2"><a href="#" class="empty"></a></td><td id="C2"><a href="#" class="white pawn">♙</a></td><td id="D2"><a href="#" class="empty"></a></td><td id="E2"><a href="#" class="empty"></a></td><td id="F2"><a href="#" class="white pawn">♙</a></td><td id="G2"><a href="#" class="empty"></a></td><td id="H2"><a href="#" class="white king">♔</a></td></tr><tr><td id="A1"><a href="#" class="empty"></a></td><td id="B1"><a href="#" class="empty"></a></td><td id="C1"><a href="#" class="empty"></a></td><td id="D1"><a href="#" class="empty"></a></td><td id="E1"><a href="#" class="empty"></a></td><td id="F1"><a href="#" class="empty"></a></td><td id="G1"><a href="#" class="empty"></a></td><td id="H1"><a href="#" class="empty"></a></td></tr></table></div>'),
|
||||
'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1' => undef,
|
||||
'fen' => undef,
|
||||
'fen ' => undef,
|
||||
);
|
||||
|
||||
done_testing;
|
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More;
|
||||
use DDG::Test::Goodie;
|
||||
|
||||
zci answer_type => "is_awesome_kleinjoshuaa";
|
||||
zci is_cached => 1;
|
||||
|
||||
ddg_goodie_test(
|
||||
[qw( DDG::Goodie::IsAwesome::kleinjoshuaa )],
|
||||
'duckduckhack kleinjoshuaa' => test_zci('kleinjoshuaa is awesome and has successfully completed the duckduckhack goodie tutorial!'),
|
||||
'duckduckhack kleinjoshuaa is awesome' => undef,
|
||||
|
||||
);
|
||||
|
||||
done_testing;
|
|
@ -0,0 +1,17 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More;
|
||||
use DDG::Test::Goodie;
|
||||
|
||||
zci answer_type => "is_awesome_ngzhian";
|
||||
zci is_cached => 1;
|
||||
|
||||
ddg_goodie_test(
|
||||
[qw( DDG::Goodie::IsAwesome::ngzhian )],
|
||||
'duckduckhack ngzhian' => test_zci('ngzhian is awesome and has successfully completed the DuckDuckHack Goodie tutorial!'),
|
||||
'duckduckhack ngzhian is awesome' => undef,
|
||||
);
|
||||
|
||||
done_testing;
|
|
@ -0,0 +1,19 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More;
|
||||
use DDG::Test::Goodie;
|
||||
|
||||
zci answer_type => "is_awesome_organiker";
|
||||
zci is_cached => 1;
|
||||
|
||||
ddg_goodie_test(
|
||||
[qw(
|
||||
DDG::Goodie::IsAwesome::organiker
|
||||
)],
|
||||
'duckduckhack organiker' => test_zci('organiker is awesome and has successfully completed the DuckDuckHack Goodie tutorial!'),
|
||||
'duckduckhack organiker is awesome' => undef,
|
||||
);
|
||||
|
||||
done_testing;
|
|
@ -0,0 +1,19 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More;
|
||||
use DDG::Test::Goodie;
|
||||
|
||||
zci answer_type => "is_awesome_rramyr";
|
||||
zci is_cached => 1;
|
||||
|
||||
ddg_goodie_test(
|
||||
[qw(
|
||||
DDG::Goodie::IsAwesome::rramyr
|
||||
)],
|
||||
'duckduckhack rramyr' => test_zci('rramyr is awesome and has successfully completed the DuckDuckHack Goodie tutorial!'),
|
||||
'duckduckhack rramyr is awesome' => undef,
|
||||
);
|
||||
|
||||
done_testing;
|
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More;
|
||||
use DDG::Test::Goodie;
|
||||
|
||||
zci answer_type => "rc4";
|
||||
zci is_cached => 1;
|
||||
|
||||
ddg_goodie_test(
|
||||
[qw(
|
||||
DDG::Goodie::Rc4
|
||||
)],
|
||||
'rc4 en mysecretkey hello' => test_zci("RC4 Encrypt: hello, with key: mysecretkey is grYU1K8=",
|
||||
structured_answer => {
|
||||
input => ['hello, Key: mysecretkey'],
|
||||
operation => "RC4 Encrypt",
|
||||
result => "grYU1K8="
|
||||
}),
|
||||
'rc4 de duck yWrJniG/nNg=' => test_zci("RC4 Decrypt: yWrJniG/nNg=, with key: duck is DdgRocks",
|
||||
structured_answer => {
|
||||
input => ['yWrJniG/nNg=, Key: duck'],
|
||||
operation => "RC4 Decrypt",
|
||||
result => "DdgRocks"
|
||||
}),
|
||||
'rc4 ' => undef,
|
||||
'rc4 enc missing' => undef,
|
||||
'rc4 no operation' => undef
|
||||
);
|
||||
|
||||
done_testing;
|
Loading…
Reference in New Issue