Skip to content

Instantly share code, notes, and snippets.

@o8r
o8r / Win10Toast.ps1
Created April 16, 2021 07:19
Show toast in Windows 10 using Powershell
Param([string]$clsid, [string]$templateFile)
# Refer Windows Runtime
[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] > $null
[Windows.UI.Notifications.ToastNotification, Windows.UI.Notifications, ContentType = WindowsRuntime] > $null
# Read toast template XML
$template = Get-Content $templateFile
$xml = New-Object Windows.Data.Xml.Dom.XmlDocument
$xml.LoadXml($template)
@o8r
o8r / NUMBA_shifting_fill.py
Created November 11, 2020 02:55
Fast shifting copy using NUMBA
import numba
@numba.njit
def shifting_fill(src, dst):
"""Fill a 2D (or more multi-demensional) array-like object by shifting a 1D array, using NUMBA.
This is useful when making an input to a RNN from time series data, that is, where
src = [0, 2, 1, 3, 5]
and the number of time steps fed in the RNN is M=3,
dst = [
@o8r
o8r / MNIST_PyTorch-Lightning.ipynb
Created November 5, 2020 07:31
MNIST example using PyTorch-Lightning
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@o8r
o8r / notify2line.py
Created February 5, 2018 01:57
Simple utility to send a notify to LINE
#!/usr/bin/env/python
""" This sends a notification to LINE via LINE notify API.
:param str token: API token
:param *: messages
"""
import sys
@o8r
o8r / Github_search_commits.py
Created February 2, 2018 15:40
Add /search/commits to pygithub
# Define search function because pygithub does not support /search/commits API yet.
import github
def __Github_search_commits(self, word, sort=github.GithubObject.NotSet, order=github.GithubObject.NotSet, **kwargs):
"""
:calls: `GET /search/commit`
:param str word: string search keyword
:param str sort: string ('author-date', 'commiter-date') (default: best match)
:param str order: string ('desc', 'asc') (default: 'desc')
:param dict kwargs: dictionary including query parameter set
:rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Commit`
@o8r
o8r / setup_logger.py
Created February 2, 2018 15:34
Python logger setup
# Logger settings
from logging import getLogger, StreamHandler, DEBUG
logger = getLogger(__name__)
handler = StreamHandler()
handler.setLevel(DEBUG)
logger.setLevel(DEBUG)
logger.addHandler(handler)
logger.propagate = False
import logging
@o8r
o8r / line_notify_func.py
Last active February 5, 2018 01:58
Line notify sinpet
def line_notify(token, msg):
""" Post a notification to LINE.
:param str token: access token for LINE Notify
:param str msg: notifier message
"""
import requests
api = 'https://notify-api.line.me/api/notify'
payload = {'message': msg}