Skip to content

Instantly share code, notes, and snippets.

View WangYihang's full-sized avatar
🎯
Focusing

Yihang Wang WangYihang

🎯
Focusing
View GitHub Profile
@WangYihang
WangYihang / Disk-Scheduling-Algorithms.py
Created August 20, 2019 08:20
Simple Implementation of Disk Scheduling Algorithms including FCFS, SSTF, LOOK, CLOOK and so on.
#!/usr/bin/env python
# encoding:utf-8
def FCFS(cylinders, head, requests):
return requests
def SSTF(cylinders, head, requests):
req = []
h = head
for i in range(len(requests)):
#!/usr/bin/env python
# coding:utf-8
import time
import graphviz
class Tape(object):
def __init__(self, tape_string="", blank_symbol="B"):
self.blank_symbol = blank_symbol
#include <sys/syscall.h>
#define STRING "/bin/sh"
#define STRLEN 7
#define ARGV (STRLEN+1)
#define ENVP (ARGV+4)
#define FD $0x03
.globl main
.type main, @function
#!/usr/bin/env python
# encoding:utf-8
import hmac
import pickle
import base64
class Student:
def __init__(self, name, age):
self.name = name
#!/usr/bin/env python
# encoding: utf-8
from z3 import *
'''
> https://zhuanlan.zhihu.com/p/30548907
I forgot my flag & key. Help me recover them.
5616f5962674d26741d2810600a6c5647620c4e3d2870177f09716b2379012c342d3b584c5672195d653722443f1c39254360007010381b721c741a532b03504d2849382d375c0d6806251a2946335a67365020100f160f17640c6a05583f49645d3b557856221b2
from PIL import Image
from glob import glob
import os
image_names = glob("*.jpg")
pdf = "%s.pdf" % os.path.basename(os.getcwd())
images = [Image.open(i) for i in image_names]
images[0].save(pdf, save_all=True, append_images=images[1:])
@WangYihang
WangYihang / scanner.py
Last active November 28, 2021 03:20
白的更白,黑的更黑
#!/usr/bin/env python
from PIL import Image, ImageEnhance
import glob
def handle(im):
width = im.size[0]
height = im.size[1]
print(height, width)
for x in range(height):
from PIL import Image
import glob
folders = [
"images/*",
]
files = []
suffix = ""
from PIL import Image
'''
Black (0,0,0,1) (0,0,0) #000000
White (0,0,0,0) (255,255,255) #FFFFFF
Red (0,1,1,0) (255,0,0) #FF0000
Green (1,0,1,0) (0,255,0) #00FF00
Blue (1,1,0,0) (0,0,255) #0000FF
Yellow (0,0,1,0) (255,255,0) #FFFF00
Cyan (1,0,0,0) (0,255,255) #00FFFF
from PIL import Image
'''
Black (0,0,0,1) (0,0,0) #000000
White (0,0,0,0) (255,255,255) #FFFFFF
Red (0,1,1,0) (255,0,0) #FF0000
Green (1,0,1,0) (0,255,0) #00FF00
Blue (1,1,0,0) (0,0,255) #0000FF
Yellow (0,0,1,0) (255,255,0) #FFFF00
Cyan (1,0,0,0) (0,255,255) #00FFFF