Skip to content

Instantly share code, notes, and snippets.

@moluapple
moluapple / cooldtpNewPostsChecker.py
Created August 25, 2012 15:14
[Python2]使用 mechanize 登录网站演示
#!/usr/bin/python
# -*- coding:utf-8 -*-
import mechanize
def check_new_posts(username, password):
b = mechanize.Browser()
b._factory.encoding = "utf8"
b.set_handle_robots(False)
b.addheaders = [('User-Agent','Mozilla/4.0(compatible; MSIE 6.0; Windows 98;)')]
@moluapple
moluapple / A realworld example.jsx
Created August 11, 2012 06:42
[Illustrator] Relaunch AI to aviod "PARM" error
// Origin discussion: http://forums.adobe.com/message/4613051
#target "estoolkit"
rasterizeFolder();
/********************************************************************************************/
function rasterizeFolder() {
//Get the source and destination folders.
//If either window is cancelled, end the script.
@moluapple
moluapple / gist:3263337
Created August 5, 2012 09:27
[Indesign] get a paragraph's index within it's parent textframe
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function (item, i) {
i || (i = 0);
var length = this.length;
if (i < 0) i = length + i;
for (; i < length; i++)
if (this[i] === item) return i;
return -1;
}
}
@moluapple
moluapple / AlignCellsbyDecimalPoint.jsx
Created July 11, 2012 07:47
[Indesign] 单元格小数点居中对齐
/***************************************************
* 确保单元格文本对齐方式为左对齐,通过以下方式选择需要对其的单元格:
* 1. 仅选中首行数据列(也即非表头及文字列)单元格运行,将自动对齐直至末行的所有数据
* 2. 直接选中所有单元格(如2行2列至100行5列)运行,对齐所有选中的单元格
* 可自动判别对齐小数点或分号(不含空格)
***************************************************/
(function() {
var oColumns = app.selection[0].columns,
i = 0,
rCount = app.selection[0].rows.length,
@moluapple
moluapple / MetroUIDemo.jsx
Created July 8, 2012 06:30
Metro-like ScriptUI Demo
#include 'doEx.jsx'
#targetengine 'MetroUIDemo'
(function () {
var metro = {
'Magenta': [255, 0, 151],
'Purple': [162, 0, 255],
'Teal': [0, 171, 169],
'Lime': [140, 191, 38],
'Brown': [160, 80, 0],
'Pink': [230, 113, 184],
@moluapple
moluapple / gist:3015959
Created June 29, 2012 05:23
将 sql 数据导出为 csv 文件
# -*- coding: utf-8 -*-
# http://stackoverflow.com/questions/3710263/how-do-i-create-a-csv-file-from-database-in-python
# 如遇编码错误,可使用python3
import csv
import sqlite3
conn = sqlite3.connect("pcd.db")
cursor = conn.cursor()
cursor.execute("select * from domain_data;")
@moluapple
moluapple / gist:2719021
Created May 17, 2012 13:44
AI CS6 Application.executeMenuCommand(menuCommandString: string ) 方法参数列表
menuCommandString,UI MenuString zh_CN
-------------------------------------
new,新建
newFromTemplate,从模板新建
open,打开
saveacopy,存储副本
Adobe AI Save For Web,存储为 Web 所用格式(W)
Adobe AI Save Selected Slices,存储选中的切片
revert,恢复
AI Place,置入(L)
@moluapple
moluapple / PSD_Fonts_Extractor.py
Created May 10, 2012 13:32
解析获取 PSD 文档所用字体列表
'''
此脚本为 python3 版。
'''
import re
def selectFile():
'''利用win32ui选择文件对话框
如果未安装此模块则弹窗输入路径'''
@moluapple
moluapple / Menu_Action_JS.jsx
Last active May 16, 2020 17:29
[Illustrator]Create, load and execute action all by JS only
// CS6 only
var set = 'Script Action', // 动作集名称
action = 'PastePDF', // 动作名称
menuEn = 'paste', // 菜单英文
menuZh = '粘贴', // 菜单中文
actionStr = ['/version 3',
'/name [ ' + set.length,
ascii2Hex(set),
']',
@moluapple
moluapple / Hex_encode_decode.jsx
Created May 1, 2012 13:33
字符及其 Hex 值互换
function hex2Ascii (str) {
return str.replace(/../g, function (a) {return String.fromCharCode('0x' + a)})
}
function ascii2Hex (hex) {
return hex.replace(/./g, function (a) {return a.charCodeAt(0).toString(16)})
}
function GBK2Hex (str/*中文字符*/) {
var f = File('hex.txt'), hex;