Skip to content

Instantly share code, notes, and snippets.

@t2psyto
t2psyto / testwin32.py
Created June 8, 2012 10:35
change Chrome window title text by python win32
import sys
import ctypes
user32 = ctypes.windll.user32
def getClassName(hwnd):
resultString = ctypes.create_string_buffer("\000" * 32)
user32.GetClassNameA(hwnd, resultString, len(resultString))
return resultString.value
@t2psyto
t2psyto / gist:3550904
Created August 31, 2012 09:41
jscript な coffeescript で console.log() したいとき
# console.log()
# for jscript coffee.bat
# https://github.com/thinca/coffee-script-on-jscript
if (typeof console == "undefined")
console = new class
log: (message) ->
WScript.Echo(message)
@t2psyto
t2psyto / gist:3787469
Created September 26, 2012 11:30
coffeescript を ロードして実行する wsf
<?xml version="1.0" encoding="Shift_JIS" standalone="yes" ?>
<package>
<job id="Hoge">
<script language="JScript" src="./coffee-script.js"></script>
<script language="jscript">
<![CDATA[
input = "./script.coffee"
var rs = new ActiveXObject("ADODB.Stream");
rs.Type = 2; // adTypeText
@t2psyto
t2psyto / gitlab_curl_post
Created October 4, 2012 15:47
curl POST to gitlab snippets api
$ cat > content.py
# -*- coding: utf-8 -*-
# 日本語
# あめんぼあかいなあいうえお
def hello():
print "hello world!"
if __name__ == "__main__":
hello()
^D
curl.exe -d '{"private_token":"qp6szjqmk8bTyMBrnJo5","title":"test1","file_name":"content1.py","code":"hogehoge\nhoge"}' http://demo.gitlabhq.com/api/v2/projects/rubinius/snippets
@t2psyto
t2psyto / accesspoint.py
Created November 6, 2012 12:15
mac address maintainer for WZR-G144N, AP-50W, WLA2-G54C
# -*- coding: cp932 -*-
import mechanize as mc
import time
import sgmllib
import re
class Stripper(sgmllib.SGMLParser):
def __init__(self):
sgmllib.SGMLParser.__init__(self)
username = "username"
password = "password"
from selenium import webdriver
driver = webdriver.Ie("c:/path/to/IEDriverServer.exe")
#driver.window_handles
driver.get("https://websearch.rakuten.co.jp/login.html?tool_id=1")
driver.find_element_by_name("u").send_keys(username)
driver.find_element_by_name("p").send_keys(password)
#-*- coding: utf-8 -*-
filename = "c:/TEMP/gihyosd_2001-2012_index.html"
from StringIO import StringIO
import gzip
import BeautifulSoup as BS
import urllib2
# workaround for beautifulsoup bug.
# info:
@t2psyto
t2psyto / robocopy_backyup.bat
Created May 30, 2013 06:03
backup script using robocopy with mail notify.
rem パックアップパラメータ バックアップ元/先「SRC → TARGET」
set SRC=\\server\share
set TARGET=D:\backup_data
rem timestamp -> YYMMDDhhmmss
rem 時刻1桁のゼロ埋め ex) " 9:00:00.00" -> "09:00:00.00"
set timetemp=%time: =0%
set timesec=%timetemp::=%
set timestamp=%date:/=%%timesec:~0,6%
@t2psyto
t2psyto / adhoc_folder_redirect
Created June 18, 2013 07:58
デスクトップログオン後にフォルダリダイレクトする。リダイレクト情報を一時的に書き換える。
taskkill /F /IM explorer.exe
set remotehome=\\server\data\username
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "Personal" /d "%remotehome%\マイドキュメント" /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "Desktop" /d "%remotehome%\デスクトップ" /f
start explorer
sleep 1
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "Personal" /d "%USERPROFILE%\Documents" /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "Desktop" /d "%USERPROFILE%\Desktop" /f