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://tonak-ai.hatenablog.com/entry/2019/03/26/124537 | |
| import torch | |
| import torch.nn as nn | |
| from torch import optim | |
| import torch.nn.functional as F | |
| from torch.autograd import Variable | |
| device = torch.device("cuda" if torch.cuda.is_available() else "cpu") | |
| n_vocab = 3 |
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 torch | |
| import torch.nn as nn | |
| device = torch.device("cuda" if torch.cuda.is_available() else "cpu") | |
| n_vocab = 3 | |
| n_layers = 1 | |
| n_embed = 5 | |
| def padding_test(x_padding): | |
| embedding = nn.Embedding(n_vocab, n_embed, padding_idx=x_padding) | |
| inputs = [[1,1,2,1,1,2,1],[1,1,2]] |
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
| def skipfalse(iterable): | |
| for elem in iterable: | |
| if elem: | |
| yield elem | |
| foo=['abc', False, 'de'] | |
| print(skipfalse(foo)) | |
| print(list(skipfalse(foo))) | |
| # filter() と lambda を使うと上記コードと同じことができる. |
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/python3 | |
| import regex as re | |
| import sys | |
| import io | |
| sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') | |
| re_quantity = re.compile(r""" | |
| ((?:各|お?好みで|あれば|約|軽く)? |
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/python3 | |
| # The alternative script of "cat files|sort|uniq -c|sort -r -n". | |
| import marisa | |
| import sys | |
| import io | |
| sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') |
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
| --- webconsole.php~ | |
| +++ webconsole.php | |
| @@ -561,12 +561,27 @@ | |
| 2 => array('pipe', 'w') // STDERR | |
| ); | |
| - $process = proc_open($command . ' 2>&1', $descriptors, $pipes); | |
| + $process = proc_open(escapeshellcmd($command), $descriptors, $pipes); | |
| if (!is_resource($process)) die("Can't execute command."); | |
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/perl | |
| use strict; | |
| &main(); | |
| sub main { | |
| open( my $ph, 'dpkg --status |' ) or die; | |
| my %package; | |
| my %depended; |
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/perl | |
| =head1 NAME | |
| ldap-health-check | |
| =head1 INSTALL | |
| First, put this script into /usr/local/bin/ and make it executable. |
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/perl | |
| =head1 NAME | |
| postfix_incoming_mailstats - Plugin to monitor the number of mails | |
| received by postfix | |
| =head1 DEFAULT CONFIGURATION | |
| [postfix_incoming_mailstats] |
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
| auto lo | |
| iface lo inet loopback | |
| # The 1st network of this host is 192.0.2.0/24. | |
| # This host mainly uses the 1st network to communicate the Internet. | |
| allow-hotplug eth0 | |
| iface eth0 inet static | |
| address 192.0.2.30 | |
| netmask 255.255.255.0 | |
| network 192.0.2.0 |