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
(defun my-open-new-memo () | |
(interactive) | |
(let ((my-regexp "\\([0-9]+\\)[.]memo") | |
(my-max 1) | |
(my-matched-num 0) | |
(file-list (directory-files "~/.emacs.d/memo/"))) | |
(dolist (i file-list) | |
(setq my-matched-num (string-to-number (replace-regexp-in-string my-regexp "\\1" i))) | |
(if (< my-max my-matched-num) | |
(setq my-max my-matched-num))) |
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
<html> | |
<head> | |
<meta http-equiv="content-type" content="text/html;charset=utf-8"> | |
<script type="text/javascript"> | |
var globalTestItemNo = 1; | |
var TESTITEMNUM; | |
var DIVIDEDIMGNUM; | |
function globalTestItemNo2testName(globalTestItemNo){ |
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 image to numpy array | |
im = array(Image.open('./data/empire.jpg')) #return numpy array | |
# show | |
imshow(im, interpolation='nearest')#or interpolation='None' | |
# star point | |
x = [100,100,400,400] | |
y = [200,500,200,500] |
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 | |
pil_im = Image.open('./data/empire.jpg').convert('L') | |
#rotate clockwise | |
out = pil_im.rotate(45) | |
#show | |
out.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 | |
pil_im = Image.open('./data/empire.jpg').convert('L') | |
#be careful it may change aspect ratio | |
out = pil_im.resize((128,128)) | |
#show | |
out.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
#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
#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
#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)"); |