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 left_right_image(left_img_path,right_img_path, canvas_size = 500): | |
# load image | |
iml = Image.open(left_img_path) | |
imr = Image.open(right_img_path) | |
# make back ground | |
bg = Image.new("RGB",(canvas_size,canvas_size),(250,250,250)) | |
# target position | |
left_target = int(bg.size[0] / 4 * 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
def make_mask(size,start_width,start_height,end_width,end_height): | |
mask = Image.new("L",(size,size),0) | |
draw = ImageDraw.Draw(mask) | |
draw.rectangle((start_width,start_height,end_width,end_height), fill=255) | |
print('mask',mask.size) | |
return mask |
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 PIL import Image | |
def to_RGB(image:Image)->Image: | |
if image.mode == 'RGB':return image | |
image.load() # required for png.split() | |
background = Image.new("RGB", image.size, (255, 255, 255)) | |
background.paste(image, mask=image.split()[3]) # 3 is the alpha channel | |
file_name = 'tmp.jpg' | |
background.save(file_name, 'JPEG', quality=80) |
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 resize_img_to_target(img,space): | |
short ,long = img.size | |
if short < long: | |
rate = space / short | |
resize_height = long * rate | |
reisze_width = space | |
else: | |
rate = space / long | |
reisze_width = short * rate | |
resize_height = space |
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 selenium import webdriver | |
from selenium.webdriver.chrome.options import Options | |
opts = Options() | |
opts.headless = True | |
browser = webdriver.Chrome(chrome_options=opts) | |
browser.get('http://yahoo.co.jp') | |
print(browser.title) | |
print(browser.find_element_by_css_selector("p").text) |
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 java.io.BufferedOutputStream; | |
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStreamReader; | |
import java.io.OutputStreamWriter; | |
import java.net.HttpURLConnection; | |
import java.net.URL; | |
public class HttpSendJSON { |
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
osascript -e 'quit app "Docker"' | |
open -a Docker |
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 logging | |
import sys | |
# setting file log | |
logging.basicConfig(filename='/tmp/debug.log',filemode='w',level=logging.DEBUG,format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') | |
# setting console log | |
root = logging.getLogger() | |
root.setLevel(logging.DEBUG) |
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 | |
open https://www.google.com/chrome/ | |
open https://www.eclipse.org/downloads/ | |
open https://simplenote.com/ | |
open https://www.sourcetreeapp.com/ | |
open https://www.jetbrains.com/pycharm/download/ | |
open https://code.visualstudio.com/ | |
open https://sequelpro.com/ | |
open https://filezilla-project.org/ | |
open https://hackjutsu.com/Lepton/ |
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
# INSTALLED_APPS に 'storages' を追加 | |
INSTALLED_APPS = [ | |
# your apps | |
'storages', | |
] | |
# settings.pyの下の方に追加 | |
# GoogleCloudStorage settings |