Skip to content

Instantly share code, notes, and snippets.

View prirority_queue.py
import heapq as hq
que = []
hq.heappush(que, (1, "TEST1"))
hq.heappush(que, (0, "TEST0"))
hq.heappush(que, (2, "TEST2"))
print(que)
priority, a = hq.heappop(que)
print(priority, a)
@pn11
pn11 / 2d_array.py
Created Aug 14, 2019
Creating two-dimensional array in Python. Result -> https://ideone.com/M2TpNg
View 2d_array.py
li = [[]] * 2
print(li)
li[0].append(1)
print(li)
print(id(li[0]))
print(id(li[1]))
li2 = [[] for _ in range(2)]
@pn11
pn11 / 0_README.md
Last active Jun 1, 2019
Retrieve Gists using GitHub API and Python3
View 0_README.md

Gists の API はこちら。

昔の Gist にたまにコメントついたりしてて気づかないことがあるので、API で取ろうとした。コメント数はとれるけどスター数やフォーク数は取れない。
あと新しいものから30個しか取れてない。

@pn11
pn11 / AHK_popup.md
Last active Nov 9, 2018
Pop-up window with AutoHotKey. AutoHotKey でポップアップ
View AHK_popup.md

Code

Progress, cbRed ct900000 cwBlue, test
Sleep 1500
Progress, Off

SplashTextOn,,, てすと
Sleep 1500
SplashTextOff
View Dockerfile
FROM python:3.5
RUN apt-get update && \
apt-get install -y git wget gzip
RUN git clone https://www.github.com/ildoonet/tf-openpose && \
cd tf-openpose && \
pip3 install -r requirements.txt && \
pip3 install opencv-python tensorflow && \
python setup.py install
@pn11
pn11 / docker_mount_currentdir.PS1
Created Oct 2, 2018
Mount current directory on a docker container using PowerShell.
View docker_mount_currentdir.PS1
$current_path = $(Resolve-Path .).ToString()
docker run -v ${current_path}:/data ubuntu bash
@pn11
pn11 / docker_image_exists.PS1
Created Oct 2, 2018
Check existence of Docker Image in PowerShell.
View docker_image_exists.PS1
$TAG = "ubuntu"
$IMAGE_ID = $(docker images -q $TAG)
if ($IMAGE_ID){
Write-Output "Docker Image ${IMAGE_ID} found."
}
else{
Write-Output "Docker Image not found."
}
@pn11
pn11 / problem_A.py
Created Jun 3, 2018
AtCoder 2018/06/02
View problem_A.py
A = int(input())
B = int(input())
for i in reversed(range(A+1)):
if i % B == 0:
print(i)
break
@pn11
pn11 / rakutenedy_csv.py
Last active May 30, 2018
rakutenedy_csv.py
View rakutenedy_csv.py
# -*- coding: utf-8 -*-
import sys
import time
USERNAME = 'xxxxxxxx@xxxxxxxx'
PASSWORD = 'xxxxxxxx'
DATESTR = '201507'
def get_html(datestr = DATESTR):