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
#crop and paste image | |
from PIL import Image | |
pil_im = Image.open('./data/empire.jpg').convert('L') | |
#cropping | |
box = (100,100,400,400)#cropping region | |
region = pil_im.crop(box) | |
#pasting |
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
#change image to thumbnail | |
#but not change width and height aspect ratio | |
#read image and convert grayscal | |
from PIL import Image | |
pil_im = Image.open('./data/empire.jpg').convert('L') | |
pil_im.thumbnail((200,200)) | |
pil_im.show() |
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
#read image and convert grayscal | |
from PIL import Image | |
pil_im = Image.open('./data/empire.jpg').convert('L') | |
pil_im.show() |
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 | |
import os | |
filelist = ['foo.jpg', 'bar.bmp', 'zot.png'] | |
for infile in filelist: | |
outfile = os.path.splitext(infile)[0] + ".jpg" | |
if infile != outfile: | |
try: | |
Image.open(infile).save(outfile) | |
except IOError: |
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
[js] | |
//Be careful. It seems completely emulate key press. | |
//You need Execel app to run this code. | |
var shellApp = new ActiveXObject("Wscript.Shell"); | |
var ex = WScript.CreateObject("Excel.Application"); | |
shellApp.appActivate("C:\\Windows\\system32\\cmd.exe") | |
ex.ExecuteExcel4Macro("CALL(\"user32\",\"keybd_event\",\"JJJJJ\",164,56,1,0)"); | |
ex.ExecuteExcel4Macro("CALL(\"user32\",\"keybd_event\",\"JJJJJ\",32,57,1,0)"); | |
ex.ExecuteExcel4Macro("CALL(\"user32\",\"keybd_event\",\"JJJJJ\",32,57,3,0)"); | |
ex.ExecuteExcel4Macro("CALL(\"user32\",\"keybd_event\",\"JJJJJ\",164,56,3,0)"); |
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
(eval-after-load 'dired | |
'(progn | |
(define-key dired-mode-map (kbd "c") 'my-dired-create-file) | |
(defun create-new-file (file-list) | |
(defun exsitp-untitled-x (file-list cnt) | |
(while (and (car file-list) (not (string= (car file-list) (concat "untitled" (number-to-string cnt) ".txt")))) | |
(setq file-list (cdr file-list))) | |
(car file-list)) | |
(defun exsitp-untitled (file-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
# -*- coding: utf-8 -*- | |
import os | |
import re | |
import editor | |
import console | |
home_dir = os.path.dirname(__file__) | |
current_dir = os.path.dirname(editor.get_path()) | |
current_dir = os.path.relpath(current_dir, home_dir) |
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
# -*- coding: utf-8 -*- | |
import os | |
import sys | |
import re | |
import console | |
import editor | |
from datetime import datetime | |
INTERRUPT_TIME = 5 |
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
# -*- coding: utf-8 -*- | |
import editor | |
import console | |
def main(): | |
text = editor.get_text().decode('utf-8') | |
s,e = editor.get_selection() | |
srow, scol = get_row_col(s,text) | |
erow, ecol = get_row_col(e,text) | |
if scol == ecol: |
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 | |
import os | |
from pprint import pprint | |
def __init__(): | |
cudirlist = os.listdir('.') | |
pprint(cudirlist) | |
print( | |
'abcd' |