Skip to content

Instantly share code, notes, and snippets.

@sharow
sharow / monitoroff.py
Last active February 24, 2023 04:13
win: sleep monitor immediately
# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; coding: utf-8; -*-
from ctypes import *
user32 = WinDLL('User32')
DISPLAY_ON = -1
DISPLAY_OFF = 2
HWND_BROADCAST = 0xffff
WM_SYSCOMMAND = 0x0112
SC_MONITORPOWER = 0xf170
@somma
somma / create_process_as_login_user.cpp
Last active August 27, 2022 15:32
create_process_as_login_user
bool
create_process_as_login_user(
_In_ const wchar_t* cmdline
)
{
_ASSERTE(NULL != cmdline);
if (NULL == cmdline) return false;
DWORD session_id = WTSGetActiveConsoleSessionId();
DWORD explorer_pid = 0xFFFFFFFF;
@jamieweavis
jamieweavis / macos-app-icon.md
Last active June 13, 2026 16:56
How to create an .icns macOS app icon
@momijiame
momijiame / asyncioecho.py
Created March 28, 2017 08:06
asyncio の低レイヤーな API で書いたエコーサーバ
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import asyncio
import socket
# イベントループに使うオブジェクトを用意する
ev_loop = asyncio.get_event_loop()
# 接続してきたクライアントとの接続情報を格納する
connections = {}
@kgantsov
kgantsov / large_file_server.py
Created April 14, 2017 11:18
Example of serving large files using aiohttp server without reading entire file into a memory
import asyncio
import os
from aiohttp import web
from aiohttp import streamer
@streamer
async def file_sender(writer, file_path=None):
"""
@lucashxu
lucashxu / nbd.sh
Created July 31, 2017 14:47
Build Network Block Device Kernel Module On CentOS7
uname -r
sudo su
# useradd builder
# groupadd builder
cd /home/centos
# Get Source Code
wget http://vault.centos.org/7.2.1511/updates/Source/SPackages/kernel-3.10.0-327.28.3.el7.src.rpm
rpm -ivh kernel-3.10.0-327.28.3.el7.src.rpm
# Build Preparation
@tor4kichi
tor4kichi / #js-initial-watch-data.json
Last active May 28, 2021 05:13
ニコ動HTML5プレイヤーページの動画内部データJSONの例
{
"video": {
"id": "sm13924244",
"title": "【ポポポポーン】あいさつするたび速度落ちるね【シーク禁止】",
"originalTitle": "【ポポポポーン】あいさつするたび速度落ちるね【シーク禁止】",
"description": "ポポポポーン教信者なら余裕だよな?    加速:<a href=\"https:\/\/www.nicovideo.jp\/watch\/sm13924147\" class=\"watch\">sm13924147<\/a> ピッチアップ:<a href=\"https:\/\/www.nicovideo.jp\/watch\/sm13941513\" class=\"watch\">sm13941513<\/a> ピッチダウン:<a href=\"https:\/\/www.nicovideo.jp\/watch\/sm13941810\" class=\"watch\">sm13941810<\/a> あいさつするたび〇〇【<a href=\"https:\/\/www.nicovideo.jp\/mylist\/24558006\" target=\"_blank\" rel=\"noopener\">mylist\/24558006<\/a>】 移動順 加速→ピッチアップ→減速→ピッチダウン→加速(以下ry 無限ループってこわくね?",
"originalDescription": "ポポポポーン教信者なら余裕だよな?    加速:sm13924147 ピッチアップ:sm13941513 ピッチダウン:sm13941810 あいさつするたび〇〇【mylist\/24558006】 移動順 加速→ピッチアップ→減速→ピッチダウン→加速(以下ry 無限ループってこわくね?",
"thumbnailURL": "https:\/\/tn.smilevideo.jp\/smile?i=13924244",
"largeThumbnailURL": null,
"postedDateTime": "2011\/03\/22 02:18:29",
@khardix
khardix / download.py
Created October 6, 2017 11:26
Python AsyncIO/aiohttp downloader with progressbars
#!/usr/bin/env python3.6
import asyncio
from contextlib import closing
import aiohttp
import tqdm
async def download(session, url, progress_queue):
@ifduyue
ifduyue / -.md
Last active June 27, 2026 14:24
Resolve pycurl: libcurl link-time ssl backend (nss) is different from compile-time ssl backend (openssl)
# yum
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:

   pycurl: libcurl link-time ssl backend (nss) is different from compile-time ssl backend (openssl)

Please install a package which provides this module, or
verify that the module is installed correctly.
@NominaceTacitus
NominaceTacitus / powercfg-win10-more-settings.cmd
Last active August 3, 2024 19:07 — forked from theultramage/powercfg-win7-all-settings.bat
Show/hide hidden settings in Win10 Power Options
@echo on
REM checked for Windows 10
REM fork from https://gist.github.com/theultramage/cbdfdbb733d4a5b7d2669a6255b4b94b
REM you may want full list https://gist.github.com/raspi/203aef3694e34fefebf772c78c37ec2c
REM SET attrib=+ATTRIB_HIDE
SET attrib=-ATTRIB_HIDE
REM Hard disk burst ignore time
powercfg -attributes 0012ee47-9041-4b5d-9b77-535fba8b1442 80e3c60e-bb94-4ad8-bbe0-0d3195efc663 %attrib%