View zig.py
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
url = 'https://ziglang.org/download/0.10.1/zig-linux-x86_64-0.10.1.tar.xz' | |
!curl $url | tar xJ | |
!mv zig-linux-x86_64-0.10.1 /opt/bin | |
%%file main.zig | |
const std = @import("std"); | |
pub fn main() void { | |
std.debug.print("Hello world\n", .{}); | |
} |
View table.txt
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
| | | | | | | |
|---|---|---|---|---| | |
| | | | | | | |
| | | | | | | |
| | | | | | |
View strip_context.py
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
def context(line, word, padding=40): | |
# หาคำแรก แล้ว pre-40, หาคำสุดท้าย post+40 เอาง่ายๆ แบบนี้ล่ะ | |
p1 = line.index(word) | |
p1s = line.rfind(' ', 0, max(0, p1-padding)) | |
if p1s==-1: | |
p1s = 0 | |
p2 = line.rindex(word) | |
p2s = line.find(' ', min(len(line), p2+padding)) | |
if p2s == -1: | |
p2s = len(line) |
View docx_lines.py
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 pathlib import Path | |
!pip -q install python-docx | |
from docx import Document | |
files = list(Path('docx').glob('*.docx')) | |
def docx_lines(path): | |
doc = Document(path) | |
lines = [] | |
for para in doc.paragraphs: |
View s3.txt
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
# bucket: dham | |
# path: /first.wav | |
https://dham.s3.amazonaws.com/first.wav | |
# longer URL with region | |
https://dham.s3.us-west-2.amazonaws.com/first.wav |
View transcribe_status.py
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 boto3 | |
tran = boto3.client('transcribe') | |
def check_jobs(in_name): | |
jobs = [] | |
resp = tran.list_transcription_jobs(JobNameContains=in_name) | |
while True: | |
jobs += resp['TranscriptionJobSummaries'] | |
next_token = resp.get('NextToken') |
View remove.sh
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
jupyter kernelspec remove ir -f |
View clear.py
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 google.colab import output | |
output.clear() | |
# IPython also has clear_output() but this is shorter. |
View u16.py
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 io | |
text = io.open('aa1.txt', encoding='utf-16-le').read() |
View natsort.py
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 re | |
convert = lambda text: int(text) if text.isdigit() else text.lower() | |
alphanum = lambda key: [convert(c) for c in re.split('([0-9]+)', key)] | |
sorted(items, key=alphanum) | |
# another solution | |
natsort = lambda s: [int(t) if t.isdigit() else t.lower() for t in re.split('(\d+)', s)] | |
sorted(items, key=natsort) |
NewerOlder