Skip to content

Instantly share code, notes, and snippets.

View Rashoru-Infinity's full-sized avatar

Keita Hagiwara Rashoru-Infinity

View GitHub Profile
FROM greymd/ojichat
RUN apk update && \
apk --no-cache add openssh \
shadow && \
ssh-keygen -q -N "" -t rsa -b 4096 -f /etc/ssh/ssh_host_rsa_key && \
adduser -D -H foo && \
usermod -p -U foo && \
echo 'foo:password' | chpasswd && \
echo "HostKey /etc/ssh/ssh_host_rsa_key" >> /etc/ssh/sshd_config && \
echo "PermitRootLogin no" >> /etc/ssh/sshd_config && \
FROM ubuntu:focal AS builder
RUN apt-get update && \
apt-get install --no-install-recommends -y gcc \
make \
libssh-dev \
ca-certificates \
libmysqlclient-dev \
git && \
apt-get clean && \
package main
import (
"encoding/json"
"flag"
"fmt"
"github.com/gocolly/colly"
"github.com/influxdata/influxdb-client-go/v2"
"io"
"log"
find ./ -type f -printf "%f\n" | awk -F'[.]' '{print $1}' | xargs -I{} mkdir {} && find ./ -type f -printf "%f\n" | awk -F'[.]' '{print $1}' | xargs -I{} unzip {}.zip -d {}
#include <stdio.h>
#include <errno.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdint.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
typedef struct machine_s
virsh list | grep running | awk '{print $2}' |\
xargs -I{} sh -c 'virsh vcpuinfo {} | tail -6 |\
head -1' | awk '{print $2}' | xargs -I{} expr {} + 1 |\
awk '{sum+=$1}END{print sum}'
@Rashoru-Infinity
Rashoru-Infinity / thread_pool_socket_server.cc
Created September 18, 2024 21:07
thread pool socket server example
#include <sys/epoll.h>
#include <sys/mman.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
#include <array>
#include <cctype>
#include <condition_variable>
#include <cstring>
@Rashoru-Infinity
Rashoru-Infinity / bm_search.c
Created October 6, 2024 21:10
implementation of bm_search without c standard library
#include <alloca.h>
#include <stdio.h>
#include <string.h>
static void make_shift(unsigned long *shift, const char *ptrn, unsigned long ptrn_len)
{
unsigned long *border_position = alloca((ptrn_len + 1) * sizeof(unsigned long));
unsigned long i = ptrn_len;
unsigned long j = i + 1;
border_position[i] = j;