Skip to content

Instantly share code, notes, and snippets.

@kayoch1n
kayoch1n / getifaddrs_linux.c
Last active December 4, 2022 02:59
getifaddrs on *nix
// gcc getifaddrs_linux.c -o getifaddrs_linux
// ./getifaddrs_linux
// https://stackoverflow.com/a/12878352
#include <stdlib.h> //exit()
#include <stdio.h> //printf(),perror()
#include <string.h> //memset
#include <ifaddrs.h> //struct ifaddrs,getifaddrs()
#include <arpa/inet.h> //INET6_ADDRSTRLEN,inet_ntop()
#include <netinet/in.h> //sockaddr_in,sockaddr_in6
@kayoch1n
kayoch1n / scripts.sh
Created November 24, 2022 03:20
Handy command lines
#!/bin/sh
# keep ssh shell alive
# https://stackoverflow.com/a/29458738/8706476
ssh ubuntu@xxxx -o ServerAliveInterval=60
@kayoch1n
kayoch1n / nfs_client.sh
Last active November 23, 2022 09:32
init NFS server/client on ubuntu
#!/bin/sh
# https://ubuntu.com/server/docs/service-nfs
# client
# https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/4/html/reference_guide/s2-nfs-client-config-options
sudo mount 172.16.0.7:/home/ubuntu/nfsroot /opt/172-16-0-7/ -o nfsvers=2
cat /proc/mounts | grep nfsroot
cat /opt/172-16-0-7/README.md
# sudo umount /opt/172-16-0-7/
@kayoch1n
kayoch1n / check_github_repo_size
Created January 26, 2021 15:32 — forked from dingzeyuli/check_github_repo_size
Check the size of a github repo before downloading
# http://webapps.stackexchange.com/questions/39587/view-estimated-size-of-github-repository-before-cloning
# tested on macOS
echo https://github.com/torvalds/linux.git | perl -ne 'print $1 if m!([^/]+/[^/]+?)(?:\.git)?$!' | xargs -I{} curl -s -k https://api.github.com/repos/'{}' | grep size
# output:
# "size": 1746294,