Skip to content

Instantly share code, notes, and snippets.

View Insert_string.py
# -*- 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:
View a.py
import re
import os
from pprint import pprint
def __init__():
cudirlist = os.listdir('.')
pprint(cudirlist)
print(
'abcd'
View Delete_rect.py
# -*- 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:
View Grep.py
# -*- coding: utf-8 -*-
import os
import sys
import re
import console
import editor
from datetime import datetime
INTERRUPT_TIME = 5
View Find.py
# -*- 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)
View create_new_file_from_dired_mode
(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)
View pasteInCommandPrompt.js
[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)");
View cvSave.py
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:
View cvReadImage.py
#read image and convert grayscal
from PIL import Image
pil_im = Image.open('./data/empire.jpg').convert('L')
pil_im.show()
View cvCropPaste.py
#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
You can’t perform that action at this time.