Skip to content

Instantly share code, notes, and snippets.

@masamitsu-murase
masamitsu-murase / run_as_admin.cmd
Created March 7, 2018 14:40
Run Python script as Administrator.
@goto BEGINNING_OF_CMD
# -*- coding: UTF-8 -*-
"""
:BEGINNING_OF_CMD
@echo off
cd /d "%~dp0"
set PYTHON=python.exe
%PYTHON% -c "import ctypes, sys, ctypes.wintypes; ctypes.windll.shell32.IsUserAnAdmin.restype = ctypes.wintypes.BOOL; sys.exit(ctypes.windll.shell32.IsUserAnAdmin())"
if ERRORLEVEL 2 goto :ERROR
if ERRORLEVEL 1 goto :ADMIN
@masamitsu-murase
masamitsu-murase / interactive.cmd
Last active March 8, 2018 05:25
Interactive Shell for Python with pyreadline
@goto RUN_PYTHON
# -*- coding: UTF-8 -*-
"""
:RUN_PYTHON
@echo off
cd /d "%~dp0"
python -x -i "%~nx0"
exit /b %ERRORLEVEL%
"""
@masamitsu-murase
masamitsu-murase / sample.html
Created September 11, 2012 17:30
mruby with NPAPI plugin
<script id="ruby_script" type="text/ruby">
#<![CDATA[
num = 0
1000.times do |i|
num += i
end
hash = { result: num, input: $input } # $input has JavaScript function.
hash[:input].call({ a: num }) # JS function is called.
$result = hash[:result]
# ]]>