Skip to content

Instantly share code, notes, and snippets.

from contextlib import contextmanager
import random
class Prot:
def __init__(self):
pass
@contextmanager
def yoyo(self, hey):
print('gacha.') # __enter__
@trsqxyz
trsqxyz / zui.py
Last active August 29, 2015 14:21
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import platform
import sys
import webbrowser
import functools
import config
@trsqxyz
trsqxyz / file0.txt
Created May 21, 2015 11:35
例外をつかってスクリプトをコントロールする ref: http://qiita.com/trsqxyz/items/f58a4f72c4a62340e1df
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import time
class StopWatching(Exception):
pass
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import random
import webbrowser
class Barista():
def __init__(self):
with open('README.md') as beans:
shops = [shop.split(" ") for shop in beans.readlines() if shop[0] == '-']

With administrative PowerShell
iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
choco version
choco install python
python -V

PowerShell の Invoke-Item で OS X の open -a application.app filename.file
に相当することできるかなと思って調べたけど 関連するプログラムで開くだけで アプリケーションの指定はできないっぽかった でも
application filename.file
のでむしろ楽っぽい

関係ないけど PowerShell コマンドが短く出来てかいてておもしろい
touch 相当のことが
ni -it file -n text.txt
明示したいときもわかりやすくできるし Tab 補完されるのもうれしい

@trsqxyz
trsqxyz / alias
Last active January 29, 2018 22:21
powershell
CommandType Name ModuleName
----------- ---- ----------
Alias % -> ForEach-Object
Alias ? -> Where-Object
Alias ac -> Add-Content
Alias asnp -> Add-PSSnapin
Alias cat -> Get-Content
Alias cd -> Set-Location
Alias chdir -> Set-Location
Alias clc -> Clear-Content
echo 'display notification "test" with title"title" subtitle"subtitle"' | osascript
def life(self, times=4, first='*', last=None):
yield first
for _ in range(times):
yield '*'
if last is None:
raise StopIteration
yield last
import sys
import time
a = '\-/|'
while True:
for _ in a:
sys.stdout.write('\r{0}'.format(_))
sys.stdout.flush()
time.sleep(0.1)