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 asyncio, socket | |
async def handle_client(reader, writer): | |
request = None | |
while request != 'quit': | |
request = (await reader.read(255)).decode('utf8') | |
response = str(eval(request)) + '\n' | |
writer.write(response.encode('utf8')) | |
await writer.drain() | |
writer.close() |
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
#!/usr/bin/env python3.4 | |
import asyncio | |
class EchoServer(asyncio.Protocol): | |
def connection_made(self, transport): | |
peername = transport.get_extra_info('peername') | |
print('connection from {}'.format(peername)) | |
self.transport = transport | |
def data_received(self, data): |
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
#!/usr/bin/env python3.4 | |
import asyncio | |
class EchoClient(asyncio.Protocol): | |
message = 'Client Echo' | |
def connection_made(self, transport): | |
transport.write(self.message.encode()) | |
print('data sent: {}'.format(self.message)) |
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
# alacritty | |
env: | |
TERM: xterm-256color | |
window: | |
dimensions: | |
columns: 120 | |
lines: 48 | |
padding: | |
x: 10 |
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
# ~/.config/starship.toml | |
add_newline = false | |
[line_break] | |
disabled = true | |
[username] | |
format = "[$user]($style)" | |
style_user = "bold bright blue" | |
show_always = true |
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
# convert all downloaded media to mp3 | |
# rename all converted files to remove {webm,mkv,mp4} from filenames | |
# echo file conversion list | |
# then delete everything but the newly converted mp3 | |
echo "starting up, get list of files, please be patient..." | |
ls | echo "Found $(wc -l) media files for conversion in the present working directory." | xargs | |
echo "starting mp3 conversion with ffmpeg and libmp3lame." | |
for i in *.{webm,mkv,mp4}; do | |
ffmpeg -i "$i" -acodec libmp3lame "$(basename "${i/.{webm,mkv,mp4}")".mp3 |
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 django.urls import path | |
from django.conf.urls import include | |
from django.conf import settings | |
from django.contrib import admin | |
from rest_framework_swagger.views import get_swagger_view | |
from .views import api_root | |
schema_view = get_swagger_view(title='DRF by Example') | |
# url list |
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
#!/usr/bin/python | |
import argparse | |
import csv | |
import json | |
import os | |
import requests | |
import sys | |
from requests.auth import HTTPBasicAuth | |
from urllib.parse import urlparse |
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 os | |
import time | |
import uuid | |
import random | |
from datetime import datetime, timedelta | |
def get_message(): | |
return uuid.uuid4() |
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 os | |
import hashlib | |
def sha256sum(filename): | |
""" | |
Create a file hash | |
:param: str (file path) | |
:return: str (md5 hash) | |
""" | |
h = hashlib.sha256() |