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
from collections import Counter | |
import itertools | |
lines = '''스윕 이그나이트 이럽션 | |
이그나이트 이프리트 리젼 | |
이럽션 이그나이트 이프리트 | |
이그나이트 스윕 이럽션 | |
이그나이트 스윕 이프리트 | |
이그나이트 리젼 이럽션 | |
이그나이트 이럽션 이프리트 |
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 FileBackedCircularBuffer: | |
def __init__(self, cls, maxlen): | |
f = tempfile.TemporaryFile() | |
filesize = maxlen * cls.format.size | |
f.truncate(filesize) | |
self.buffer = mmap.mmap(f.fileno(), filesize) | |
self.cls = cls | |
self.maxlen = maxlen | |
self.start_index = 0 # inclusive | |
self.end_index = 0 # exclusive |
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 | |
set -ex | |
# Do argument checks | |
if [ ! "$#" -ge 1 ]; then | |
echo "Usage: $0 {ip_addr}" | |
exit 1 | |
fi | |
IP_ADDRESS=$1 |
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 | |
snap install microk8s --classic |
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/sh | |
# Do argument checks | |
if [ ! "$#" -ge 1 ]; then | |
echo "Usage: $0 {size}" | |
echo "Example: $0 4G" | |
echo "Usage: $0 {size} {swappiness}" | |
exit 1 | |
fi |
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
''' | |
Use the IP_BOUND_IF socket option to bind to a specific network interface on macOS. | |
''' | |
import socket | |
IP_BOUND_IF = 25 | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.setsockopt(socket.IPPROTO_IP, IP_BOUND_IF, socket.if_nametoindex('en0')) |
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
import torch | |
def calculate_loss(x, y): | |
clip_range = 100. | |
clipped = y + (x - y).clamp(-clip_range, clip_range) | |
l_vf = 0.5 * torch.max((clipped - y) ** 2, (x - y) ** 2).mean() | |
return l_vf | |
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
from collections import defaultdict | |
metrics = defaultdict(float) | |
num_metrics = 0 | |
# training loop | |
for xs, ys in training_dataloader: | |
batch_size = xs.size(0) | |
loss = criterion(...) | |
metrics['loss'] += float(loss) * batch_size | |
num_metrics += batch_size |
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
-----BEGIN CERTIFICATE----- | |
MIIDJjCCAo+gAwIBAgIBATANBgkqhkiG9w0BAQQFADCBkDELMAkGA1UEBhMCS08x | |
DjAMBgNVBAgTBVN0YXRlMQ4wDAYDVQQHEwVTZW91bDEMMAoGA1UEChMDVUxDMQww | |
CgYDVQQLEwNSbkQxGzAZBgNVBAMTEk5lc3BvdFNlcnZlclJvb3RDYTEoMCYGCSqG | |
SIb3DQEJARYZTmVzcG90U2VydmVyUm9vdENhQGt0LmNvbTAeFw0xNzA0MTEwOTA0 | |
NTZaFw0yNzA0MDkwOTA0NTZaMIGMMQswCQYDVQQGEwJLTzEOMAwGA1UECBMFU3Rh | |
dGUxDjAMBgNVBAcTBVNlb3VsMQwwCgYDVQQKEwNVTEMxDDAKBgNVBAsTA1JuRDEX | |
MBUGA1UEAxQOTkVTUE9UX0FBQUNlcnQxKDAmBgkqhkiG9w0BCQEWGU5lc3BvdFNl | |
cnZlclJvb3RDYUBrdC5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBANOF | |
bvn37Kx3IPyD+NFUHc9yirHNWGa6odOGFc95E+55neQ2fcu+DoGgyB0fhyl3uroT |
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
import tensorflow as tf | |
import random | |
W = tf.get_variable('W', shape=[1, 4]) | |
ph_y = tf.placeholder(tf.int32, [1]) # labels | |
prob = tf.nn.softmax(W) | |
loss = tf.reduce_mean( |
NewerOlder