This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::fmt; | |
const UNITS: [char; 4] = ['K', 'M', 'G', 'T']; | |
pub struct Filesize(pub usize); | |
impl fmt::Display for Filesize { | |
fn fmt(&self, f: &mut fmt::Formatter<'_>) | |
-> fmt::Result { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
'''recover /rsyncd-munged/ symlinks''' | |
import sys | |
import os | |
def main(topdir): | |
for root, dirs, files in os.walk(topdir): | |
for f in files: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import os | |
import glob | |
def main(): | |
patterns = [ | |
'/sys/block/*/device/power/control', | |
'/sys/bus/i2c/devices/*/device/power/control', | |
'/sys/bus/pci/devices/*/power/control', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
unshare -m bash <<'EOF' | |
mount --make-rprivate / | |
for f in /etc/pacman.d/*.sync; do | |
filename="${f%.*}" | |
mount --bind "$f" "$filename" | |
done | |
pacman -Sy | |
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
from functools import partial | |
def colors16(): | |
for bold in [0, 1]: | |
for i in range(30, 38): | |
for j in range(40, 48): | |
print(f'\x1b[{bold};{i};{j}m {bold};{i};{j} |\x1b[0m', end='') | |
print() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<sys/time.h> | |
#include<stdbool.h> | |
#include<signal.h> | |
#include<stdint.h> | |
#include<sys/resource.h> | |
volatile uint64_t count = 0; | |
void alarm_handler() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//===================================================================== | |
// 让 zsh 的历史记录可读 | |
//===================================================================== | |
#include<stdio.h> | |
#include<stdlib.h> | |
#include<string.h> | |
//--------------------------------------------------------------------- | |
void readhist(); | |
void writehist(); | |
void usage(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import asyncio | |
import time | |
import socket | |
import argparse | |
import aiohttp | |
class MyConnector(aiohttp.TCPConnector): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import os | |
def allrepofiles(): | |
repo = '/var/lib/pacman/local' | |
files = set() | |
for dirpath, dirnames, filenames in os.walk(repo): | |
for file in filenames: | |
if file != 'files': |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import os | |
import datetime | |
import subprocess | |
import logging | |
import tempfile | |
import contextlib | |
from pathlib import Path |
NewerOlder