Skip to content

Instantly share code, notes, and snippets.

View Mon-ius's full-sized avatar
🎯
Focusing

Monius Mon-ius

🎯
Focusing
View GitHub Profile
@nghia4007
nghia4007 / setup_disk.sh
Last active February 25, 2024 13:28
setup_alpine.sh
#!/bin/sh
PREFIX=
: ${LIBDIR=$PREFIX/lib}
. "$LIBDIR/libalpine.sh"
. "$LIBDIR/dasd-functions.sh"
MBR=${MBR:-"/usr/share/syslinux/mbr.bin"}
ROOTFS=${ROOTFS:-ext4}
BOOTFS=${BOOTFS:-ext4}
@pagxir
pagxir / residence.pac
Last active June 1, 2024 10:30
proxy auto config for split domain into oversea and big local network.
const _net_count = 15641;
const _net_list = [
{"net": 0x01000000, "prefix": 24}, {"net": 0x01000400, "prefix": 22}, {"net": 0x01001000, "prefix": 20}, {"net": 0x01004000, "prefix": 18},
{"net": 0x01008000, "prefix": 17}, {"net": 0x01010100, "prefix": 24}, {"net": 0x01014000, "prefix": 18}, {"net": 0x01018000, "prefix": 17},
{"net": 0x01020300, "prefix": 24}, {"net": 0x01028000, "prefix": 17}, {"net": 0x01040000, "prefix": 24}, {"net": 0x01048000, "prefix": 17},
{"net": 0x01050000, "prefix": 16}, {"net": 0x01060000, "prefix": 15}, {"net": 0x01090000, "prefix": 16}, {"net": 0x010a0a00, "prefix": 24},
{"net": 0x010a8000, "prefix": 17}, {"net": 0x010b0000, "prefix": 16}, {"net": 0x01100000, "prefix": 13}, {"net": 0x01200000, "prefix": 13},
{"net": 0x01280000, "prefix": 14}, {"net": 0x012c0000, "prefix": 16}, {"net": 0x012e0000, "prefix": 15}, {"net": 0x01340000, "prefix": 14},
{"net": 0x01400000, "prefix": 14}, {"net": 0x01480000, "prefix": 13}, {"net": 0x016
@jaklinger
jaklinger / read_torch_from_s3.py
Last active June 9, 2024 14:50
Read a torch model from S3
import torch
from contextlib import contextmanager
import boto3
from io import BytesIO
from transformers import PretrainedConfig, PreTrainedModel
import json
from tempfile import NamedTemporaryFile
BUCKET_NAME = "open-jobs-lake"
use std::{
fs::File,
io::{Read, Write},
time::Instant,
};
use tokio::task::{self, JoinHandle};
async fn compute() {
let handles: Vec<JoinHandle<_>> = (0..1000)
.map(|_| {
@lbrame
lbrame / podman_arch_rootless.md
Created February 11, 2020 17:47
Running rootless unprivileged Podman containers on Arch Linux

Setting up podman rootless containers on Arch Linux

Podman is a container engine that is similar to and fully compatible with Docker that has the peculiarity of not requiring a daemon to run and to allow for rootless containers, which are often deemed safer than privileged containers running as root. Podman is a drop-in replacement for Docker that even supports the same syntax and it has good support from Red Hat.

However, running podman rootless containers on Arch Linux may not be obvious, so I'm writing the instructions I have used to achieve that here.

Podman works using control groups and users from which said containers need to be launched need to be assigned an appropriate range of subordinate user and group IDs. On Arch Linux, these files are not present and they need to be created.

From a root shell:

@gdamjan
gdamjan / README.md
Last active February 7, 2024 21:11
run a minimal alpine based initramfs in VM machine

in 5 easy steps

1

get cloud-hypervisor or firecracker

2

compile a kernel (use the provided x_kernel_config file), you'll need the stripped ELF file in arch/x86/boot/compressed/vmlinux.bin or the compressed bzImage for cloud-hypervisor.

Exploiting Lua 5.1 on x86_64

The following Lua program generates a Lua bytecode program called lua-sandbox-rce.luac, which in turn spawns a shell from within Lua 5.1 sandbox. The remainder of this document attempts to explain how this program works by a whirlwind tour of relevent bits of the Lua 5.1 virtual machine.

function outer()
  local magic -- In bytecode, the stack slot corresponding to this local is changed
  local function middle()
    local co, upval
    local ub1 = {[0] = -- Convert uint8_t to char[1]
@profOnno
profOnno / Alpine_linux_on_tilaa.md
Last active February 25, 2024 13:35
Alpine linux on Tilaa

Introduction

Tilaa is my vps provider but doesn't have alpine in the install options After playing around with the vps systems... coreos ubuntu.. i did make mistakes... coreos got invaded ... opened a webgui... forgot to protect it... needed to get some data from it. So used the Tilaa rescue boot (in the Dashboard) and mounted the disks. Also used it when i increased the disk size for an installation (if I remember correctly), deleting the partition, creating a new one with the same starting address), do a resize2fs to expand and voila.. Bob was my uncle.

After playing arround with Alpine Linux in coreos and ubuntu lxd. I thought it would be a nice distro to get running straight from the vps. A weekend without sunlight but with pixellight I got it running, needs another iteration to make it a smooth experiance :o.

DISCLAIMER Any action you take upon the information on this page is strictly at your own risk, I won't be liable for any losses and damages in connection with the use of this page.

St

@jancurn
jancurn / proxy-chain-example.js
Last active February 29, 2024 07:26
Example showing how to use the proxy-chain NPM package to let headless Chrome use a proxy server with username and password
const puppeteer = require('puppeteer');
const proxyChain = require('proxy-chain');
(async() => {
const oldProxyUrl = 'http://bob:password123@proxy.example.com:8000';
const newProxyUrl = await proxyChain.anonymizeProxy(oldProxyUrl);
// Prints something like "http://127.0.0.1:45678"
console.log(newProxyUrl);
@mbinna
mbinna / effective_modern_cmake.md
Last active December 25, 2024 05:52
Effective Modern CMake

Effective Modern CMake

Getting Started

For a brief user-level introduction to CMake, watch C++ Weekly, Episode 78, Intro to CMake by Jason Turner. LLVM’s CMake Primer provides a good high-level introduction to the CMake syntax. Go read it now.

After that, watch Mathieu Ropert’s CppCon 2017 talk Using Modern CMake Patterns to Enforce a Good Modular Design (slides). It provides a thorough explanation of what modern CMake is and why it is so much better than “old school” CMake. The modular design ideas in this talk are based on the book [Large-Scale C++ Software Design](https://www.amazon.de/Large-Scale-Soft