Skip to content

Instantly share code, notes, and snippets.

@hershkoy
hershkoy / apache.conf
Last active December 18, 2022 11:56
log rotate apache on windows + zip
ErrorLog "logs/error.log"
#rotate every 2 minutes
ErrorLog "|bin/rotatelogs.exe -p C:/.../zip_logs.bat -l logs/errorlog.%Y-%m-%d-%H_%M_%S.log 120"
# or rotate every 20Mb
ErrorLog "|bin/rotatelogs.exe -p C:/.../zip_logs.bat -n 20 logs/error.log 20M"
@hershkoy
hershkoy / convertNPM.js
Last active February 23, 2022 15:07
convert npm module to browser
var soap = require('soap')
global.window.soap = soap
@hershkoy
hershkoy / gist:0fb256736be94ff56cc5a526bd7f482f
Created January 9, 2022 11:33
Connect to private github repo from windows using deploy keys
add to C:/Users/yourUser/.ssh/config: <= if you don't have .ssh folder, just do a ssh-gen in cmd
```
Host github_kiosker
HostName github.com
User git
IdentityFile C:/Users/Dev/.ssh/key.pem
```
then in cmd, you can clone using:
@hershkoy
hershkoy / dcssh.sh
Created June 29, 2021 20:20
CLI fast doscker-compose ssh to container (by service name)
#!/bin/bash
# this uses docker-compose service name, not container
containername="$1"
docker-compose exec $containername bash
@hershkoy
hershkoy / strace_example
Last active June 18, 2021 10:31
Strace example (on php-fpm)
mkdir strace_210618
cd strace_210618
ps aux | grep fpm
strace -o fpm.txt -ffF -ttT -p <pid1,pid2,pid3....>
strace-log-merge fpm.txt > fpm_sorted.txt
@hershkoy
hershkoy / docker_ssh.sh
Last active May 25, 2021 19:34
docker exec/ssh into container by the row number in docker ps -a
#!/bin/bash
ln="$1"
containername=`docker ps --format "{{.Names}}" | awk "FNR == $1"`
echo $containername
docker exec -it $containername bash
@hershkoy
hershkoy / gdrive_get_large_file.sh
Created December 9, 2020 08:27
Download large file from Google Drive (2020)
#!/bin/bash
if [ $# != 2 ]; then
echo "Usage: googledown.sh ID save_name"
exit 0
fi
confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id='$1 -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')
echo $confirm
wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$confirm&id=$1" -O $2 && rm -rf /tmp/cookies.txt
@hershkoy
hershkoy / init-docker.py
Created November 29, 2020 19:09
WSL2 - Init docker
import os
import re
from ipaddress import IPv4Interface, IPv6Interface
def main():
print("Getting ip")
# WSL_NIC = getWSLInterface()
proc = os.popen("wsl /sbin/ip -o -4 addr list eth0:1")
Start with one random point in first cluster.
"Grow" the cluster to near neighbors (below threshold).
Repeat until all cluster is discovered.
Then start with new cluster.
Agglomerate small clusters at the end
Benefits:
Unsupervised clustering (not need to supply k like in kmeans).
Drawbacks: