Skip to content

Instantly share code, notes, and snippets.

View devlights's full-sized avatar
🤧
hay fever....

devlights devlights

🤧
hay fever....
View GitHub Profile
@devlights
devlights / print_datetime.py
Created January 30, 2018 11:18
[python] 指定したUNIX時間を yyyy/mm/dd hh:mm:ss 形式で表示
def pt(secs=None):
import time
s = secs if secs else time.time()
t = time.localtime(s)
return time.strftime('%Y/%m/%d %H:%M:%S', t)
@devlights
devlights / install_wkhtmltopdf_using_homebrew.md
Created January 13, 2018 18:53
Mac で wkhtmltopdf のインストール (homebrew 経由で)

mac で wkhtmltopdf のインストール

$ brew search wkhtmltopdf
==> Searching local taps...
==> Searching taps on GitHub...
caskroom/cask/wkhtmltopdf
$ brew tap caskroom/cask
Updating Homebrew...
$ brew cask install wkhtmltopdf
@devlights
devlights / removereadonly.py
Last active November 16, 2017 10:49
[PYTHON] 指定したディレクトリ以下の全ファイルの読取り専用を外す (Windows)
"""
指定したディレクトリ以下の全ファイルの読取り専用を外します。
デフォルトはカレントディレクトリを対象とします。
"""
import os
import stat
DEFAULT_DIR = '.'
@devlights
devlights / c_cpp_properties.json
Created November 13, 2017 12:04
[VSCODE] Windows で MinGW 使ってビルドできるようにする設定(まだ実行までは出来ていないけど)
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceRoot}",
"C:/MinGW/include",
"C:/MinGW/lib/gcc/mingw32/4.9.3/include"
],
"defines": [
@devlights
devlights / find_command_like_LINUX_on_windows.md
Last active November 1, 2017 04:36
[Windows][CommandPrompt] WindowsでLinuxのfindコマンドみたいにファイル検索するコマンド

Linux

$ find . -name "__init__.py"

Windows

> where /r . "__init__.py"
@devlights
devlights / gcd.py
Last active October 23, 2017 03:48
[python] 最大公約数求める
import functools
import time
def timetrace(func):
@functools.wraps(func)
def _wrapper(*args, **kwargs):
start = time.time()
results = func(*args, **kwargs)
end = time.time()
print(f'Took {end - start} sec')
@devlights
devlights / howto_create_ipython_startup_config_file.md
Created October 20, 2017 02:31
[Python] IPythonの起動時に指定したモジュールを読み込んでもらう

概要

$ ipython profile create
  • $HOME/.ipython/profile_default の下にファイルが作成される
  • ipython_config.py を編集

起動時に指定したモジュールを読み込み

@devlights
devlights / upd_git_committime.py
Last active October 9, 2017 05:48
本スクリプトは、予め pull を実施後に実行されることを想定しています。 なので、リモート周りのコマンドは使っていません。コミット履歴もローカルコミット履歴をみます。 (つまり、ls-filesを使って、ls-remoteは利用しません。) 動作には、python-dateutilとgitpythonモジュールが必要です。
# coding: utf-8
"""
ファイルの更新日付をコミット日時に調整します。
注意)本スクリプトは、予め pull を実施後に実行されることを想定しています。
なので、リモート周りのコマンドは使っていません。コミット履歴もローカルコミット履歴をみます。
(つまり、ls-filesを使って、ls-remoteは利用しません。)
動作には、python-dateutilとgitpythonが必要です。
@devlights
devlights / netsh_command_tips.md
Created April 21, 2017 14:18
netsh コマンドを使用してLANアナライズ

使い方

管理者モードでコマンドプロンプト起動

以下のコマンドを打ち込むとLANキャプチャ開始

netsh trace start capture=yes report=no persistent=no maxSize=0 fileMode=single correlation=no traceFile=c:\tmp\xxxxx.etl
@devlights
devlights / MulticoreJITSamples01.cs
Created April 9, 2017 10:05
System.Runtime.ProfileOptimizationクラスのサンプルです。 Monoには存在しない。
namespace Sazare.Samples
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime;
using Sazare.Common;
#region MulticoreJITSamples-01