This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| import CoreML | |
| import AppKit | |
| //let kCVPixelFormatType_32Float: OSType = 0x0000001E // kCVPixelFormatType_32BGRA | |
| let modelInputKey = "input_image" | |
| var modelOutputKey = "output_image" // デフォルト。printで自動検出 | |
| guard CommandLine.arguments.count >= 3 else { | |
| print("Usage: RealESRGANApp input.png output.png") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # カレントディレクトリのすべての .mkv ファイルをループ | |
| for file in *.mkv; do | |
| # 拡張子を除いたファイル名を取得 | |
| # ${file%.*} は、ファイル名から最後のドット以降を削除します(例:example.mkv -> example) | |
| dirname="${file%.*}" | |
| # ファイル名と同じ名前のディレクトリを作成 | |
| # -p オプションは、すでにディレクトリが存在する場合にエラーを抑制します |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def split_list(list, n): | |
| if not list: | |
| return [] | |
| return [list[:n]] + split_list(list[n:], n) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #https://sites.google.com/site/hoseifujii/news/pythonniyorumugouzaonozaiguidingyiniyorushizhuang | |
| import random as r | |
| namelist=['apple','grape','orange','lemon','banana'] | |
| class node: | |
| def __init__(self, name, children): | |
| self.name = name # String | |
| self.children = children # List of Class node |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| MyClass = type( | |
| 'MyClass', | |
| (object), | |
| { | |
| '__init__': lambda self, val: setattr(self, '_val', val), | |
| 'say': lambda self: self._val, | |
| }, | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #http://a-zumi.net/python-singleton/ | |
| class Singleton(object): | |
| __instance = None | |
| # __new__は__init__の前に実行されるのでここでインスタンスが生成されているか確認する | |
| def __new__(cls, *args, **kwargs): | |
| if cls.__instance is None: | |
| cls.__instance = object.__new__(cls) | |
| return cls.__instance | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'http://qiita.com/ktyubeshi/items/74228f18498224c7427d | |
| Option Explicit | |
| Public Function REGEXP(文字列 As String, 正規表現文字列 As String, Optional SubMatchIndex As Integer = -1) | |
| 'Dim RE As VBScript_RegExp_55.REGEXP | |
| 'Dim ReMatch As MatchCollection | |
| 'Dim M As Match |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # http://kimihiro-n.appspot.com/show/5814395191951360 | |
| import csv | |
| import json | |
| result = [] | |
| with open('hoge.csv') as f: | |
| for line in csv.DictReader(f): | |
| line_json = json.dumps(line) | |
| result.append(line_json) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # coding: utf-8 | |
| # http://kimihiro-n.appspot.com/show/5814395191951360 | |
| import csv, json | |
| print([json.dumps(l) for l in csv.DictReader(open('hoge.csv'))]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # coding=utf-8 | |
| import csv | |
| template = 'Person(name=u"%(姓名)s", birthday="%(生年月日)s", sex=u"%(性別)s").save()' | |
| data = csv.reader(open('data.csv')) | |
| # ヘッダー行を飛ばす | |
| header = data.next() |
NewerOlder