Skip to content

Instantly share code, notes, and snippets.

@holly
holly / drop_cache.sh
Last active May 27, 2020 00:13
sync and drop cache
#!/bin/sh
sync; sync; sync
echo 3 >/proc/sys/vm/drop_caches
@holly
holly / nc-http.sh
Created October 11, 2015 12:48
oneliner http server
while true; do echo -n -e "HTTP/1.1: 200 OK\n\nHello world\n" | nc -l 8080; done
@holly
holly / nc-tcp-forward.sh
Created October 17, 2015 02:32
easy tcp port forwarding by netcat
#!/usr/bin/env bash
set -e
if [ $# != 3 ]; then
echo 'Usage: nc-tcp-forward.sh $FRONTPORT $BACKHOST $BACKPORT' >&2
exit 1
fi
@holly
holly / make-rir-delegated-latest.py
Last active October 7, 2021 04:02
make afrinic/apnic/arin/ripe/lacnic delegated-latest ipv4 and ipv6 list script
#!/usr/bin/env python
# vim:fileencoding=utf-8
""" [NAME] script or package easy description
[DESCRIPTION] script or package description
"""
from datetime import datetime
from argparse import ArgumentParser
import pprint
@holly
holly / inotify.py
Created November 15, 2015 04:27 — forked from quiver/inotify.py
Python implementation of "IBM DeveloperWorks : Monitor Linux file system events with inotify"
import collections
import ctypes
import ctypes.util
# bit masks
IN_ISDIR = 0x40000000
IN_ALL_EVENTS = 0xfff
class inotify_event_struct(ctypes.Structure):
"""
#!/usr/bin/env python
from ctypes import CDLL, CFUNCTYPE, c_char_p, c_int, c_uint32
from ctypes.util import find_library
import argparse
import os
import struct
import sys
import select
cat /dev/urandom | tr -dc "a-zA-Z0-9" | fold -w48 | head
@holly
holly / make-country-list.py
Last active November 29, 2015 13:35
output country data from https://restcountries.eu/ api
#!/usr/bin/env python3
# vim:fileencoding=utf-8
""" [NAME] script or package easy description
[DESCRIPTION] script or package description
"""
from datetime import datetime
from argparse import ArgumentParser, FileType
import pprint
#!/usr/bin/env python3
# vim:fileencoding=utf-8
""" [NAME] script or package easy description
[DESCRIPTION] script or package description
"""
from datetime import datetime
from argparse import ArgumentParser
import pprint
#!/bin/sh
#--- memo --
# 参考:https://sites.google.com/site/glusterfstech/install
#--- vm.swappiness [デフォルト:60]
# 0にすると物理メモリを使いきるまでswapしなくなる。
#--- vm.dirty_background_ratio [デフォルト:10]
#メモリに対してdirtyデータが指定の%になるとバックグラウンドでpdflushが動作